package/package.json000644 000765 000024 0000001246 12340456644013030 0ustar00000000 000000 { "name": "uniq", "version": "1.0.1", "description": "Removes duplicates from a sorted array in place", "main": "uniq.js", "directories": { "test": "test" }, "dependencies": {}, "devDependencies": { "tape": "^2.12.3" }, "scripts": { "test": "tape test/*.js" }, "repository": { "type": "git", "url": "git://github.com/mikolalysenko/uniq.git" }, "keywords": [ "array", "duplicate", "unique", "uniq", "remove", "sort", "in", "place", "no", "copy" ], "author": "Mikola Lysenko", "license": "MIT", "readmeFilename": "README.md", "gitHead": "e9828cfcb97e25a351f95b39fdf3c31876ff3985" } package/.npmignore000644 000765 000024 0000000142 12123606303012517 0ustar00000000 000000 lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results npm-debug.log node_modules/*package/README.md000644 000765 000024 0000002305 12125722321012003 0ustar00000000 000000 uniq ==== Removes all duplicates from an array in place. Usage ===== First install using npm: npm install uniq Then use it as follows: ```javascript var arr = [1, 1, 2, 2, 3, 5] require("uniq")(arr) console.log(arr) //Prints: // // 1,2,3,5 // ``` ## `require("uniq")(array[, compare, sorted])` Removes all duplicates from a sorted array in place. * `array` is the array to remove items from * `compare` is an optional comparison function that returns 0 when two items are equal, and something non-zero when they are different. If unspecified, then the default equals will be used. * `sorted` if true, then assume array is already sorted **Returns:** A reference to `array` **Time Complexity:** `O(array.length * log(arra.length))` or `O(array.length)` if `sorted` ## Why use this instead of underscore.uniq[ue]? A few reasons: * This library updates the array in place without making an extra copy (and so it is faster for large arrays) * It also accepts a custom comparison function so you can remove duplicates from arrays containing object * It is more modular in the sense that it doesn't come with a bazillion other utility grab bag functions. # Credits (c) 2013 Mikola Lysenko. MIT License package/LICENSE000644 000765 000024 0000002072 12144300731011530 0ustar00000000 000000 The MIT License (MIT) Copyright (c) 2013 Mikola Lysenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/uniq.js000644 000765 000024 0000001616 12340456635012055 0ustar00000000 000000 "use strict" function unique_pred(list, compare) { var ptr = 1 , len = list.length , a=list[0], b=list[0] for(var i=1; i