2.0.0 • Published 11 years ago

uniqs v2.0.0

Weekly downloads
7,850,483
License
MIT
Repository
github
Last release
11 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-test1responsis-gantt-task-reacttealteal-phpteal-jssticky-scroll-catchsearch-input-reactsearch-list-reactsequelcomponenttestapavue-compmentvs-tree-plusjesusdemom2m-chartjs-plugin-crosshairmggauharlitepie-datepicker-gabekafirchain-tetrishot-zone-vuep147-tablep148-tablepostcss-unicode-characterspostcss-unique-selectors-nightlypostcss-discard-unused-nightlypostcss-font-familypostcss-zindex-nightlypostcss-minify-params-nightlyng-search-dropdownnka-gantt-task-reactreact-lightbox-pack-18supportnois-react-toaststock-ticker-react-widgettingzi-vuepress@artiso-solutions/vue-html-to-paper@bezael-challenge/innoit-date-format@carhoo/widget-dealers@devorso/dcountdown@darwishdev/dash-dev@contagt/metismenuverify-img-codevformlmq@greminder/bootstrap-material-design@hazyflame/vue-jitsi-meet@hproinformatica/functions@humanity.cash/types@graines-digitales/nice-handsome-button@kristoffertonning/vue-laravel-errors@leiyulf/gantt-task-react@meysam213/react-leaflet@ngxvoice/ngx-voicelistner@enonic/mock-xp@kommunicate/kommunicate-chatbot-plugin@ikon-x/ckeditor5-custom-build-for-irrosoft@junvary/quasar-ui-qcascader@sak1sham/react-toc-highlight@refactorpro/pixi-virtual-joystick@oriduk/ckeditor5-rebuild-oriduk@oriduk/ckeditor5-rebuild-musicanote@southcn/ckeditor5-build-inline@stansaal/ckeditor5-custom-build@ctfdio/picocss-themes@ct-note/table@percent/percent-api-hookseasyplayer-my@the91end/react-auth@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdownfhir2@vue-helper/vue-keep-alive@zebracompany/f_editorap-vue-captchaflowable-bpmn-modelergenerator-bootstrap-boilerplate-templatebase-editorbaincarousel-reactckeditor5-custom-symmetreckeditor5-custom-build-megampireckeditor5-custom-build-for-irrosoftckeditor5-custom-ksckeditor5-build-custom-strapickeditor5-build-classic-ticketckeditor5-build-classic-v-editcssesc-wbgcourse-vue-tplckeditor5-click-virtualckeditor5-build-yektackeditor5-strapi-msgckeditor-5-imi-1digital-keyboard-demos
2.0.0

11 years ago

1.0.0

11 years ago