.. | ||
node_modules/isobject | ||
index.js | ||
LICENSE | ||
package.json | ||
README.md |
object-visit
Call a specified method on each value in the given object.
Install
Install with npm
$ npm i object-visit --save
Usage
var visit = require('object-visit');
var ctx = {
data: {},
set: function (key, value) {
if (typeof key === 'object') {
visit(ctx, 'set', key);
} else {
ctx.data[key] = value;
}
}
};
ctx.set('a', 'a');
ctx.set('b', 'b');
ctx.set('c', 'c');
ctx.set({d: {e: 'f'}});
console.log(ctx.data);
//=> {a: 'a', b: 'b', c: 'c', d: { e: 'f' }};
Related projects
- base-methods: Starter for creating a node.js application with a handful of common methods, like
set
,get
,… more | homepage - collection-visit: Visit a method over the items in an object, or map visit over the objects… more | homepage
- define-property: Define a non-enumerable property on an object. | homepage
- map-visit: Map
visit
over an array of objects. | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on November 09, 2015.