Sha256: 266c44a60e8bc0d0aea544a162b08fc35ce3023af9e26e9b01f930cd89b97d92

Contents?: true

Size: 1.18 KB

Versions: 32

Compression:

Stored size: 1.18 KB

Contents

[![Build Status](https://travis-ci.org/fgnass/uniqs.svg?branch=master)](https://travis-ci.org/fgnass/uniqs)

### Tiny utility to create unions and de-duplicated lists.

Example:

```js
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:

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

Passing individual items works too:
```js
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](https://npmjs.org/package/flatten) as alternative to full-blown
libraries like underscore or lodash.

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

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

### License
MIT

Version data entries

32 entries across 31 versions & 11 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/uniqs/README.md
disco_app-0.18.0 test/dummy/node_modules/uniqs/README.md
disco_app-0.18.2 test/dummy/node_modules/uniqs/README.md
disco_app-0.16.1 test/dummy/node_modules/uniqs/README.md
disco_app-0.15.2 test/dummy/node_modules/uniqs/README.md
disco_app-0.18.4 test/dummy/node_modules/uniqs/README.md
disco_app-0.18.1 test/dummy/node_modules/uniqs/README.md
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/uniqs/README.md
disco_app-0.14.0 test/dummy/node_modules/uniqs/README.md
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/uniqs/README.md
tang-0.2.1 spec/tang_app/node_modules/uniqs/README.md
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/uniqs/README.md
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/uniqs/README.md
ruby2js-4.0.4 lib/tasks/testrails/node_modules/uniqs/README.md
ruby2js-4.0.3 lib/tasks/testrails/node_modules/uniqs/README.md
tang-0.2.0 spec/tang_app/node_modules/uniqs/README.md
tang-0.1.0 spec/tang_app/node_modules/uniqs/README.md
tang-0.0.9 spec/tang_app/node_modules/uniqs/README.md
enju_library-0.3.8 spec/dummy/node_modules/uniqs/README.md
jester-data-8.0.0 node_modules/uniqs/README.md