array-unique
Advanced tools
Comparing version 0.2.1 to 0.3.2
15
index.js
@@ -29,1 +29,16 @@ /*! | ||
}; | ||
module.exports.immutable = function uniqueImmutable(arr) { | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError('array-unique expects an array.'); | ||
} | ||
var arrLen = arr.length; | ||
var newArr = new Array(arrLen); | ||
for (var i = 0; i < arrLen; i++) { | ||
newArr[i] = arr[i]; | ||
} | ||
return module.exports(newArr); | ||
}; |
{ | ||
"name": "array-unique", | ||
"description": "Return an array free of duplicate values. Fastest ES5 implementation.", | ||
"version": "0.2.1", | ||
"description": "Remove duplicate values from an array. Fastest ES5 implementation.", | ||
"version": "0.3.2", | ||
"homepage": "https://github.com/jonschlinkert/array-unique", | ||
"author": { | ||
"name": "Jon Schlinkert", | ||
"url": "https://github.com/jonschlinkert" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/jonschlinkert/array-unique.git" | ||
}, | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"repository": "jonschlinkert/array-unique", | ||
"bugs": { | ||
"url": "https://github.com/jonschlinkert/array-unique/issues" | ||
}, | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/array-unique/blob/master/LICENSE" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
@@ -34,5 +27,37 @@ "main": "index.js", | ||
"benchmarked": "^0.1.3", | ||
"mocha": "*", | ||
"should": "*" | ||
"gulp-format-md": "^0.1.9", | ||
"mocha": "^2.5.3", | ||
"should": "^10.0.0" | ||
}, | ||
"keywords": [ | ||
"array", | ||
"unique" | ||
], | ||
"verb": { | ||
"toc": false, | ||
"layout": "default", | ||
"tasks": [ | ||
"readme" | ||
], | ||
"plugins": [ | ||
"gulp-format-md" | ||
], | ||
"related": { | ||
"list": [ | ||
"arr-diff", | ||
"arr-union", | ||
"arr-flatten", | ||
"arr-reduce", | ||
"arr-map", | ||
"arr-pluck" | ||
] | ||
}, | ||
"reflinks": [ | ||
"verb", | ||
"verb-generate-readme" | ||
], | ||
"lint": { | ||
"reflinks": true | ||
} | ||
} | ||
} |
@@ -1,9 +0,11 @@ | ||
# array-unique [![NPM version](https://badge.fury.io/js/array-unique.svg)](http://badge.fury.io/js/array-unique) [![Build Status](https://travis-ci.org/jonschlinkert/array-unique.svg)](https://travis-ci.org/jonschlinkert/array-unique) | ||
# array-unique [![NPM version](https://img.shields.io/npm/v/array-unique.svg?style=flat)](https://www.npmjs.com/package/array-unique) [![NPM downloads](https://img.shields.io/npm/dm/array-unique.svg?style=flat)](https://npmjs.org/package/array-unique) [![Build Status](https://img.shields.io/travis/jonschlinkert/array-unique.svg?style=flat)](https://travis-ci.org/jonschlinkert/array-unique) | ||
> Return an array free of duplicate values. Fastest ES5 implementation. | ||
Remove duplicate values from an array. Fastest ES5 implementation. | ||
## Install with [npm](npmjs.org) | ||
## Install | ||
```bash | ||
npm i array-unique --save | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm install --save array-unique | ||
``` | ||
@@ -16,37 +18,61 @@ | ||
unique(['a', 'b', 'c', 'c']); | ||
//=> ['a', 'b', 'c'] | ||
var arr = ['a', 'b', 'c', 'c']; | ||
console.log(unique(arr)) //=> ['a', 'b', 'c'] | ||
console.log(arr) //=> ['a', 'b', 'c'] | ||
/* The above modifies the input array. To prevent that at a slight performance cost: */ | ||
var unique = require("array-unique").immutable; | ||
var arr = ['a', 'b', 'c', 'c']; | ||
console.log(unique(arr)) //=> ['a', 'b', 'c'] | ||
console.log(arr) //=> ['a', 'b', 'c', 'c'] | ||
``` | ||
## Related | ||
* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons. | ||
* [arr-union](https://github.com/jonschlinkert/arr-union): Returns an array of unique values using strict equality for comparisons. | ||
* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | ||
* [arr-reduce](https://github.com/jonschlinkert/arr-reduce): Fast array reduce that also loops over sparse elements. | ||
* [arr-map](https://github.com/jonschlinkert/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | ||
* [arr-pluck](https://github.com/jonschlinkert/arr-pluck): Retrieves the value of a specified property from all elements in the collection. | ||
## About | ||
## Run tests | ||
Install dev dependencies. | ||
### Related projects | ||
```bash | ||
npm i -d && npm test | ||
* [arr-diff](https://www.npmjs.com/package/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://github.com/jonschlinkert/arr-diff) | [homepage](https://github.com/jonschlinkert/arr-diff "Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.") | ||
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.") | ||
* [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map "Faster, node.js focused alternative to JavaScript's native array map.") | ||
* [arr-pluck](https://www.npmjs.com/package/arr-pluck): Retrieves the value of a specified property from all elements in the collection. | [homepage](https://github.com/jonschlinkert/arr-pluck "Retrieves the value of a specified property from all elements in the collection.") | ||
* [arr-reduce](https://www.npmjs.com/package/arr-reduce): Fast array reduce that also loops over sparse elements. | [homepage](https://github.com/jonschlinkert/arr-reduce "Fast array reduce that also loops over sparse elements.") | ||
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.") | ||
### Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Building docs | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
``` | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/array-unique/issues) | ||
### Running tests | ||
## Author | ||
Install dev dependencies: | ||
```sh | ||
$ npm install -d && npm test | ||
``` | ||
### Author | ||
**Jon Schlinkert** | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
Copyright (c) 2015 Jon Schlinkert | ||
Released under the MIT license | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/array-unique/blob/master/LICENSE). | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 24, 2015._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.28, on July 31, 2016._ |
Sorry, the diff of this file is not supported yet
Nonpermissive License
License(Experimental) A package's licensing information has fine-grained problems
Found 1 instance in 1 package
7161
0
34
77
5