time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

_baseUnset.js (580B)


      1 var castPath = require('./_castPath'),
      2     last = require('./last'),
      3     parent = require('./_parent'),
      4     toKey = require('./_toKey');
      5 
      6 /**
      7  * The base implementation of `_.unset`.
      8  *
      9  * @private
     10  * @param {Object} object The object to modify.
     11  * @param {Array|string} path The property path to unset.
     12  * @returns {boolean} Returns `true` if the property is deleted, else `false`.
     13  */
     14 function baseUnset(object, path) {
     15   path = castPath(path, object);
     16   object = parent(object, path);
     17   return object == null || delete object[toKey(last(path))];
     18 }
     19 
     20 module.exports = baseUnset;