UNPKG

vue-app-sdk

Version:
32 lines (31 loc) 1.16 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const _assignValue = require("./_assignValue.cjs"); const _castPath = require("./_castPath.cjs"); const _isIndex = require("./_isIndex.cjs"); const isObject = require("./isObject.cjs"); const _toKey = require("./_toKey.cjs"); function baseSet(object, path, value, customizer) { if (!isObject.default(object)) { return object; } path = _castPath.default(path, object); var index = -1, length = path.length, lastIndex = length - 1, nested = object; while (nested != null && ++index < length) { var key = _toKey.default(path[index]), newValue = value; if (key === "__proto__" || key === "constructor" || key === "prototype") { return object; } if (index != lastIndex) { var objValue = nested[key]; newValue = void 0; if (newValue === void 0) { newValue = isObject.default(objValue) ? objValue : _isIndex.default(path[index + 1]) ? [] : {}; } } _assignValue.default(nested, key, newValue); nested = nested[key]; } return object; } exports.default = baseSet;