mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Add a doc on path creation for _.set. [ci skip]
This commit is contained in:
14
lodash.js
14
lodash.js
@@ -11336,8 +11336,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value at `path` of `object`. If a portion of `path` doesn't
|
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist
|
||||||
* exist it's created.
|
* it's created. Arrays are created for missing index properties while objects
|
||||||
|
* are created for all other missing properties. Use `_.setWith` to customize
|
||||||
|
* `path` creation.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -11378,13 +11380,7 @@
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function customizer(nsValue) {
|
* _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, Object);
|
||||||
* if (!_.isObject(nsValue)) {
|
|
||||||
* return {};
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* _.setWith({ '0': { 'length': 2 } }, '[0][1][2]', 3, customizer);
|
|
||||||
* // => { '0': { '1': { '2': 3 }, 'length': 2 } }
|
* // => { '0': { '1': { '2': 3 }, 'length': 2 } }
|
||||||
*/
|
*/
|
||||||
function setWith(object, path, value, customizer) {
|
function setWith(object, path, value, customizer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user