flatten-hash

Flatten nested objects to a single level in dot notation

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
flatten-hash
110.0.48 years ago8 years agoMinified + gzip package size for flatten-hash in KB

Readme

flatten-hash travis build status NPM version
Flatten nested objects to a single level in dot notation

Usage

Use dot notation to flatten nested objects.
var flattenHash = require('flatten-hash');
var nested = {foo: {bar: {baz: {bang: 'fez'} } }, a: 'b'};
console.log(var flat=flattenHash(nested));

flattens to:
{ 'foo.bar.baz.bang' : 'fez', a:'b'}

which you can then refer to as
console.log(flat['foo.bar.baz.bang']);

Limitations

Currently does not work with Arrays and RegExp objects; will throw an error.

See also

expand-hash - Expand hash keys into an object with the given values.
flat - Flatten/unflatten nested Javascript objects

Install

Install with npm:

npm i flatten-hash --save-dev

Contribute

All contributions are welcome! Stars and tweets are always a great way to show your support! But we can definitely use some help with:

Please read contributing guide for more info!
License
license
Copyright (c) 2014 Andreas Pizsa, contributors.
----- This file was generated by verb-cli on August 30, 2014.