unique-array-objects

2.1.0 • Public • Published

unique-array-objects

Module for deleting repeated objects. The module considers romantic key and values ​​and the visual structure.

How to start

Start:

  1. Install the dependency with npm i --save unique-array-objects
  2. Import the library:
/*
* Use as function
*/
import uab from 'unique-array-objects';
var array = [
    {
        id: 1, 
        nome: 'Jhon'
    },
    { 
        id: 2, 
        nome: 'Jhon'
    }, {
        id: 1, 
        nome: 'Jhon'
    },
    { 
        id: 1, 
        nome: 'Jhon',
        altura: 1.71
    }
]
console.log(uab(array);
/**
 * WILL RETURN:
 * 
 * 0 => id: 1, nome: 'Jhon'
 * 1 => id: 2, nome: 'Jhon'
 * 2 => id: 1, nome: 'Jhon', altura: 1.71
 */
 
 
/*
* Use as Array.prototype
*/
import uab from 'unique-array-objects/prototype';
Array.prototype.remove = uab
var array = [
    {
        id: 1, 
        nome: 'Jhon'
    },
    { 
        id: 2, 
        nome: 'Jhon'
    }, {
        id: 1, 
        nome: 'Jhon'
    },
    { 
        id: 1, 
        nome: 'Jhon',
        altura: 1.71
    }
]
console.log(array.remove())
/*
* Use as middleware on Node
*/
router.get('/test', require('unique-array-objects/middle'), function (req, res) {
    var array = [{
            id: 1,
            nome: 'Jhon'
        },
        {
            id: 2,
            nome: 'Jhon'
        }, {
            id: 1,
            nome: 'Jhon'
        },
        {
            id: 1,
            nome: 'Jhon',
            altura: 1.71
        }
    ]
    res.send(req.uac(array))
})

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i unique-array-objects

      Weekly Downloads

      43

      Version

      2.1.0

      License

      ISC

      Unpacked Size

      3.05 kB

      Total Files

      6

      Last publish

      Collaborators

      • hallss93
      • bunker.dev