De Duplicated
This is package for deleting the duplicated elements in array, there are contain two methods, first method called simpleArray, this method de_duplicated the simple elements just numbers or strings or both, and second method is complexArray the de_duplicated object elements in array
Getting Started
download the package in your project and require it, and use it
Prerequisites
you should have node.js in your local machine
Installing
open terminal and go to your project directory and write
npm install de_duplicated
// or
yarn add de_duplicated
How To Use it
After install package
- Examples for simple array:
import DeDuplicated from 'de_duplicated';
const DeDuplicated = require('../de_duplicate/build').default;
let simpleArray = [2, 5, 8, 2, 2, 8, 5, 2, 3];
let uniqueSimpleArray = DeDuplicated.simpleArray(simpleArray);
console.log(uniqueSimpleArray);
import DeDuplicated from 'de_duplicated';
const DeDuplicated = require('../de_duplicate/build').default;
let simpleArray = ['john', 'milad', 'Milad', 'john', 'John'];
let uniqueSimpleArray = DeDuplicated.simpleArray(simpleArray);
console.log(uniqueSimpleArray);
import DeDuplicated from 'de_duplicated';
const DeDuplicated = require('../de_duplicate/build').default;
let simpleArray = [1, 2, 1, 2, 5, 8, 8, 5, 'john', 'milad', 'Milad', 'john', 'John'];
let uniqueSimpleArray = DeDuplicated.simpleArray(simpleArray);
console.log(uniqueSimpleArray);
- Examples for complex array
import DeDuplicated from 'de_duplicated';
const DeDuplicated = require('../de_duplicate/build').default;
let complexArray = [
{ id: 1, name: "Milad", age: 24 },
{ id: 2, name: "Milad", age: 24 },
{ id: 1, name: "Milad", age: 24 },
{ id: 3, name: "Milad", age: 24 },
{ id: 1, name: "Milad", age: 24 },
{ id: 2, name: "Milad", age: 24 },
]
let uniqueComplexArray = DeDuplicated.complexArray(complexArray, 'id');
console.log(uniqueComplexArray);
import DeDuplicated from 'de_duplicated';
const DeDuplicated = require('../de_duplicate/build').default;
let complexArray = [
{ id: 1, name: "Milad", age: 24 },
{ id: 2, name: "John", age: 24 },
{ id: 1, name: "Milad", age: 24 },
{ id: 3, name: "John", age: 24 },
{ id: 1, name: "Milad", age: 24 },
{ id: 2, name: "Milad", age: 24 },
]
let uniqueComplexArray = DeDuplicated.complexArray(complexArray, 'name');
console.log(uniqueComplexArray);
import DeDuplicated from 'de_duplicated';
const DeDuplicated = require('../de_duplicate/build').default;
let complexArray = [
{ id: 1, name: "Milad", age: 24 },
{ id: 2, name: "milad", age: 24 },
{ id: 1, name: "Milad", age: 24 },
{ id: 3, name: "milad", age: 24 },
{ id: 1, name: "Milad", age: 24 },
{ id: 2, name: "Milad", age: 24 },
]
let uniqueComplexArray = DeDuplicated.complexArray(complexArray, 'name');
console.log(uniqueComplexArray);
Authors
License
This project is licensed under the MIT License - see the LICENSE.md file for details