CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
wrapperAt.js49 linesDownload Raw Back to lodash
1var LazyWrapper = require('./_LazyWrapper'),2    LodashWrapper = require('./_LodashWrapper'),3    baseAt = require('./_baseAt'),4    flatRest = require('./_flatRest'),5    isIndex = require('./_isIndex'),6    thru = require('./thru');7 8/**9 * This method is the wrapper version of `_.at`.10 *11 * @name at12 * @memberOf _13 * @since 1.0.014 * @category Seq15 * @param {...(string|string[])} [paths] The property paths to pick.16 * @returns {Object} Returns the new `lodash` wrapper instance.17 * @example18 *19 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };20 *21 * _(object).at(['a[0].b.c', 'a[1]']).value();22 * // => [3, 4]23 */24var wrapperAt = flatRest(function(paths) {25  var length = paths.length,26      start = length ? paths[0] : 0,27      value = this.__wrapped__,28      interceptor = function(object) { return baseAt(object, paths); };29 30  if (length > 1 || this.__actions__.length ||31      !(value instanceof LazyWrapper) || !isIndex(start)) {32    return this.thru(interceptor);33  }34  value = value.slice(start, +start + (length ? 1 : 0));35  value.__actions__.push({36    'func': thru,37    'args': [interceptor],38    'thisArg': undefined39  });40  return new LodashWrapper(value, this.__chain__).thru(function(array) {41    if (length && !array.length) {42      array.push(undefined);43    }44    return array;45  });46});47 48module.exports = wrapperAt;49 
basant307/AI_Governance_Project · CoolFace