-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import ChainWrapper from './ChainWrapper' | ||
|
||
/** | ||
* Creates an immutadot wrapper instance that wraps value allowing to make sequences of immutadot functions calls on it.<br/> | ||
* The result of such sequences must be unwrapped with {@link seq#value|value}. | ||
* Creates an immutadot wrapper instance that wraps <code>object</code> allowing to make sequences of immutadot functions calls on it.<br/> | ||
* The result of such sequences must be unwrapped with {@link seq#value|value}.<br/> | ||
* The object on which the functions are called may be changed with an optional <code>path</code>. | ||
* @function chain | ||
* @memberof seq | ||
* @param {*} value The value to wrap. | ||
* @param {Object} object The object to wrap. | ||
* @param {Array|string} [path] The path of the object on which functions are called. | ||
* @return {Object} Returns the new immutadot wrapper instance. | ||
* @example | ||
* @example <caption>Chain several operations</caption> | ||
* chain({ nested1: { prop: 'old' }, nested2: { prop: 1 } }) | ||
* .set('nested1.prop', 'new') | ||
* .unset('nested2.prop') | ||
* .value() // => { nested1: { prop: 'new' }, nested2: {} } | ||
* @example <caption>Chain on a path</caption> | ||
* chain({ nested: { prop1: 'old', prop2: 1 } }, 'nested') | ||
* .set('prop1', 'new') | ||
* .unset('prop2') | ||
* .value() // => { nested: { prop1: 'new' } } | ||
* @see {@link seq#value|value} for more information. | ||
* @since 0.1.8 | ||
*/ | ||
export default value => new ChainWrapper(value) | ||
export default (object, path) => new ChainWrapper(object, path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters