Skip to content

Commit f00f6e4

Browse files
committed
Make _.omitPath consistent with path semantics in core Underscore (#177)
Now all tests pass.
1 parent ccd8283 commit f00f6e4

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

docs/underscore.object.builders.js.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ obj === imperialObj;
155155

156156
Returns a copy of `obj` excluding the value represented by the `ks` path.
157157
Path may be given as an array or as a dot-separated string.
158-
If the path contains an array, the value of the path will be removed from all the array elements.
159158

160159
```javascript
161160
var test = {

test/object.builders.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ $(document).ready(function() {
135135
}
136136
}, "should return the whole object because the path is empty");
137137

138-
assert.deepEqual(_.omitPath(a, 'dada.list.file'), {
138+
assert.deepEqual(_.omitPath(a, 'dada.list.0.file'), {
139139
foo: true,
140140
bar: false,
141141
baz: 42,
@@ -144,20 +144,20 @@ $(document).ready(function() {
144144
pedro: 'pedro',
145145
list: [
146146
{name: 'aa', more: {other: { a: 1, b: 2}}},
147-
{name: 'bb'}
147+
{file: '..', name: 'bb'}
148148
]
149149
}
150-
}, "should return an object without the value in each object of the list");
150+
}, "should return an object without the value in an element of the list");
151151

152-
assert.deepEqual(_.omitPath(a, 'dada.list.name'), {
152+
assert.deepEqual(_.omitPath(a, 'dada.list.1.name'), {
153153
foo: true,
154154
bar: false,
155155
baz: 42,
156156
dada: {
157157
carlos: { pepe: 9 },
158158
pedro: 'pedro',
159159
list: [
160-
{file: '..', more: {other: { a: 1, b: 2}}},
160+
{name: 'aa', file: '..', more: {other: { a: 1, b: 2}}},
161161
{file: '..'}
162162
]
163163
}
@@ -173,7 +173,7 @@ $(document).ready(function() {
173173
}
174174
}, "should return an object without the list");
175175

176-
assert.deepEqual(_.omitPath(a, 'dada.list.more.other.a'), {
176+
assert.deepEqual(_.omitPath(a, 'dada.list.0.more.other.a'), {
177177
foo: true,
178178
bar: false,
179179
baz: 42,

0 commit comments

Comments
 (0)