Skip to content

Commit

Permalink
docs(keysRecorder): jsdoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yidinghan committed Apr 10, 2017
1 parent a40ccbb commit dbdf5f5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,49 @@ const set = require('lodash.set');
const unset = require('lodash.unset');
const pick = require('lodash.pick');

/**
* keysRecorder
* use ldoash pick, get and set to collect data from given target object
*
* @param {object} payload - input arguments
* @param {string[]} [payload.defaults] - default keys will be collected
* @param {string[]} [payload.whitelist] - keys will be collected as
* additional part
* @param {string[]} [payload.blacklist] - keys that will be ignored at last
* @return {function} closure function, setting by given payload
* @example
* // without payload
* const recorder = keysRecorder();
* recorder() // {}
* recorder({ foo: 1, bar: 2, foobar: { a: 3, b: 4 } }) // {}
*
* // with defaults
* const recorder = keysRecorder({ defaults: ['foo'] });
* recorder() // {}
* recorder({ foo: 1, bar: 2, foobar: { a: 3, b: 4 } }) // { foo: 1 }
*
* // with defaults and whitelist
* const recorder = keysRecorder({ defaults: ['foo'], whitelist: ['foobar'] });
* recorder() // {}
* recorder({
* foo: 1,
* bar: 2,
* foobar: { a: 3, b: 4 }
* }) // { foo: 1, foobar: { a: 3, b: 4 } }
*
* // with defaults and whitelist and blacklist
* const recorder = keysRecorder({
* defaults: ['foo'],
* whitelist: ['foobar'],
* blacklist: ['foobar.b'],
* });
* recorder() // {}
* recorder({
* foo: 1,
* bar: 2,
* foobar: { a: 3, b: 4 }
* }) // { foo: 1, foobar: { a: 3 } }
*/
exports.keysRecorder = (payload = {}) => {
const {
defaults = [],
Expand Down

0 comments on commit dbdf5f5

Please sign in to comment.