1
0
Fork 0

Merge 'v1.5.2' into master

This commit is contained in:
Fernandez Ludovic 2018-02-12 15:26:49 +01:00
commit 794c0206f3
338 changed files with 4158 additions and 48549 deletions

View file

@ -2,11 +2,10 @@ package objx
// Exclude returns a new Map with the keys in the specified []string
// excluded.
func (d Map) Exclude(exclude []string) Map {
func (m Map) Exclude(exclude []string) Map {
excluded := make(Map)
for k, v := range d {
var shouldInclude bool = true
for k, v := range m {
var shouldInclude = true
for _, toExclude := range exclude {
if k == toExclude {
shouldInclude = false
@ -17,7 +16,6 @@ func (d Map) Exclude(exclude []string) Map {
excluded[k] = v
}
}
return excluded
}
@ -38,19 +36,16 @@ func (m Map) Merge(merge Map) Map {
return m.Copy().MergeHere(merge)
}
// Merge blends the specified map with this map and returns the current map.
// MergeHere blends the specified map with this map and returns the current map.
//
// Keys that appear in both will be selected from the specified map. The original map
// Keys that appear in both will be selected from the specified map. The original map
// will be modified. This method requires that
// the wrapped object be a map[string]interface{}
func (m Map) MergeHere(merge Map) Map {
for k, v := range merge {
m[k] = v
}
return m
}
// Transform builds a new Obj giving the transformer a chance
@ -71,11 +66,9 @@ func (m Map) Transform(transformer func(key string, value interface{}) (string,
// This method requires that the wrapped object be a map[string]interface{}
func (m Map) TransformKeys(mapping map[string]string) Map {
return m.Transform(func(key string, value interface{}) (string, interface{}) {
if newKey, ok := mapping[key]; ok {
return newKey, value
}
return key, value
})
}