Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rocktimsaikia/flatify-obj
Flatten nested javascript objects into a single-depth object.
https://github.com/rocktimsaikia/flatify-obj
flat-objects flattened-objects npm-package objects
Last synced: about 2 months ago
JSON representation
Flatten nested javascript objects into a single-depth object.
- Host: GitHub
- URL: https://github.com/rocktimsaikia/flatify-obj
- Owner: rocktimsaikia
- License: mit
- Created: 2020-10-05T11:00:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-17T13:50:44.000Z (about 4 years ago)
- Last Synced: 2024-10-14T13:05:42.549Z (3 months ago)
- Topics: flat-objects, flattened-objects, npm-package, objects
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# flatify-obj ![build](https://travis-ci.com/RocktimSaikia/flatify-obj.svg?branch=master)
> Flatten nested javascript objects into a single-depth object.## Install
```bash
$ npm install flatify-obj
```## Usage
```js
const flatifyObject = require('flatify-obj');flatifyObject({foo: {bar: {unicorn: '🦄'}}})
//=> { 'foo.bar.unicorn': '🦄' }flatifyObject({foo: {unicorn: '🦄'}, bar: 'unicorn'}, {onlyLeaves: true});
//=> {unicorn: '🦄', bar: 'unicorn'}
```## API
### flatifyObject(object, options?)
#### object
Type: `object`
Object to flatten#### options
##### onlyLeaves
Type: `boolean`
Default: `false`Removes the parent property and only returns the leaf nodes of the object
## License
MIT © [Rocktim Saikia](https://rocktim.xyz/)