2.1.0 • Published 5 years ago

unique-array-objects v2.1.0

Weekly downloads
53
License
ISC
Repository
github
Last release
5 years ago

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))
})
2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

6 years ago