UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

36 lines (35 loc) 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const baseSet_1 = __importDefault(require("./.internal/baseSet")); /** * This method is like `set` except that it accepts `customizer` which is * invoked to produce the objects of `path`. If `customizer` returns `undefined` * path creation is handled by the method instead. The `customizer` is invoked * with three arguments: (nsValue, key, nsObject). * * **Note:** This method mutates `object`. * * @since 5.3.0 * @category Object * @param object The object to modify. * @param ath The path of the property to set. * @param value The value to set. * @param customizer The function to customize assigned values. * @returns Returns `object`. * @example * * ```js * const object = {} * * setWith(object, '[0][1]', 'a', Object) * // => { '0': { '1': 'a' } } * ``` */ function setWith(object, path, value, customizer) { customizer = typeof customizer === "function" ? customizer : undefined; return object == null ? object : (0, baseSet_1.default)(object, path, value, customizer); } exports.default = setWith;