homefront
Merge, flatten, expand, search in, fetch from, remove from, put in and work with objects easily.
Makes working with javascript objects really easy, in both the browser and on the server.
Installation
npm i --save homefront
Tests
npm test
Usage
Usage is pretty straight forward.
Homefront class
Working with homefront
let Homefront = Homefront;let homefront = data HomefrontMODE_NESTED; // Put a value.homefront; // Fetch a value.homefront; // Remove a value.homefront; // Use dot-notation for nested objects.homefront;homefront;homefront;homefront; // Merge new data into your objecthomefront; // And the same again, but with nested keys!homefront; // And, sorry, the same again, but static.Homefront; // And sort of the same, apply defaults.homefront; // Flatten object (nested objects to dot-notation keys):homefront; // Expand object (dot-notation keys to nested objects):homefront; // Helpershomefront;homefront;homefront;homefront; // ConstantsHomefrontMODE_FLAT;HomefrontMODE_NESTED;
Expand
let expand = expand;let data = 'my.nested.key': 'value' 'my.nested.other': 'value';let expanded = ; // => {my: {nested: {key: 'value', other: 'value'}}}
Flatten
Returns a flattened object, with all nested keys dot separated.
let flatten = flatten;let data = foo:bar:bat:'baz';let flattened = ; // => {'foo.bar.bat': 'baz'}
Building the code
For this code to work in the browser, there's an extra transpile step included. Running this is as easy as executing the following command:
npm run build
The built code will appear in the dist directory.
Breaking changes
Since the last major version bump, method .defaults()
has been renamed to .applyDefaults()
as defaults cause exceptions on some browser. It shadows the name of a strict-mode function.