Socket
Socket
Sign inDemoInstall

array-ext

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    array-ext

Some Array extensions


Version published
Maintainers
1
Install size
12.2 kB
Created

Readme

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

FAQs

Last updated on 16 Jan 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc