npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

arrayhelper

v0.1.5

Published

Common array functions used by Exclusive Software

Readme

Description

A package of functions that extend array functionality in Node

Installation

npm install arrayhelper

Usage

Just add the following line and the Array.prototype will then include all Functions

require('arrayhelper');

Functions

Array.prototype.distinct()

Description

Returns an array with duplicate items removes

Returns

Array

Example

var arr = [1,1,5,6,3,5,6,7,7];
var distinct = arr.distinct();
console.log(distinct); //[ 1, 5, 6, 3, 7 ]

Array.prototype.equals(arr)

Description

Returns true if elements in the two arrays are equal, false otherwise. Also checks for nested arrays and their equality.

Parameters

arr - Array to compare with. Returns false if this is not an array

Returns

boolean, true if elements in the arrays are equal

Example

var arr1 = [ 1, 2, [ 3, 4 ] ];
var arr2 = [ 1, 2, [ 3, 4 ] ];
var arr3 = [ 1, 2, 3, 4 ];

console.log(arr1.equals(arr2)); //true
console.log(arr1.equals(arr3)); //false

Array.prototype.toDict(key)

Description

Converts an array of objects into an object with keys specified by key

Parameters

key - String. The value from the objects to use as the key in the dictionary

Returns

Object

Example

var arr = [
    { ID: 1, Data: 'hello world' },
    { ID: 2, Data: 'arrays are useful', Data2: 'dictionaries are good to' },
    { ID: 2, Data: 'example'}
];
console.log(arr.toDict('ID'));
/*
 * { '1': { ID: 1, Data: 'hello world' },
 *   '2':
 *   [ { ID: 2,
 *       Data: 'arrays are useful',
 *       Data2: 'dictionaries are good to' },
 *     { ID: 2, Data: 'example' } ] } 
 */

 console.log(arr.toDict('Data'));
 /*
  * { 'hello world': { ID: 1, Data: 'hello world' },
  * 'arrays are useful':
  *  { ID: 2,
  *    Data: 'arrays are useful',
  *    Data2: 'dictionaries are good to' },
  * example: { ID: 2, Data: 'example' } }
  */

  console.log(arr.toDict('ID')[1]); //{ ID: 1, Data: 'hello world' }
  console.log(arr.toDict('Data').example); //{ ID: 2, Data: 'example' }

Array.prototype.forEachCallback(callback, [end])

Description

Loops through each item in the array and waits (non blocking) for the callback before proceeding to the next item in the array.

Parameters

callback - function(item, next) item - the current item in the array next - call when finished to move to the next item in the array

end - function. Optional. Called when the for each loop is complete

Returns

No return value

example

var arr = [
    { ID: 1, Data: 'foo' },
    { ID: 2, Data: 'bar' }
];

arr.forEachCallback(function(item, next) {
    db.someCallToDb(item, function(err, res) {
        next();
    });
}, function() {
    console.log('Loop complete notify client side');
});

Array.prototype.execute([callback])

Description

Executes an array of functions in a semi-async manner. Does not execute the callback untill all functions are complete. Each function in the array accepts one variable that is a function to call when execution is complete.

Useful for when you want to make multiple calls to a database and not have to wait for each one before executing the next.

Each function in the array is in the below format

function(done) {

}

Where done is the callback in the format function(err). If err is set other functions in the array may finish executing but no more are started and execution drops straight out to the callback supplied in the execute call.

See example for details.

Parameters

callback - function(err). Optional. Called when all functions have finished execution. err - set if there was an error returned from on of the functions in the array

Returns

No return value

Example

[
    function(done) {
        console.log('function 1');
        done();
    },
    function(done) {
        done(new Error('Error at function 2'));
    },
    function(done) {
        console.log('function 3');
        done();
    }
].execute(function(err) {
    if(err) console.log(err);
    console.log('Execution complete');
});

/* outputs
 * function 1
 * function 3
 * [Error: Error at function 2]
 * Execution complete
 */