1.0.1 • Published 10 years ago

uniq v1.0.1

Weekly downloads
10,636,258
License
MIT
Repository
github
Last release
10 years ago

uniq

Removes all duplicates from an array in place.

Usage

First install using npm:

npm install uniq

Then use it as follows:

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.unique?

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

vuedragdropuploadimageswebtorrent-jalibittorrent-tracker-sslcloud-archive-s3bb-chat@fundefund/funde_ckabisko-climate-plotsgql_din_mod@l1nyanm1ng/react-picture-viewer@everything-registry/sub-chunk-3013p149-table@kommunicate/kommunicate-chatbot-plugin@koding/gloh@koding/bant-factor@kristoffertonning/vue-laravel-errors@laplatajs/timbify@leiyulf/gantt-task-reactglohglslify-detectivegl-shader-updategl-state@movilizame/relational-pouchgame-shellgo-plugin-cligreedy-meshergoogle-mirror-check@openpolitica/matomo-next@namtoonix/editorjs-custom-multiple-selectedgbapitestgenerator-bootstrap-boilerplate-template@nbcnews/machinist@ngxvoice/ngx-voicelistnerget-torrentgenorec-enginegeojson-polygon-aggregategeojson-xyz-data@kirrosh/pts@refactorpro/pixi-virtual-joystickidl@sackmanson/quill-image-uploaderipfs-engram@sak1sham/react-toc-highlightgulp-htmlimghyperdb-osmhyperlog-concestoricons-vue-test@rubenrodriguez/qbzf@ryifkiyidan/schema-to-yuphexyun.helpers@ikon-x/ckeditor5-custom-build-for-irrosofthtml-versionhot-zone-vue@oriduk/ckeditor5-rebuild-musicanote@oriduk/ckeditor5-rebuild-oridukgulp-cssimg@pvm/pvm@pvm/updatehbxytc-maxiangyinhbxytc_jiangyulinghashdjquerytest@silver0542/directus-extension-cma-components-editorjsonmvc-dbjsonmvc-datastore@southcn/ckeditor5-build-inlinejesusdemohelp-widgetjopafyhello-ragunan-2015halfasleep_math2kappa-osmjsw@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdownkillsomel1-path-finder@the91end/react-auth@stansaal/ckeditor5-custom-build@tradle/bitjoe-js@synthit/nested-listkafirchain-tetrisbainbant-factorbffs@atimermann/sindri@c11/engine.dbng-search-dropdown@bitfirer/vue-qriouslybem-tools-createbittorrent-tracker-proxybittorrent-tracker-ritbittorrent-tracker-zeronetbogotaavenbreaks-ipfs-storagemocha-jshintmocha-jshint-stylishmoekitbabel-standardapplesignlog-pattern@zebracompany/f_editor
1.0.1

10 years ago

1.0.0

10 years ago

0.0.2

11 years ago

0.0.0

11 years ago