@hugoalh/unique-array
v6.0.0
Published
A module to return unique array elements without any duplicated elements by ignore their reference points.
Readme
Unique Array (ES)
🔗 DistBoard @hugoalh ● GitHub ● JSR ● NPM
An ECMAScript module to return unique array elements without any duplicated elements by ignore their reference points.
🎯 Runtime Targets
Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:
🛡️ Runtime Permissions
This does not request any runtime permission.
#️⃣ Sources & Entrypoints
- GitHub Raw
https://raw.githubusercontent.com/hugoalh/unique-array-es/{Tag}/mod.ts - JSR
jsr:@hugoalh/unique-array[@{Tag}] - NPM
npm:@hugoalh/unique-array[@{Tag}]
| Name | Path | Description |
|:--|:--|:--|
| . | ./mod.ts | Default. |
| ./array | ./array.ts | Utility for array. |
| ./collector | ./collector.ts | Collector. |
[!NOTE]
- Different runtimes have vary support for the sources and entrypoints, visit the runtime documentation for more information.
- It is recommended to include tag for immutability.
- These are not part of the public APIs hence should not be used:
- Benchmark/Test file (e.g.:
example.bench.ts,example.test.ts).- Entrypoint name or path include any underscore prefix (e.g.:
_example.ts,foo/_example.ts).- Identifier/Namespace/Symbol include any underscore prefix (e.g.:
_example,Foo._example).
🧩 APIs
class UniqueCollector<T> { collect(item: T): boolean; getCount(): bigint; getSize(): number; has(item: T): boolean; values(): SetIterator<T>; }function uniqueArray<T>(item: readonly T[]): T[];
[!NOTE]
- For the full or prettier documentation, can visit via:
✍️ Examples
uniqueArray([{ foo: "bar" }, { foo: "bar" }, { bar: "gaz" }]); //=> [{ foo: "bar" }, { bar: "gaz" }]
