Sha256: e2bfb9a9b4a1dd501a8028c7abae2b38cc0eb2eb871641449f1d2e9fa25256eb

Contents?: true

Size: 1.31 KB

Versions: 270

Compression:

Stored size: 1.31 KB

Contents

var LazyWrapper = require('./_LazyWrapper'),
    LodashWrapper = require('./_LodashWrapper'),
    baseAt = require('./_baseAt'),
    flatRest = require('./_flatRest'),
    isIndex = require('./_isIndex'),
    thru = require('./thru');

/**
 * This method is the wrapper version of `_.at`.
 *
 * @name at
 * @memberOf _
 * @since 1.0.0
 * @category Seq
 * @param {...(string|string[])} [paths] The property paths to pick.
 * @returns {Object} Returns the new `lodash` wrapper instance.
 * @example
 *
 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
 *
 * _(object).at(['a[0].b.c', 'a[1]']).value();
 * // => [3, 4]
 */
var wrapperAt = flatRest(function(paths) {
  var length = paths.length,
      start = length ? paths[0] : 0,
      value = this.__wrapped__,
      interceptor = function(object) { return baseAt(object, paths); };

  if (length > 1 || this.__actions__.length ||
      !(value instanceof LazyWrapper) || !isIndex(start)) {
    return this.thru(interceptor);
  }
  value = value.slice(start, +start + (length ? 1 : 0));
  value.__actions__.push({
    'func': thru,
    'args': [interceptor],
    'thisArg': undefined
  });
  return new LodashWrapper(value, this.__chain__).thru(function(array) {
    if (length && !array.length) {
      array.push(undefined);
    }
    return array;
  });
});

module.exports = wrapperAt;

Version data entries

270 entries across 269 versions & 28 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.59 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.58 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.57 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.56 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.55 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.54 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.53 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.52 node_modules/lodash/wrapperAt.js
trusty-cms-6.3.1 node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.51 node_modules/lodash/wrapperAt.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/wrapperAt.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js
immosquare-cleaner-0.1.50 node_modules/lodash/wrapperAt.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/wrapperAt.js