🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array-ext

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-ext

Some Array extensions

0.1.5
latest
Source
npm
Version published
Maintainers
1
Created
Source

###Some Array Extensions

NPM version Tests License

####Examples:

var arrayExt = require('array-ext');

var arr = [128, 255, 255];

arr.toHex(); // 80 ff ff

//Compare
arr.eq([128, 255]); // true


//new array unique entries
var arr3 = arr.uniquef();

//Remove dupplicated entries
arr.unique(); // arr will be [128, 255]


var arr1 = [
    { ip: '192.168.1.1', name: 'gateway' },
    { ip: '192.168.1.1', name: 'gateway' },
    { ip: '192.168.1.2', name: 'gateway' },
    { ip: '192.168.1.3', name: 'gateway' }
];

arr1.unique('ip'); // by porperty name



arr.contains(128); // true
arr1.contains('ip', {ip: '192.168.1.1'}); // true // by poperty name

var arr2 = [
    { ip: '192.168.1.100', name: 'gateway' },
    { ip: '192.168.1.1', name: 'gateway' },
    { ip: '192.168.1.200', name: 'gateway' },
    { ip: '192.168.1.30', name: 'gateway' }
];

arr1.contains('ip', arr2); // true


// push an entry if not already in
arr.add(128); //

//remove 
arr.removeDup(128); // will remove entry 128

//remove all by array
arr1.removeDup('ip', arr2);

//same than forEach, except counting form the end
//usefull if entries will be deleted in callback
arr.lastThat(function(entry, index, array){
});

Keywords

Array extension

FAQs

Package last updated on 16 Jan 2017

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