A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/gearcase/object-unset below:

gearcase/object-unset: Removes the property at path of object.

Removes the property at path of object.

$ npm install --save object-unset 

For more use-cases see the tests

var unset = require('object-unset');

unset({ a: { b: { c: 7 } } }, 'a');
// => {}

unset({ a: [{ b: { c: 7 } }] }, 'a[0]');
// => {a: [] }

unset({ a: [{ b: { c: 7 } }] }, 'a.0');
// => {a: [] }

unset({ a: { b: { c: 7 } } }, 'a.b.c');
// => { a: { b: {} } }

{ a: [{ b: { c: 7 } }] }, 'a[0].b.c');
// => { a: [{ b: {} }] }

unset({ a: [{ b: { c: 7 } }] }, 'a[0].d.c');
// => { a: [{ b: { c: 7 } }] }

unset(null, 'a.b.c');
// => null

unset({ a: 1 }, 'a.b.c.d');
// => { a: 1 }

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4