diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-06-21 13:10:40 -0700 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2018-06-21 16:10:40 -0400 |
commit | 8526739066ccb00ccd24b74650a7d7b284442985 (patch) | |
tree | 282512ae2ad95c98a9ca82de304a410b6b56685c /vendor/github.com/stretchr/objx/mutations.go | |
parent | a59ccaa8b3844895dde3980e6224fef46ff4a1c8 (diff) | |
download | chat-8526739066ccb00ccd24b74650a7d7b284442985.tar.gz chat-8526739066ccb00ccd24b74650a7d7b284442985.tar.bz2 chat-8526739066ccb00ccd24b74650a7d7b284442985.zip |
MM-10934 Update server dependencies. (#8981)
* Changing throttled import path.
* Upgrading dependencies.
Diffstat (limited to 'vendor/github.com/stretchr/objx/mutations.go')
-rw-r--r-- | vendor/github.com/stretchr/objx/mutations.go | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/vendor/github.com/stretchr/objx/mutations.go b/vendor/github.com/stretchr/objx/mutations.go index e7b8eb794..c3400a3f7 100644 --- a/vendor/github.com/stretchr/objx/mutations.go +++ b/vendor/github.com/stretchr/objx/mutations.go @@ -5,14 +5,7 @@ package objx func (m Map) Exclude(exclude []string) Map { excluded := make(Map) for k, v := range m { - var shouldInclude = true - for _, toExclude := range exclude { - if k == toExclude { - shouldInclude = false - break - } - } - if shouldInclude { + if !contains(exclude, k) { excluded[k] = v } } @@ -21,11 +14,11 @@ func (m Map) Exclude(exclude []string) Map { // Copy creates a shallow copy of the Obj. func (m Map) Copy() Map { - copied := make(map[string]interface{}) + copied := Map{} for k, v := range m { copied[k] = v } - return New(copied) + return copied } // Merge blends the specified map with a copy of this map and returns the result. @@ -52,12 +45,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 := make(map[string]interface{}) + newMap := Map{} for k, v := range m { modifiedKey, modifiedVal := transformer(k, v) newMap[modifiedKey] = modifiedVal } - return New(newMap) + return newMap } // TransformKeys builds a new map using the specified key mapping. @@ -72,3 +65,13 @@ 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 +} |