X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Fgrunt-legacy-util%2Fnode_modules%2Flodash%2FwrapperAt.js;fp=node_modules%2Fgrunt-legacy-util%2Fnode_modules%2Flodash%2FwrapperAt.js;h=ce06e72b983c8300632c2f92cec7ae84c84e10d5;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/grunt-legacy-util/node_modules/lodash/wrapperAt.js b/node_modules/grunt-legacy-util/node_modules/lodash/wrapperAt.js new file mode 100644 index 000000000..ce06e72b9 --- /dev/null +++ b/node_modules/grunt-legacy-util/node_modules/lodash/wrapperAt.js @@ -0,0 +1,48 @@ +var LazyWrapper = require('./_LazyWrapper'), + LodashWrapper = require('./_LodashWrapper'), + baseAt = require('./_baseAt'), + baseFlatten = require('./_baseFlatten'), + isIndex = require('./_isIndex'), + rest = require('./rest'), + thru = require('./thru'); + +/** + * This method is the wrapper version of `_.at`. + * + * @name at + * @memberOf _ + * @category Seq + * @param {...(string|string[])} [paths] The property paths of elements to pick, + * specified individually or in arrays. + * @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] + * + * _(['a', 'b', 'c']).at(0, 2).value(); + * // => ['a', 'c'] + */ +var wrapperAt = rest(function(paths) { + paths = baseFlatten(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;