Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

de_duplicated

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

de_duplicated

This is a package to delete the duplicated elements in array

  • 2.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

De Duplicated npm version GitHub forks GitHub issues GitHub stars Build Status

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

  1. Examples for simple array:
//example 1
import DeDuplicated from 'de_duplicated';
// OR
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);
//result
    //[ 2, 5, 8, 3 ]
//example 2

import DeDuplicated from 'de_duplicated';
// OR
const DeDuplicated = require('../de_duplicate/build').default;

let simpleArray = ['john', 'milad', 'Milad', 'john', 'John'];

let uniqueSimpleArray = DeDuplicated.simpleArray(simpleArray);

console.log(uniqueSimpleArray);
// result
    //[ 'john', 'milad' ]

   // Note that: The simpleArray method case insensitive for string 
 //example 3
import DeDuplicated from 'de_duplicated';
// OR
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);
//result
    //[ 1, 2, 5, 8, 'john', 'milad' ]

    //Note That: The simpleArray method case insensitive for string 
  1. Examples for complex array
    //example 1
import DeDuplicated from 'de_duplicated';
// OR
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);
// result
   /* [
        { id: 1, name: 'Milad', age: 24 },
        { id: 2, name: 'Milad', age: 24 },
        { id: 3, name: 'Milad', age: 24 }
    ]*/
    //example 2
import DeDuplicated from 'de_duplicated';
// OR
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);
//result
    //[ { id: 1, name: 'Milad', age: 24 }, { id: 2, name: 'John', age: 24 } ]
    //example 3
import DeDuplicated from 'de_duplicated';
// OR
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);
//result
    /*[
    { id: 1, name: 'Milad', age: 24 },
    { id: 2, name: 'milad', age: 24 }
    ]*/

    //Note that : The complexArray method case sensitive for string 

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

FAQs

Package last updated on 21 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc