diff --git a/README.md b/README.md index e7b22b422..25ff3c9f0 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,6 @@ require({ * `_.defer` * `_.difference` * `_.each` - * `_.escape` * `_.every`, `_.all` * `_.extend` * `_.filter`, `_.select` @@ -220,6 +219,7 @@ require({ * `_.groupBy` * `_.indexOf` * `_.intersection` + * `_.invert` * `_.invoke` * `_.isArguments` * `_.isDate` @@ -238,6 +238,7 @@ require({ * `_.min` * `_.mixin` * `_.omit` + * `_.pairs` * `_.pick` * `_.pluck` * `_.reduce`, `_.foldl`, `_.inject` diff --git a/build.js b/build.js index 3cb05b00f..d6f58f68a 100755 --- a/build.js +++ b/build.js @@ -595,7 +595,7 @@ .replace(/(?: *\/\/.*\n)*\s*'( *)<% *if *\(isKeysFast[\s\S]+?'\1<% *} *else *\{ *%>.+\n([\s\S]+?) *'\1<% *} *%>.+/, '$2') // remove `isKeysFast` from `beforeLoop.object` of `mapIteratorOptions` .replace(/=\s*'\s*\+\s*\(isKeysFast.+/, "= []'") - // remove `isKeysFast` from `inLoop.object` of `mapIteratorOptions`, `invoke`, `pluck`, and `sortBy` + // remove `isKeysFast` from `inLoop.object` of `mapIteratorOptions`, `invoke`, `pairs`, `pluck`, and `sortBy` .replace(/'\s*\+\s*\(isKeysFast[^)]+?\)\s*\+\s*'/g, '.push') // remove data object property assignment in `createIterator` .replace(/\s*.+?\.isKeysFast *=.+/, ''); diff --git a/lodash.js b/lodash.js index f1e85e765..c53cc90b7 100644 --- a/lodash.js +++ b/lodash.js @@ -1865,7 +1865,7 @@ * @static * @memberOf _ * @category Objects - * @param {Object} object The object to inspect.. + * @param {Object} object The object to inspect. * @returns {Array} Returns new array of key-value pairs. * @example * @@ -1875,7 +1875,7 @@ var pairs = createIterator({ 'args': 'object', 'init':'[]', - 'inLoop': 'result.push([index, value])' + 'inLoop': 'result' + (isKeysFast ? '[ownIndex] = ' : '.push') + '([index, value])' }); /** diff --git a/perf/perf.js b/perf/perf.js index 1e93d9035..38e547de0 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -864,6 +864,18 @@ /*--------------------------------------------------------------------------*/ + suites.push( + Benchmark.Suite('`_.invert`') + .add('Lo-Dash', '\ + lodash.invert(object)' + ) + .add('Underscore', '\ + _.invert(object)' + ) + ); + + /*--------------------------------------------------------------------------*/ + suites.push( Benchmark.Suite('`_.invoke` iterating an array') .add('Lo-Dash', '\ @@ -1104,6 +1116,18 @@ /*--------------------------------------------------------------------------*/ + suites.push( + Benchmark.Suite('`_.pairs`') + .add('Lo-Dash', '\ + lodash.pairs(object)' + ) + .add('Underscore', '\ + _.pairs(object)' + ) + ); + + /*--------------------------------------------------------------------------*/ + suites.push( Benchmark.Suite('`_.pick`') .add('Lo-Dash', '\