1# unset-value [![NPM version](https://img.shields.io/npm/v/unset-value.svg?style=flat)](https://www.npmjs.com/package/unset-value) [![NPM monthly downloads](https://img.shields.io/npm/dm/unset-value.svg?style=flat)](https://npmjs.org/package/unset-value) [![NPM total downloads](https://img.shields.io/npm/dt/unset-value.svg?style=flat)](https://npmjs.org/package/unset-value) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/unset-value.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/unset-value) 2 3> Delete nested properties from an object using dot notation. 4 5## Install 6 7Install with [npm](https://www.npmjs.com/): 8 9```sh 10$ npm install --save unset-value 11``` 12 13## Usage 14 15```js 16var unset = require('unset-value'); 17 18var obj = {a: {b: {c: 'd', e: 'f'}}}; 19unset(obj, 'a.b.c'); 20console.log(obj); 21//=> {a: {b: {e: 'f'}}}; 22``` 23 24## Examples 25 26### Updates the object when a property is deleted 27 28```js 29var obj = {a: 'b'}; 30unset(obj, 'a'); 31console.log(obj); 32//=> {} 33``` 34 35### Returns true when a property is deleted 36 37```js 38unset({a: 'b'}, 'a') // true 39``` 40 41### Returns `true` when a property does not exist 42 43This is consistent with `delete` behavior in that it does not 44throw when a property does not exist. 45 46```js 47unset({a: {b: {c: 'd'}}}, 'd') // true 48``` 49 50### delete nested values 51 52```js 53var one = {a: {b: {c: 'd'}}}; 54unset(one, 'a.b'); 55console.log(one); 56//=> {a: {}} 57 58var two = {a: {b: {c: 'd'}}}; 59unset(two, 'a.b.c'); 60console.log(two); 61//=> {a: {b: {}}} 62 63var three = {a: {b: {c: 'd', e: 'f'}}}; 64unset(three, 'a.b.c'); 65console.log(three); 66//=> {a: {b: {e: 'f'}}} 67``` 68 69### throws on invalid args 70 71```js 72unset(); 73// 'expected an object.' 74``` 75 76## About 77 78### Related projects 79 80* [get-value](https://www.npmjs.com/package/get-value): Use property paths (`a.b.c`) to get a nested value from an object. | [homepage](https://github.com/jonschlinkert/get-value "Use property paths (`a.b.c`) to get a nested value from an object.") 81* [get-values](https://www.npmjs.com/package/get-values): Return an array of all values from the given object. | [homepage](https://github.com/jonschlinkert/get-values "Return an array of all values from the given object.") 82* [omit-value](https://www.npmjs.com/package/omit-value): Omit properties from an object or deeply nested property of an object using object path… [more](https://github.com/jonschlinkert/omit-value) | [homepage](https://github.com/jonschlinkert/omit-value "Omit properties from an object or deeply nested property of an object using object path notation.") 83* [put-value](https://www.npmjs.com/package/put-value): Update only existing values from an object, works with dot notation paths like `a.b.c` and… [more](https://github.com/tunnckocore/put-value#readme) | [homepage](https://github.com/tunnckocore/put-value#readme "Update only existing values from an object, works with dot notation paths like `a.b.c` and support deep nesting.") 84* [set-value](https://www.npmjs.com/package/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/jonschlinkert/set-value "Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.") 85* [union-value](https://www.npmjs.com/package/union-value): Set an array of unique values as the property of an object. Supports setting deeply… [more](https://github.com/jonschlinkert/union-value) | [homepage](https://github.com/jonschlinkert/union-value "Set an array of unique values as the property of an object. Supports setting deeply nested properties using using object-paths/dot notation.") 86* [upsert-value](https://www.npmjs.com/package/upsert-value): Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/doowb/upsert-value "Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths.") 87 88### Contributing 89 90Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). 91 92### Contributors 93 94| **Commits** | **Contributor** | 95| --- | --- | 96| 6 | [jonschlinkert](https://github.com/jonschlinkert) | 97| 2 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) | 98 99### Building docs 100 101_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ 102 103To generate the readme, run the following command: 104 105```sh 106$ npm install -g verbose/verb#dev verb-generate-readme && verb 107``` 108 109### Running tests 110 111Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: 112 113```sh 114$ npm install && npm test 115``` 116 117### Author 118 119**Jon Schlinkert** 120 121* [github/jonschlinkert](https://github.com/jonschlinkert) 122* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) 123 124### License 125 126Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). 127Released under the [MIT License](LICENSE). 128 129*** 130 131_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 25, 2017._