Skip to content

Commit e75ce8f

Browse files
committed
refactor
1 parent 7e848ad commit e75ce8f

File tree

6 files changed

+335
-202
lines changed

6 files changed

+335
-202
lines changed

.verb.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1+
## Heads up!
2+
3+
Breaking changes in v1.0.0! See the [Release History](#CHANGELOG.md).
4+
15
## Usage
26

37
```js
4-
var omitEmpty = require('{%= name %}');
8+
const omitEmpty = require('{%= name %}');
59

6-
omitEmpty({a: 'a', b: ''});
7-
//=> {a: 'a'}
10+
console.log(omitEmpty({ a: 'a', b: '' }));
11+
//=> { a: 'a' }
812

9-
omitEmpty({a: 'a', b: {c: 'c', d: ''}});
10-
//=> {a: 'a', b: {c: 'c'}
13+
console.log(omitEmpty({ a: 'a', b: { c: 'c', d: '' } }));
14+
//=> { a: 'a', b: { c: 'c' } }
1115

12-
omitEmpty({a: ['a'], b: []});
13-
//=> {a: ['a']}
16+
console.log(omitEmpty({ a: ['a'], b: [] }));
17+
//=> { a: ['a'] }
1418

15-
omitEmpty({a: 0, b: 1});
16-
//=> {a: 0, b: 1}
19+
console.log(omitEmpty({ a: 0, b: 1 }));
20+
//=> { a: 0, b: 1 }
1721

18-
// set the `noZero` flag
19-
omitEmpty({a: 0, b: 1}, true);
20-
//=> {b: 1}
22+
// set omitZero to true, to evaluate "0" as falsey
23+
console.log(omitEmpty({ a: 0, b: 1 }, { omitZero: true }));
24+
//=> { b: 1 }
2125
```

CHANGELOG.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Release history
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
<details>
9+
<summary><strong>Guiding Principles</strong></summary>
10+
11+
- Changelogs are for humans, not machines.
12+
- There should be an entry for every single version.
13+
- The same types of changes should be grouped.
14+
- Versions and sections should be linkable.
15+
- The latest version comes first.
16+
- The release date of each versions is displayed.
17+
- Mention whether you follow Semantic Versioning.
18+
19+
</details>
20+
21+
<details>
22+
<summary><strong>Types of changes</strong></summary>
23+
24+
Changelog entries are classified using the following labels _(from [keep-a-changelog](http://keepachangelog.com/)_):
25+
26+
- `Added` for new features.
27+
- `Changed` for changes in existing functionality.
28+
- `Deprecated` for soon-to-be removed features.
29+
- `Removed` for now removed features.
30+
- `Fixed` for any bug fixes.
31+
- `Security` in case of vulnerabilities.
32+
33+
</details>
34+
35+
## [1.0.0] - 2018-12-10
36+
37+
**Changed**
38+
39+
- refactored completely
40+
- support was removed for `exclude` and `excludeType`
41+
- `options.noZero` was renamed to `options.omitZero`
42+
43+
## [0.4.1] - 2016-06-01
44+
45+
- adds support for excluding types or keys
46+
47+
## [0.4.0] - 2016-06-01
48+
49+
- Changes for removing empty properties inside an array.
50+
- Merge pull request #4 from kakadiadarpan/master
51+
- closes https://github.com/jonschlinkert/omit-empty/issues/3
52+
53+
## [0.3.6] - 2016-04-09
54+
55+
- make array value handling stricter
56+
57+
## [0.3.5] - 2016-04-09
58+
59+
- ensure empty arrays are omitted
60+
61+
## [0.3.4] - 2016-03-27
62+
63+
- ensure zero-length function values aren't omitted
64+
65+
## [0.3.3] - 2016-03-19
66+
67+
- bugfix: do not omit Date objects.
68+
- Merge pull request #2 from stnever/do-not-omit-dates
69+
70+
## [0.3.2] - 2015-12-24
71+
72+
- update deps
73+
74+
## [0.3.1] - 2015-03-24
75+
76+
- first commit
77+
78+
[Unreleased]: https://github.com/jonschlinkert/omit-empty/compare/0.4.1...1.0.0
79+
[0.4.1]: https://github.com/jonschlinkert/omit-empty/compare/0.4.0...0.4.1
80+
[0.4.0]: https://github.com/jonschlinkert/omit-empty/compare/0.3.6...0.4.0
81+
[0.3.6]: https://github.com/jonschlinkert/omit-empty/compare/0.3.5...0.3.6
82+
[0.3.5]: https://github.com/jonschlinkert/omit-empty/compare/0.3.4...0.3.5
83+
[0.3.4]: https://github.com/jonschlinkert/omit-empty/compare/0.3.3...0.3.4
84+
[0.3.3]: https://github.com/jonschlinkert/omit-empty/compare/0.3.2...0.3.3
85+
[0.3.2]: https://github.com/jonschlinkert/omit-empty/compare/0.3.1...0.3.2
86+
87+
[Unreleased]: https://github.com/jonschlinkert/omit-empty/compare/0.3.1...HEAD
88+
[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
89+

README.md

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,104 @@
1-
# omit-empty [![NPM version](https://img.shields.io/npm/v/omit-empty.svg?style=flat)](https://www.npmjs.com/package/omit-empty) [![NPM downloads](https://img.shields.io/npm/dm/omit-empty.svg?style=flat)](https://npmjs.org/package/omit-empty) [![Build Status](https://img.shields.io/travis/jonschlinkert/omit-empty.svg?style=flat)](https://travis-ci.org/jonschlinkert/omit-empty)
1+
# omit-empty [![NPM version](https://img.shields.io/npm/v/omit-empty.svg?style=flat)](https://www.npmjs.com/package/omit-empty) [![NPM monthly downloads](https://img.shields.io/npm/dm/omit-empty.svg?style=flat)](https://npmjs.org/package/omit-empty) [![NPM total downloads](https://img.shields.io/npm/dt/omit-empty.svg?style=flat)](https://npmjs.org/package/omit-empty) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/omit-empty.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/omit-empty)
22

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.
46

57
## Install
68

79
Install with [npm](https://www.npmjs.com/):
810

911
```sh
10-
$ npm install omit-empty --save
12+
$ npm install --save omit-empty
1113
```
1214

15+
## Heads up!
16+
17+
Breaking changes in v1.0.0! See the [Release History](#CHANGELOG.md).
18+
1319
## Usage
1420

1521
```js
16-
var omitEmpty = require('omit-empty');
22+
const omitEmpty = require('omit-empty');
1723

18-
omitEmpty({a: 'a', b: ''});
19-
//=> {a: 'a'}
24+
console.log(omitEmpty({ a: 'a', b: '' }));
25+
//=> { a: 'a' }
2026

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' } }
2329

24-
omitEmpty({a: ['a'], b: []});
25-
//=> {a: ['a']}
30+
console.log(omitEmpty({ a: ['a'], b: [] }));
31+
//=> { a: ['a'] }
2632

27-
omitEmpty({a: 0, b: 1});
28-
//=> {a: 0, b: 1}
33+
console.log(omitEmpty({ a: 0, b: 1 }));
34+
//=> { a: 0, b: 1 }
2935

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 }
3339
```
3440

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
4342

44-
## Contributing
43+
<details>
44+
<summary><strong>Contributing</strong></summary>
4545

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).
4747

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>
4949

50-
## Building docs
50+
<details>
51+
<summary><strong>Running Tests</strong></summary>
5152

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:
5354

5455
```sh
55-
$ npm install -g verb verb-readme-generator && verb
56+
$ npm install && npm test
5657
```
5758

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.)_
5965

60-
Install dev dependencies:
66+
To generate the readme, run the following command:
6167

6268
```sh
63-
$ npm install -d && npm test
69+
$ npm install -g verbose/verb#dev verb-generate-readme && verb
6470
```
6571

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
6790

6891
**Jon Schlinkert**
6992

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)
7296

73-
## License
97+
### License
7498

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).
77101

78102
***
79103

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

Comments
 (0)