CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
_baseUnset.js53 linesDownload Raw Back to lodash-es
1import castPath from './_castPath.js';2import last from './last.js';3import parent from './_parent.js';4import toKey from './_toKey.js';5 6/** Used for built-in method references. */7var objectProto = Object.prototype;8 9/** Used to check objects for own properties. */10var hasOwnProperty = objectProto.hasOwnProperty;11 12/**13 * The base implementation of `_.unset`.14 *15 * @private16 * @param {Object} object The object to modify.17 * @param {Array|string} path The property path to unset.18 * @returns {boolean} Returns `true` if the property is deleted, else `false`.19 */20function baseUnset(object, path) {21  path = castPath(path, object);22 23  // Prevent prototype pollution:24  // https://github.com/lodash/lodash/security/advisories/GHSA-xxjr-mmjv-4gpg25  // https://github.com/lodash/lodash/security/advisories/GHSA-f23m-r3pf-42rh26  var index = -1,27      length = path.length;28 29  if (!length) {30    return true;31  }32 33  while (++index < length) {34    var key = toKey(path[index]);35 36    // Always block "__proto__" anywhere in the path if it's not expected37    if (key === '__proto__' && !hasOwnProperty.call(object, '__proto__')) {38      return false;39    }40 41    // Block constructor/prototype as non-terminal traversal keys to prevent42    // escaping the object graph into built-in constructors and prototypes.43    if ((key === 'constructor' || key === 'prototype') && index < length - 1) {44      return false;45    }46  }47 48  var obj = parent(object, path);49  return obj == null || delete obj[toKey(last(path))];50}51 52export default baseUnset;53 
basant307/AI_Governance_Project · CoolFace