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

array-extension-js

v1.0.1

Published

Array extensions to create new array elements, iterate the collection and return the array itself and methods to return a single value.

Readme

Array extension.

Array extension to create new array elements, iterate the collection and return the array itself and methods to return a single value.

Get started.

Installation

This guide will help you to install the array extension in your project.

Firstly, you need to go to the project path and open a new terminal and do the next (choose the best option for you):

As a global npm package.

npm i array-extension-js -g

As a local npm package.

npm i --save array-extension-js 

Then, you're going to add the next code in your index file:

require('array-extension-js')

And...your project is ready to use this extension!


Features

Array methods

each(callback).

This method iterates over the array elements and executes the callback function.

Sintax: array.each(callback)

Params: callback function that sends two arguments: item and index.

Implementation example: each.js


where(spec).

This method creates a new array that contains all the elements that satisfies the given specification.

Sintax: array.where(spec)

Params: spec is a callback function that will decide if the element shall or not to be included in the new list.

Implementation example: where.js


any(spec).

This method shall return a true value if any of the elements in the array satisfies the given spec.

Sintax: array.any(spec)

Params: spec is a function then it shall be called for each element in the array. If the spec parameter is not a function object, then it will be tested against each element of the array.

Implementation example: any.js


select(spec).

Creates a new collection containing the elements returned by the spec function. It allows to make an excerpt of the collection, it would be useful to hide information.

Syntax: array.select(spec)

Params:spec is a callback function that takes element & index as arguments, and returns the desired part of the element to form a new array.

Implementation example: select.js


take(howMany, spec).

This method returns a new array containing ideally howMany elements.

Syntax: array.take(howMany, spec) or array.take(howMany)

Params: spec argument defines the criteria, this method will use to fill up the new array (if there is no spec argument then it shall take just the first howMany elements in the collection).

Implementation example: take.js


skip(howMany).

This method produces a new Array which will not include the first howMany elements.

Syntax: array.skip(howMany)

Params: howMany argument defines the first elements to not include in the new array.

Implementation example: skip.js


first(spec).

This method returns the first element on collection that satisfies the specification, if there is no specification then it will return the very first array’s element.

Syntax: array.first(spec)

Params: specargument defines the criteria to get an element.

Implementation example: first.js


last(spec).

This method returns the last collection’s element that satisfies the given specification, if there is no specification then will return just the last element.

Syntax: array.last(spec)

Params: specargument defines the criteria to get an element.

Implementation example: last.js


count(spec).

This method returns the number of elements on the collection that satisfies the specification, if no specification is present then it will return just the array’s length property.

Syntax: array.count(spec)

Params: specargument defines the criteria to count an element.

Implementation example: count.js


index(spec).

This method returns the zero based position in the array of the element that satisfies the specification.

Syntax: array.index(spec)

Params: specargument defines the criteria to get the element index.

Implementation example: index.js


pluck(property)

This method retrieves the given property of each element in the array and return a new array containing that property values.

Syntax: array.pluck(property)

Params: property argument defines the property to get elements.

Implementation example: pluck.js


sum(spec).

This method returns the summatory of the result of executing the spec function on each array’s element.

Syntax: array.sum(spec)

Params: spec argument is the criteria to do the summatory, if there is not spec function then it will return the summatory of the array’s elements.

Implementation example: sum.js


max(comparer).

This method finds and return the maximum value on the collection.

Syntax: array.max(comparer)

Params: comparer argument should be a function that receives 2 parameters, valueA and valueB and shall return a negative number for valueA < valueB scenario, zero when valueA === valueB and finally a positive number when valueA > valueB. If not comparer is specified then it will try to evaluate the array elements as if they are numbers.

Implementation example: max.js


min(comparer).

This method finds and return the smallest value on the collection.

Syntax: array.min(comparer)

Params: comparer argument should be a function that receives 2 parameters, valueA and valueB and shall return a negative number for valueA < valueB scenario, zero when valueA === valueB and finally a positive number when valueA > valueB. If not comparer is specified then it will try to evaluate the array elements as if they are numbers.

Implementation example: min.js


flatten().

This method returns a new flat array.

Syntax: array.flatten()

Implementation example: flatten.js