Skip to content

Commit 8d7d82a

Browse files
authored
Merge pull request #231 from jgonggrijp/manrueda-omitPath
Finish @manrueda's omitPath
2 parents bdf07e3 + f00f6e4 commit 8d7d82a

File tree

4 files changed

+206
-16
lines changed

4 files changed

+206
-16
lines changed

docs/underscore.object.builders.js.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _.frequencies(citations);
2626

2727
Returns a new object resulting from merging the passed objects. Objects
2828
are processed in order, so each will override properties of the same
29-
name occurring in earlier arguments.
29+
name occurring in earlier arguments.
3030

3131
Returns `null` if called without arguments.
3232

@@ -148,3 +148,27 @@ obj === imperialObj;
148148
```
149149

150150
--------------------------------------------------------------------------------
151+
152+
#### omitPath
153+
154+
**Signature:** `_.omitPath(obj:Object, ks:String|Array)`
155+
156+
Returns a copy of `obj` excluding the value represented by the `ks` path.
157+
Path may be given as an array or as a dot-separated string.
158+
159+
```javascript
160+
var test = {
161+
foo: true,
162+
bar: false,
163+
baz: 42,
164+
dada: {
165+
carlos: {
166+
pepe: 9
167+
},
168+
pedro: 'pedro'
169+
}
170+
};
171+
172+
_.omitPath(test, 'dada.carlos.pepe');
173+
// => {foo: true, bar: false, baz: 42, dada: {carlos: {}, pedro: 'pedro'}}
174+
```

0 commit comments

Comments
 (0)