dedupe

    3.0.3 • Public • Published

    dedupe Build Status

    removes duplicates from your array.

    Installation

    npm install dedupe

    Usage

    primitive types

    var dedupe = require('dedupe')
    
    var a = [1, 2, 2, 3]
    var b = dedupe(a)
    console.log(b)
    
    //result: [1, 2, 3]

    complex types

    Here the string representation of the object is used for comparism. Internal JSON.stringify is used for serialization. That means that {} is considered equal to {}.

    var dedupe = require('dedupe')
    
    var aa = [{a: 2}, {a: 1}, {a: 1}, {a: 1}]
    var bb = dedupe(aa)
    console.log(bb)
    
    //result: [{a: 2}, {a: 1}]

    complex types types with custom hasher

    You can use a custom hasher to overwrite the default behaviour.

    var dedupe = require('dedupe')
    
    var aaa = [{a: 2, b: 1}, {a: 1, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]
    var bbb = dedupe(aaa, value => value.a)
    console.log(bbb)
    
    //result: [{a: 2, b: 1}, {a: 1,b: 2}]

    Install

    npm i dedupe

    DownloadsWeekly Downloads

    13,550

    Version

    3.0.3

    License

    MIT

    Unpacked Size

    3.14 kB

    Total Files

    4

    Last publish

    Collaborators

    • zaphod1984