summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/stretchr/objx/mutations.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/stretchr/objx/mutations.go
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/stretchr/objx/mutations.go')
-rw-r--r--vendor/github.com/stretchr/objx/mutations.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/vendor/github.com/stretchr/objx/mutations.go b/vendor/github.com/stretchr/objx/mutations.go
index c3400a3f7..e7b8eb794 100644
--- a/vendor/github.com/stretchr/objx/mutations.go
+++ b/vendor/github.com/stretchr/objx/mutations.go
@@ -5,7 +5,14 @@ package objx
func (m Map) Exclude(exclude []string) Map {
excluded := make(Map)
for k, v := range m {
- if !contains(exclude, k) {
+ var shouldInclude = true
+ for _, toExclude := range exclude {
+ if k == toExclude {
+ shouldInclude = false
+ break
+ }
+ }
+ if shouldInclude {
excluded[k] = v
}
}
@@ -14,11 +21,11 @@ func (m Map) Exclude(exclude []string) Map {
// Copy creates a shallow copy of the Obj.
func (m Map) Copy() Map {
- copied := Map{}
+ copied := make(map[string]interface{})
for k, v := range m {
copied[k] = v
}
- return copied
+ return New(copied)
}
// Merge blends the specified map with a copy of this map and returns the result.
@@ -45,12 +52,12 @@ func (m Map) MergeHere(merge Map) Map {
// to change the keys and values as it goes. This method requires that
// the wrapped object be a map[string]interface{}
func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map {
- newMap := Map{}
+ newMap := make(map[string]interface{})
for k, v := range m {
modifiedKey, modifiedVal := transformer(k, v)
newMap[modifiedKey] = modifiedVal
}
- return newMap
+ return New(newMap)
}
// TransformKeys builds a new map using the specified key mapping.
@@ -65,13 +72,3 @@ func (m Map) TransformKeys(mapping map[string]string) Map {
return key, value
})
}
-
-// Checks if a string slice contains a string
-func contains(s []string, e string) bool {
- for _, a := range s {
- if a == e {
- return true
- }
- }
- return false
-}