2.0.0 • Published 10 years ago

uniqs v2.0.0

Weekly downloads
7,850,483
License
MIT
Repository
github
Last release
10 years ago

Build Status

Tiny utility to create unions and de-duplicated lists.

Example:

var uniqs = require('uniqs');

var foo = { foo: 23 };
var list = [3, 2, 2, 1, foo, foo];

uniqs(list);
// => [3, 2, 1, { foo: 23 }]

You can pass multiple lists to create a union:

uniqs([2, 1, 1], [2, 3, 3, 4], [4, 3, 2]);
// => [2, 1, 3, 4]

Passing individual items works too:

uniqs(3, 2, 2, [1, 1, 2]);
// => [3, 2, 1]

Summary

  • Uniqueness is defined based on strict object equality.
  • The lists do not need to be sorted.
  • The resulting array contains the items in the order of their first appearance.

About

This package has been written to accompany utilities like flatten as alternative to full-blown libraries like underscore or lodash.

The implementation is optimized for simplicity rather than performance and looks like this:

module.exports = function uniqs() {
  var list = Array.prototype.concat.apply([], arguments);
  return list.filter(function(item, i) {
    return i == list.indexOf(item);
  });
};

License

MIT

vuedragdropuploadimagescloud-archive-s3bb-chat@fundefund/funde_ckgql_din_mod@everything-registry/sub-chunk-3013p149-tablevue-button-test1vue-compment@graines-digitales/nice-handsome-button@greminder/bootstrap-material-designvformlmqverify-img-code@junvary/quasar-ui-qcascader@kommunicate/kommunicate-chatbot-plugin@kristoffertonning/vue-laravel-errors@leiyulf/gantt-task-reactfhir2@hproinformatica/functionseasyplayer-my@humanity.cash/types@meysam213/react-leafletflowable-bpmn-modelergenerator-bootstrap-boilerplate-template@ngxvoice/ngx-voicelistner@refactorpro/pixi-virtual-joystick@sak1sham/react-toc-highlight@hazyflame/vue-jitsi-meet@ikon-x/ckeditor5-custom-build-for-irrosofthot-zone-vue@percent/percent-api-hooks@oriduk/ckeditor5-rebuild-musicanote@oriduk/ckeditor5-rebuild-oriduk@southcn/ckeditor5-build-inlinejesusdemo@enonic/mock-xp@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@the91end/react-auth@stansaal/ckeditor5-custom-buildkafirchain-tetrisbain@bezael-challenge/innoit-date-formatng-search-dropdown@zebracompany/f_editorcarousel-react@contagt/metismenunois-react-toast@darwishdev/dash-dev@artiso-solutions/vue-html-to-papernka-gantt-task-reactbase-editor@ctfdio/picocss-themes@ct-note/tablem2m-chartjs-plugin-crosshairlitepie-datepicker-gabe@vue-helper/vue-keep-alivemggauharap-vue-captchapostcss-discard-unused-nightlypostcss-font-familypostcss-unicode-characterspostcss-unique-selectors-nightly@devorso/dcountdownpostcss-minify-params-nightlypostcss-zindex-nightlyreact-lightbox-pack-18supportp147-tablep148-tablecssesc-wbgcourse-vue-tplckeditor5-build-classic-ticketckeditor5-build-classic-v-editckeditor5-build-custom-strapickeditor-5-imi-1ckeditor5-custom-build-megampireckeditor5-click-virtualckeditor5-custom-symmetreckeditor5-custom-build-for-irrosoftckeditor5-custom-ksckeditor5-build-yektackeditor5-strapi-msgdigital-keyboard-demosresponsis-gantt-task-reactsearch-input-reactsearch-list-reactsequelcomponent@carhoo/widget-dealerssticky-scroll-catchstock-ticker-react-widgettealteal-jsteal-phptingzi-vuepresstestapa
2.0.0

10 years ago

1.0.0

10 years ago