lodash.uniq
Advanced tools
Comparing version 2.4.1 to 3.0.0
127
index.js
/** | ||
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> | ||
* Build: `lodash modularize modern exports="npm" -o ./npm/` | ||
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <http://lodash.com/license> | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
var baseUniq = require('lodash._baseuniq'), | ||
createCallback = require('lodash.createcallback'); | ||
var baseCallback = require('lodash._basecallback'), | ||
baseUniq = require('lodash._baseuniq'), | ||
isIterateeCall = require('lodash._isiterateecall'); | ||
/** | ||
* Creates a duplicate-value-free version of an array using strict equality | ||
* for comparisons, i.e. `===`. If the array is sorted, providing | ||
* `true` for `isSorted` will use a faster algorithm. If a callback is provided | ||
* each element of `array` is passed through the callback before uniqueness | ||
* is computed. The callback is bound to `thisArg` and invoked with three | ||
* arguments; (value, index, array). | ||
* An implementation of `_.uniq` optimized for sorted arrays without support | ||
* for callback shorthands and `this` binding. | ||
* | ||
* If a property name is provided for `callback` the created "_.pluck" style | ||
* callback will return the property value of the given element. | ||
* @private | ||
* @param {Array} array The array to inspect. | ||
* @param {Function} [iteratee] The function invoked per iteration. | ||
* @returns {Array} Returns the new duplicate-value-free array. | ||
*/ | ||
function sortedUniq(array, iteratee) { | ||
var seen, | ||
index = -1, | ||
length = array.length, | ||
resIndex = -1, | ||
result = []; | ||
while (++index < length) { | ||
var value = array[index], | ||
computed = iteratee ? iteratee(value, index, array) : value; | ||
if (!index || seen !== computed) { | ||
seen = computed; | ||
result[++resIndex] = value; | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
* Creates a duplicate-value-free version of an array using `SameValueZero` | ||
* for equality comparisons. Providing `true` for `isSorted` performs a faster | ||
* search algorithm for sorted arrays. If an iteratee function is provided it | ||
* is invoked for each value in the array to generate the criterion by which | ||
* uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked | ||
* with three arguments; (value, index, array). | ||
* | ||
* If an object is provided for `callback` the created "_.where" style callback | ||
* will return `true` for elements that have the properties of the given object, | ||
* else `false`. | ||
* If a property name is provided for `predicate` the created "_.property" | ||
* style callback returns the property value of the given element. | ||
* | ||
* If an object is provided for `predicate` the created "_.matches" style | ||
* callback returns `true` for elements that have the properties of the given | ||
* object, else `false`. | ||
* | ||
* **Note:** `SameValueZero` comparisons are like strict equality comparisons, | ||
* e.g. `===`, except that `NaN` matches `NaN`. See the | ||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* for more details. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @alias unique | ||
* @category Arrays | ||
* @param {Array} array The array to process. | ||
* @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. | ||
* @param {Function|Object|string} [callback=identity] The function called | ||
* per iteration. If a property name or object is provided it will be used | ||
* to create a "_.pluck" or "_.where" style callback, respectively. | ||
* @param {*} [thisArg] The `this` binding of `callback`. | ||
* @returns {Array} Returns a duplicate-value-free array. | ||
* @category Array | ||
* @param {Array} array The array to inspect. | ||
* @param {boolean} [isSorted] Specify the array is sorted. | ||
* @param {Function|Object|string} [iteratee] The function invoked per iteration. | ||
* If a property name or object is provided it is used to create a "_.property" | ||
* or "_.matches" style callback respectively. | ||
* @param {*} [thisArg] The `this` binding of `iteratee`. | ||
* @returns {Array} Returns the new duplicate-value-free array. | ||
* @example | ||
* | ||
* _.uniq([1, 2, 1, 3, 1]); | ||
* // => [1, 2, 3] | ||
* _.uniq([1, 2, 1]); | ||
* // => [1, 2] | ||
* | ||
* _.uniq([1, 1, 2, 2, 3], true); | ||
* // => [1, 2, 3] | ||
* // using `isSorted` | ||
* _.uniq([1, 1, 2], true); | ||
* // => [1, 2] | ||
* | ||
* _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); | ||
* // => ['A', 'b', 'C'] | ||
* // using an iteratee function | ||
* _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); | ||
* // => [1, 2.5] | ||
* | ||
* _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); | ||
* // => [1, 2.5, 3] | ||
* | ||
* // using "_.pluck" callback shorthand | ||
* // using the "_.property" callback shorthand | ||
* _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); | ||
* // => [{ 'x': 1 }, { 'x': 2 }] | ||
*/ | ||
function uniq(array, isSorted, callback, thisArg) { | ||
// juggle arguments | ||
function uniq(array, isSorted, iteratee, thisArg) { | ||
var length = array ? array.length : 0; | ||
if (!length) { | ||
return []; | ||
} | ||
// Juggle arguments. | ||
if (typeof isSorted != 'boolean' && isSorted != null) { | ||
thisArg = callback; | ||
callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted; | ||
thisArg = iteratee; | ||
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; | ||
isSorted = false; | ||
} | ||
if (callback != null) { | ||
callback = createCallback(callback, thisArg, 3); | ||
} | ||
return baseUniq(array, isSorted, callback); | ||
iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3); | ||
return (isSorted) | ||
? sortedUniq(array, iteratee) | ||
: baseUniq(array, iteratee); | ||
} | ||
module.exports = uniq; |
@@ -1,3 +0,3 @@ | ||
Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas, | ||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -22,2 +22,2 @@ | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
{ | ||
"name": "lodash.uniq", | ||
"version": "2.4.1", | ||
"description": "The Lo-Dash function `_.uniq` as a Node.js module generated by lodash-cli.", | ||
"homepage": "http://lodash.com/custom-builds", | ||
"version": "3.0.0", | ||
"description": "The modern build of lodash’s `_.uniq` as a module.", | ||
"homepage": "https://lodash.com/", | ||
"icon": "https://lodash.com/icon.svg", | ||
"license": "MIT", | ||
"keywords": ["functional", "lodash", "lodash-modularized", "server", "util"], | ||
"keywords": "lodash, lodash-modularized, stdlib, util", | ||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"contributors": [ | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", | ||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", | ||
"Mathias Bynens <mathias@qiwi.be> (http://mathiasbynens.be/)" | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
], | ||
"bugs": "https://github.com/lodash/lodash-cli/issues", | ||
"repository": { "type": "git", "url": "https://github.com/lodash/lodash-cli.git" }, | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash._baseuniq": "~2.4.1", | ||
"lodash.createcallback": "~2.4.1" | ||
"lodash._basecallback": "^3.0.0", | ||
"lodash._baseuniq": "^3.0.0", | ||
"lodash._isiterateecall": "^3.0.0" | ||
} | ||
} |
@@ -1,15 +0,20 @@ | ||
# lodash.uniq v2.4.1 | ||
# lodash.uniq v3.0.0 | ||
The [Lo-Dash](http://lodash.com/) function [`_.uniq`](http://lodash.com/docs#uniq) as a [Node.js](http://nodejs.org/) module generated by [lodash-cli](https://npmjs.org/package/lodash-cli). | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.uniq` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
## Author | ||
## Installation | ||
| [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") | | ||
|---| | ||
| [John-David Dalton](http://allyoucanleet.com/) | | ||
Using npm: | ||
## Contributors | ||
```bash | ||
$ {sudo -H} npm i -g npm | ||
$ npm i --save lodash.uniq | ||
``` | ||
| [![twitter/blainebublitz](http://gravatar.com/avatar/ac1c67fd906c9fecd823ce302283b4c1?s=70)](https://twitter.com/blainebublitz "Follow @BlaineBublitz on Twitter") | [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | | ||
|---|---|---| | ||
| [Blaine Bublitz](http://www.iceddev.com/) | [Kit Cambridge](http://kitcambridge.be/) | [Mathias Bynens](http://mathiasbynens.be/) | | ||
In Node.js/io.js: | ||
```js | ||
var uniq = require('lodash.uniq'); | ||
``` | ||
See the [documentation](https://lodash.com/docs#uniq) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.uniq) for more details. |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6521
101
0
21
3
+ Addedlodash._basecallback@^3.0.0
+ Addedlodash._basecallback@3.3.1(transitive)
+ Addedlodash._baseindexof@3.1.0(transitive)
+ Addedlodash._baseisequal@3.0.7(transitive)
+ Addedlodash._baseuniq@3.0.3(transitive)
+ Addedlodash._bindcallback@3.0.1(transitive)
+ Addedlodash._cacheindexof@3.0.2(transitive)
+ Addedlodash._createcache@3.1.2(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash._isiterateecall@3.0.9(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.istypedarray@3.0.6(transitive)
+ Addedlodash.keys@3.1.2(transitive)
+ Addedlodash.pairs@3.0.1(transitive)
- Removedlodash.createcallback@~2.4.1
- Removedlodash._arraypool@2.4.1(transitive)
- Removedlodash._basebind@2.4.1(transitive)
- Removedlodash._basecreate@2.4.1(transitive)
- Removedlodash._basecreatecallback@2.4.1(transitive)
- Removedlodash._basecreatewrapper@2.4.1(transitive)
- Removedlodash._baseindexof@2.4.1(transitive)
- Removedlodash._baseisequal@2.4.1(transitive)
- Removedlodash._baseuniq@2.4.1(transitive)
- Removedlodash._cacheindexof@2.4.1(transitive)
- Removedlodash._cachepush@2.4.1(transitive)
- Removedlodash._createcache@2.4.1(transitive)
- Removedlodash._createwrapper@2.4.1(transitive)
- Removedlodash._getarray@2.4.1(transitive)
- Removedlodash._getobject@2.4.1(transitive)
- Removedlodash._isnative@2.4.1(transitive)
- Removedlodash._keyprefix@2.4.2(transitive)
- Removedlodash._largearraysize@2.4.1(transitive)
- Removedlodash._maxpoolsize@2.4.1(transitive)
- Removedlodash._objectpool@2.4.1(transitive)
- Removedlodash._objecttypes@2.4.1(transitive)
- Removedlodash._releasearray@2.4.1(transitive)
- Removedlodash._releaseobject@2.4.1(transitive)
- Removedlodash._setbinddata@2.4.1(transitive)
- Removedlodash._shimkeys@2.4.1(transitive)
- Removedlodash._slice@2.4.1(transitive)
- Removedlodash.bind@2.4.1(transitive)
- Removedlodash.createcallback@2.4.4(transitive)
- Removedlodash.forin@2.4.1(transitive)
- Removedlodash.identity@2.4.1(transitive)
- Removedlodash.isfunction@2.4.1(transitive)
- Removedlodash.isobject@2.4.1(transitive)
- Removedlodash.keys@2.4.1(transitive)
- Removedlodash.noop@2.4.1(transitive)
- Removedlodash.property@2.4.1(transitive)
- Removedlodash.support@2.4.1(transitive)
Updatedlodash._baseuniq@^3.0.0