uniqs

WebJar for uniqs

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

uniqs
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

uniqs
WebJar for uniqs
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/fgnass/uniqs

Download uniqs

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/uniqs/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>uniqs</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/uniqs/
implementation 'org.webjars.npm:uniqs:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/uniqs/
implementation ("org.webjars.npm:uniqs:2.0.0")
'org.webjars.npm:uniqs:jar:2.0.0'
<dependency org="org.webjars.npm" name="uniqs" rev="2.0.0">
  <artifact name="uniqs" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='uniqs', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "uniqs" % "2.0.0"
[org.webjars.npm/uniqs "2.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Versions

Version
2.0.0