Unique Array (NodeJS)

UniqueArray.NodeJS GitHub Contributors GitHub Issues GitHub Pull Requests GitHub Discussions GitHub Stars GitHub Forks GitHub Languages CodeFactor Grade LGTM Alerts LGTM Grade License

Release Latest (GitHub Latest Release Date) Pre (GitHub Latest Pre-Release Date)
GitHub GitHub Total Downloads GitHub Latest Release Version GitHub Latest Pre-Release Version
NPM NPM Total Downloads NPM Latest Release Version NPM Latest Pre-Release Version

📝 Description

A NodeJS module to return unique array elements by ignore all of the duplicated elements.

📚 Documentation

Getting Started

Install

  • NodeJS >= v14.15.0
  • NPM >= v6.14.8
npm install @hugoalh/unique-array

Use In CommonJS

const uniqueArray = require("@hugoalh/unique-array");

Use In ModuleJS

import uniqueArray from "@hugoalh/unique-array";

API

Function

uniqueArray(
  input: any[],
  ignoreReferences?: boolean = false// Whether to compare objects without compare their reference points.
): any[]

Example

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

uniqueArray([{ foo: "bar" }, { foo: "bar" }, { bar: "gaz" }]);
//=> [{ foo: "bar" }, { foo: "bar" }, { bar: "gaz" }]

uniqueArray([{ foo: "bar" }, { foo: "bar" }, { bar: "gaz" }], true);
//=> [{ foo: "bar" }, { bar: "gaz" }]

GitHub

View Github