JSPM

@reactive-academy/js-array-unique

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q22374F
  • License MIT

Function to remove duplicated items from item and return array with unique elements only

Package Exports

  • @reactive-academy/js-array-unique

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@reactive-academy/js-array-unique) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

js-array-unique

Function to remove duplicated items from array and return an array with unique elements only

NPM

Installation

npm install @reactive-academy/js-array-unique
yarn add @reactive-academy/js-array-unique

Usage

Array with primitive items

import unique from '@reactive-academy/js-array-unique';

const items = ['a', 'b', 'c', 'c', 'a'];
// output: ['a', 'b', 'c']
const uniqueItems = unique(items); 

Objects in the array

import unique from '@reactive-academy/js-array-unique';

const items1 = [{id: 1, name: 'Patrick'}, {id: 2, name: 'John'}];
const items2 = [{id: 1, name: 'Patrick'}, {id: 1, name: 'Patrick'}, {id: 2, name: 'John'}, {id: 3, name: 'Frank'}];
// output: [{id: 1, name: 'Patrick'}, {id: 2, name: 'John'}, {id: 3, name: 'Frank'}]
const uniqueItems = unique([...items1, ...items2], 'id');