Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mike1pol/omit-empty
Omit emptry arrays, objects and strings
https://github.com/mike1pol/omit-empty
js omit omit-js omitempty vanilla-javascript
Last synced: 20 days ago
JSON representation
Omit emptry arrays, objects and strings
- Host: GitHub
- URL: https://github.com/mike1pol/omit-empty
- Owner: mike1pol
- License: mit
- Created: 2017-10-19T13:25:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-22T18:52:39.000Z (about 7 years ago)
- Last Synced: 2024-12-05T06:34:45.165Z (about 1 month ago)
- Topics: js, omit, omit-js, omitempty, vanilla-javascript
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# omit-empty
[![NPM version](https://img.shields.io/npm/v/@mikepol/omit-empty.svg?style=flat)](https://www.npmjs.com/package/@mikepol/omit-empty) [![NPM downloads](https://img.shields.io/npm/dm/@mikepol/omit-empty.svg?style=flat)](https://npmjs.org/package/@mikepol/omit-empty) [![Build Status](https://img.shields.io/travis/mike1pol/omit-empty.svg?style=flat)](https://travis-ci.org/mike1pol/omit-empty)Recursively omit empty properties from an object. Omits empty objects, arrays, strings or zero.
## Install
```npm i -s @mikepol/omit-empty```## Usage
```
import omitEmpty from '@mikepol/omit-empty';omitEmpty({a: 'a', b: ''});
//=> {a: 'a'}omitEmpty({a: 'a', b: {c: 'c', d: ''}});
//=> {a: 'a', b: {c: 'c'}omitEmpty({a: ['a'], b: []});
//=> {a: ['a']}omitEmpty({a: 0, b: 1});
//=> {a: 0, b: 1}omitEmpty({a: null, b: ''});
//=> null
```## Tests
```npm install && npm test```