You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move _.omitPath to object.builders per comment by @joshuacc in #177
Also reimplements the function as suggested by @joshuacc. More tests
pass in this way, but still not all.
This is somewhat inconsistent; arguably, _.omitWhen, _.pickWhen and
_.selectKeys belong in object.builders, too.
assert.deepEqual(_.omitPath(a,'dada.carlos.pepe'),{foo: true,bar: false,baz: 42,dada: {carlos: {},pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return an object without the value that represent the path");
86
+
assert.deepEqual(_.omitPath(a,'dada.carlos'),{foo: true,bar: false,baz: 42,dada: {pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return an object without the value that represent the path");
87
+
assert.deepEqual(_.omitPath(a,''),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return the whole object because the path is empty");
88
+
89
+
assert.deepEqual(_.omitPath(a,'dada.list.file'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{name: 'aa',more: {other: {a: 1,b: 2}}},{name: 'bb'}]}},"should return an object without the value in each object of the list");
90
+
assert.deepEqual(_.omitPath(a,'dada.list.name'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}}},{file: '..'}]}},"should return an object without the value in each object of the list");
91
+
92
+
assert.deepEqual(_.omitPath(a,'dada.list'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro'}},"should return an object without the list");
93
+
94
+
assert.deepEqual(_.omitPath(a,'dada.list.more.other.a'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{file: '..',more: {other: {b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return an object without the value inside the values of the list");
assert.deepEqual(_.omitWhen(a,_.isEmpty),{baz: "something",quux: ['a']},"should return an object with kvs that return a falsey value for the given predicate");
assert.deepEqual(_.omitPath(a,'dada.carlos.pepe'),{foo: true,bar: false,baz: 42,dada: {carlos: {},pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return an object without the value that represent the path");
115
-
assert.deepEqual(_.omitPath(a,'dada.carlos'),{foo: true,bar: false,baz: 42,dada: {pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return an object without the value that represent the path");
116
-
assert.deepEqual(_.omitPath(a,''),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return the whole object because the path is empty");
117
-
118
-
assert.deepEqual(_.omitPath(a,'dada.list.file'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{name: 'aa',more: {other: {a: 1,b: 2}}},{name: 'bb'}]}},"should return an object without the value in each object of the list");
119
-
assert.deepEqual(_.omitPath(a,'dada.list.name'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{file: '..',more: {other: {a: 1,b: 2}}},{file: '..'}]}},"should return an object without the value in each object of the list");
120
-
121
-
assert.deepEqual(_.omitPath(a,'dada.list'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro'}},"should return an object without the list");
122
-
123
-
assert.deepEqual(_.omitPath(a,'dada.list.more.other.a'),{foo: true,bar: false,baz: 42,dada: {carlos: {pepe: 9},pedro: 'pedro',list: [{file: '..',more: {other: {b: 2}},name: 'aa'},{file: '..',name: 'bb'}]}},"should return an object without the value inside the values of the list");
0 commit comments