|
1 |
| -# omit-empty [](https://www.npmjs.com/package/omit-empty) [](https://npmjs.org/package/omit-empty) [](https://travis-ci.org/jonschlinkert/omit-empty) |
| 1 | +# omit-empty [](https://www.npmjs.com/package/omit-empty) [](https://npmjs.org/package/omit-empty) [](https://npmjs.org/package/omit-empty) [](https://travis-ci.org/jonschlinkert/omit-empty) |
2 | 2 |
|
3 |
| -Recursively omit empty properties from an object. Omits empty objects, arrays, strings or zero. |
| 3 | +> Recursively omit empty properties from an object. Omits empty objects, arrays, strings or zero. |
| 4 | +
|
| 5 | +Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. |
4 | 6 |
|
5 | 7 | ## Install
|
6 | 8 |
|
7 | 9 | Install with [npm](https://www.npmjs.com/):
|
8 | 10 |
|
9 | 11 | ```sh
|
10 |
| -$ npm install omit-empty --save |
| 12 | +$ npm install --save omit-empty |
11 | 13 | ```
|
12 | 14 |
|
| 15 | +## Heads up! |
| 16 | + |
| 17 | +Breaking changes in v1.0.0! See the [Release History](#CHANGELOG.md). |
| 18 | + |
13 | 19 | ## Usage
|
14 | 20 |
|
15 | 21 | ```js
|
16 |
| -var omitEmpty = require('omit-empty'); |
| 22 | +const omitEmpty = require('omit-empty'); |
17 | 23 |
|
18 |
| -omitEmpty({a: 'a', b: ''}); |
19 |
| -//=> {a: 'a'} |
| 24 | +console.log(omitEmpty({ a: 'a', b: '' })); |
| 25 | +//=> { a: 'a' } |
20 | 26 |
|
21 |
| -omitEmpty({a: 'a', b: {c: 'c', d: ''}}); |
22 |
| -//=> {a: 'a', b: {c: 'c'} |
| 27 | +console.log(omitEmpty({ a: 'a', b: { c: 'c', d: '' } })); |
| 28 | +//=> { a: 'a', b: { c: 'c' } } |
23 | 29 |
|
24 |
| -omitEmpty({a: ['a'], b: []}); |
25 |
| -//=> {a: ['a']} |
| 30 | +console.log(omitEmpty({ a: ['a'], b: [] })); |
| 31 | +//=> { a: ['a'] } |
26 | 32 |
|
27 |
| -omitEmpty({a: 0, b: 1}); |
28 |
| -//=> {a: 0, b: 1} |
| 33 | +console.log(omitEmpty({ a: 0, b: 1 })); |
| 34 | +//=> { a: 0, b: 1 } |
29 | 35 |
|
30 |
| -// set the `noZero` flag |
31 |
| -omitEmpty({a: 0, b: 1}, true); |
32 |
| -//=> {b: 1} |
| 36 | +// set omitZero to true, to evaluate "0" as falsey |
| 37 | +console.log(omitEmpty({ a: 0, b: 1 }, { omitZero: true })); |
| 38 | +//=> { b: 1 } |
33 | 39 | ```
|
34 | 40 |
|
35 |
| -## Related projects |
36 |
| - |
37 |
| -You might also be interested in these projects: |
38 |
| - |
39 |
| -* [for-in](https://www.npmjs.com/package/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://www.npmjs.com/package/for-in) | [homepage](https://github.com/jonschlinkert/for-in) |
40 |
| -* [for-own](https://www.npmjs.com/package/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://www.npmjs.com/package/for-own) | [homepage](https://github.com/jonschlinkert/for-own) |
41 |
| -* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object) |
42 |
| -* [reduce-object](https://www.npmjs.com/package/reduce-object): Reduces an object to a value that is the accumulated result of running each property… [more](https://www.npmjs.com/package/reduce-object) | [homepage](https://github.com/jonschlinkert/reduce-object) |
| 41 | +## About |
43 | 42 |
|
44 |
| -## Contributing |
| 43 | +<details> |
| 44 | +<summary><strong>Contributing</strong></summary> |
45 | 45 |
|
46 |
| -This document was generated by [verb](https://github.com/verbose/verb), please don't edit directly. Any changes to the readme must be made in [.verb.md](.verb.md). See [Building Docs](#building-docs). |
| 46 | +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). |
47 | 47 |
|
48 |
| -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/omit-empty/issues/new). |
| 48 | +</details> |
49 | 49 |
|
50 |
| -## Building docs |
| 50 | +<details> |
| 51 | +<summary><strong>Running Tests</strong></summary> |
51 | 52 |
|
52 |
| -Generate readme and API documentation with [verb](https://github.com/verbose/verb): |
| 53 | +Running 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: |
53 | 54 |
|
54 | 55 | ```sh
|
55 |
| -$ npm install -g verb verb-readme-generator && verb |
| 56 | +$ npm install && npm test |
56 | 57 | ```
|
57 | 58 |
|
58 |
| -## Running tests |
| 59 | +</details> |
| 60 | + |
| 61 | +<details> |
| 62 | +<summary><strong>Building docs</strong></summary> |
| 63 | + |
| 64 | +_(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.)_ |
59 | 65 |
|
60 |
| -Install dev dependencies: |
| 66 | +To generate the readme, run the following command: |
61 | 67 |
|
62 | 68 | ```sh
|
63 |
| -$ npm install -d && npm test |
| 69 | +$ npm install -g verbose/verb#dev verb-generate-readme && verb |
64 | 70 | ```
|
65 | 71 |
|
66 |
| -## Author |
| 72 | +</details> |
| 73 | + |
| 74 | +### Related projects |
| 75 | + |
| 76 | +You might also be interested in these projects: |
| 77 | + |
| 78 | +* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.") |
| 79 | +* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.") |
| 80 | +* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.") |
| 81 | + |
| 82 | +### Contributors |
| 83 | + |
| 84 | +| **Commits** | **Contributor** | |
| 85 | +| --- | --- | |
| 86 | +| 31 | [jonschlinkert](https://github.com/jonschlinkert) | |
| 87 | +| 1 | [kakadiadarpan](https://github.com/kakadiadarpan) | |
| 88 | + |
| 89 | +### Author |
67 | 90 |
|
68 | 91 | **Jon Schlinkert**
|
69 | 92 |
|
70 |
| -* [github/jonschlinkert](https://github.com/jonschlinkert) |
71 |
| -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) |
| 93 | +* [GitHub Profile](https://github.com/jonschlinkert) |
| 94 | +* [Twitter Profile](https://twitter.com/jonschlinkert) |
| 95 | +* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) |
72 | 96 |
|
73 |
| -## License |
| 97 | +### License |
74 | 98 |
|
75 |
| -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). |
76 |
| -Released under the [MIT license](https://github.com/jonschlinkert/omit-empty/blob/master/LICENSE). |
| 99 | +Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). |
| 100 | +Released under the [MIT License](LICENSE). |
77 | 101 |
|
78 | 102 | ***
|
79 | 103 |
|
80 |
| -_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on June 01, 2016._ |
| 104 | +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on December 10, 2018._ |
0 commit comments