项目作者: jonschlinkert

项目描述 :
Call the given method on each value in the given object.
高级语言: JavaScript
项目地址: git://github.com/jonschlinkert/object-visit.git
创建时间: 2015-07-04T19:57:38Z
项目社区:https://github.com/jonschlinkert/object-visit

开源协议:MIT License

下载


object-visit NPM version NPM monthly downloads NPM total downloads Linux Build Status

Call a specified method on each value in the given object.

Install

Install with npm:

  1. $ npm install --save object-visit

Usage

  1. var visit = require('object-visit');
  2. var ctx = {
  3. data: {},
  4. set: function (key, value) {
  5. if (typeof key === 'object') {
  6. visit(ctx, 'set', key);
  7. } else {
  8. ctx.data[key] = value;
  9. }
  10. }
  11. };
  12. ctx.set('a', 'a');
  13. ctx.set('b', 'b');
  14. ctx.set('c', 'c');
  15. ctx.set({d: {e: 'f'}});
  16. console.log(ctx.data);
  17. //=> {a: 'a', b: 'b', c: 'c', d: { e: 'f' }};

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This project’s readme.md is generated by verb, please don’t edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

  1. $ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

  1. $ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert.
Released under the MIT License.


This file was generated by verb-generate-readme, v0.5.0, on April 09, 2017.