UNPKG

tdesign-react

Version:
78 lines (66 loc) 2.32 kB
/** * tdesign v1.16.2 * (c) 2025 tdesign * @license MIT */ 'use strict'; var _typeof = require('./dep-b325182b.js'); var _baseGet = require('./dep-5dd1b13c.js'); var last = require('./dep-002bcd4b.js'); var _baseSlice = require('./dep-2ad01263.js'); /** * Gets the parent value at `path` of `object`. * * @private * @param {Object} object The object to query. * @param {Array} path The path to get the parent value of. * @returns {*} Returns the parent value. */ function parent(object, path) { return path.length < 2 ? object : _baseGet.baseGet(object, _baseSlice.baseSlice(path, 0, -1)); } /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.unset`. * * @private * @param {Object} object The object to modify. * @param {Array|string} path The property path to unset. * @returns {boolean} Returns `true` if the property is deleted, else `false`. */ function baseUnset(object, path) { path = _baseGet.castPath(path, object); // Prevent prototype pollution, see: https://github.com/lodash/lodash/security/advisories/GHSA-xxjr-mmjv-4gpg var index = -1, length = path.length; if (!length) { return true; } var isRootPrimitive = object == null || _typeof._typeof(object) !== 'object' && typeof object !== 'function'; while (++index < length) { var key = path[index]; // skip non-string keys (e.g., Symbols, numbers) if (typeof key !== 'string') { continue; } // Always block "__proto__" anywhere in the path if it's not expected if (key === '__proto__' && !hasOwnProperty.call(object, '__proto__')) { return false; } // Block "constructor.prototype" chains if (key === 'constructor' && index + 1 < length && typeof path[index + 1] === 'string' && path[index + 1] === 'prototype') { // Allow ONLY when the path starts at a primitive root, e.g., _.unset(0, 'constructor.prototype.a') if (isRootPrimitive && index === 0) { continue; } return false; } } var obj = parent(object, path); return obj == null || delete obj[_baseGet.toKey(last.last(path))]; } exports.baseUnset = baseUnset; //# sourceMappingURL=dep-f0b4efe7.js.map