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 🙏

© 2024 – Pkg Stats / Ryan Hefner

arrayext.js

v1.0.6

Published

Javascript Library to Extend Javascript's array functionalities

Downloads

1

Readme

arrayExt.js

A lightwieght Javascript Library that extends Javascript's array functionalities.

Using arrayExt.js

Just import arrayExt.js file from the package folder into your project and arrays will automatically have new functions.

Usage:

var foo1 = [{a: 1, b: 2}, {a: 3, b: 4}];
var foo2 = [1,2,3,4];

var check = function(elem, value) {     /* elem is the array element and value the value we send */
  return elem.a === value;
};

foo1.index(3, check);       /* Returns 1 */
foo1.index(8, check);       /* Returns -1 */

foo2.index(3);              /* Returns 2 */

Usage:

var foo1 = [1,3,5,7,9];
var foo2 = [1,3,5,7,9];

var check = function(elem1, elem2){      /* elem1 is the array element and elem2 the element of the array we send */
  return elem1 === elem2;
};

foo1.same(foo2);             /* Returns true*/
foo1.same(foo2, check);      /* Returns true*/

foo2.push(2);

foo1.same(foo2);             /* Returns false*/
foo1.same(foo2, check);      /* Returns false*/

Usage:

var foo1 = [1,3,5,7,9];
var foo2 = [1,3,5];
var foo3 = [1,6];

var check = function(elem1, elem2){      /* elem1 is the array element and elem2 the element of the array we send */
  return elem1 === elem2;
};

foo1.hasList(foo2);             /* Returns true*/
foo1.hasList(foo2, check);      /* Returns true*/

foo1.hasList(foo3);             /* Returns false*/

Usage:

var foo1 = [1,3,5,7];
var foo2 = foo1.copy();

foo1 == foo2  /* Returns false */

Usage:

var foo = [2,4,6,8,0];

foo.sublist(1,3);            /* Returns [4, 6, 8]*/

Usage:

var foo = [1,3,5,7];

foo.shove(9);   /* Returns 5 and foo is [1,3,5,9] */
foo.shove(9);   /* Returns 5 and foo is [1,3,5,9] */

/* With comparison function */

var foo = [{a: 1, b: 2}];

var check = function(elem, value) {     /* elem is the array element and value the value we send */
  return elem.a === value.a;
};

foo.shove({a:3, b:4}, check);  /* Returns 2 and foo is [{a: 1, b: 2}, {a:3, b:4}] */
foo.shove({a:3, b:4}, check):  /* Returns 2 and foo is [{a: 1, b: 2}, {a:3, b:4}] */

Usage:

var foo = [1,5,9];

foo.insert(3,2));      /* Returns 4 and foo is [1,5,3,9] */

Usage:

var foo = [1,3,5,7,9];

foo.remove(3));      /* Returns 4 and foo is [1,5,3,9] */

Usage:

var foo = [0,1,2,null,"hello",""];

foo.clean();        /* foo is [0,1,2,"hello"] */

Usage:

var foo1 = [1,3,5,7,9];
var foo2 = [1,2,5,6,9];

foo1.intersection(foo2);      /* Returns [1,5,9] */

var foo3 = [{a: 1, b:2}, {a: 3, b: 4}];
var foo4 = [{a: 1, b:2}];

var check = function(elem1, elem2){     /* elem1 is the array element and elem2 the element of the array we send */
  elem1.a == elem2.a
};

foo3.intersection(foo4, check);      /* Returns [{a: 1, b:2}] */

Usage:

var foo1 = [1,3,5,7,9];
var foo2 = [5,9];

foo1.deduct(foo2);      /* Returns [1,3,7] */

var foo3 = [{a: 1, b:2}, {a: 3, b: 4}];
var foo4 = [{a: 1, b:2}];

var check = function(elem1, elem2){     /* elem1 is the array element and elem2 the element of the array we send */
  elem1.a == elem2.a
};

foo3.deduct(foo4, check);      /* Returns [{a: 3, b:4}] */

Usage:

var foo1 = [1,3,5,7,9];
var foo2 = [2,4,5,6,8,9];

foo1.merge(foo2);      /* Returns [1,3,5,7,9,2,4,6,8] */

var foo3 = [{a: 1, b:2}, {a: 3, b: 4}];
var foo4 = [{a: 1, b:2}, {a: 5, b:6}];

var check = function(elem1, elem2){     /* elem1 is the array element and elem2 the element of the array we send */
  elem1.a == elem2.a
};

foo3.merge(foo4, check);      /* Returns [{a: 1, b:2}, {a: 3, b:4}, {a: 5, b:6}] */

Usage:

var aFoo = [1,3,5,7,9];
var sFoo = "hello array";

Array.isArray(aFoo);    /* Returns true */
Array.isArray(sFoo);    /* Returns false */