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

arraygeous

v0.1.24

Published

A JavaScript library for lightning fast array manipulation.

Downloads

87

Readme

arraygeous

A JavaScript library for lightning fast array manipulation. Build Status

Installation

Web browser

In vanilla, a arr global is exported. You can use the latest version from unpkg.

<script src="https://unpkg.com/[email protected]/build/arraygeous.js"></script>
<script src="https://unpkg.com/[email protected]/build/arraygeous.min.js"></script>

If you'd rather host it yourself, download the latest release from the build directory.

npm

npm i arraygeous -S
const arr = require("arraygeous");

API

arraygeous provides three types of functions.

  • Native JavaScript functions that run faster because arraygeous uses for loops.
  • Special functions that are not included among JavaScript's native array functions.
  • Math functions that perform arithmetic on arrays.

You can also call multiple functions on the same array by using arr.pipe(array). Return the result of the pipe with pipe.result().

Native

# arr.every(array, test) · Source

Returns a boolean representing whether every item in an array passes a test function.

# arr.filter(array, test) · Source

Returns a new array with every element in an array that passes a test, specified as a function.

# arr.find(array, test) · Source

Returns the value of the first element in an array that passes a test, specified as a function.

# arr.findIndex(array, test) · Source

Returns the index of the first element in an array that passes a test, specified as a function. Returns -1 if no element passes the test.

# arr.includes(array, value[, start]) · Source

Returns a boolean representing whether an array includes a value. You can specify where in the array to begin the seach with an optional start index.

# arr.map(array, accessor) · Source

Returns a new array with the result of calling an accessor function for each array element.

# arr.some(array, test) · Source

Returns a boolean representing whether any item in an array passes a test function.

Special

# arr.closest(array, value[, accessor]) · Source

Returns the closest element in an array to a value, ignoring invalid values (null, undefined, NaN, Infinity) in the array. The array can be mapped to an optional accessor function.

# arr.count(array[, accessor]) · Source

Returns an array of objects, where each object represents a unique value from an input array, according to an optional accessor function, and the number of items that value appears in the array.

# arr.flatten(array[, accessor]) · Source

Returns a single array from an array of arrays. You can map each item in the array to the value returned by an optional accessor function.

# arr.random(array) · Source

Returns a random item from an array.

# arr.sort(array[, accessor[, order]]) · Source

Sorts an array. You can map each item in the array to the value returned by an optional accessor function. Defaults to ascending order, but you can return descending order by specifying the third argument, order, as the string "desc". Invalid values other than Infinity and -Infinity (null, undefined, NaN) will be moved to the end.

# arr.unique(array[, accessor]) · Source

Returns the unique values of an array. You can map each item in the array to the value returned by an optional accessor function.

Math

# arr.cor(array[, x, y]) · Source

Returns the correlation coefficient of an array of paired values, where each pair is an array of two values. If your data is an array of objects, you can map each item in the array to a pair of values with optional x- and y-accessor functions.

# arr.cumsum(array[, accessor]) · Source

Returns the iterated cumulative sum of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.deviation(array[, accessor]) · Source

Returns the standard deviation of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.diff(array[, accessor[, lag]]) · Source

Returns lagged and iterated differences of an array of values. You can map each item in the array to a value with an optional accessor function. You can pass a third a third argument, lag, which is an integer indicating how many indices back to calculate the lag

# arr.extent(array[, accessor]) · Source

Returns the minimum and maximum, represented as [minimum, maximum], of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.max(array[, accessor]) · Source

Returns the maximum of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.maxIndex(array[, accessor]) · Source

Returns the index of the maximum of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.mean(array[, accessor]) · Source

Returns the mean of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.meanroll(array, n, [, accessor]) · Source

For each item in an array of values, calculates the trailing rolling average of n items. If the index of the item is less than n, calculates the avereage of the item's value and all previous values. You can map each item in the array to a value with an optional accessor function.

# arr.median(array[, accessor]) · Source

Returns the median of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.min(array[, accessor]) · Source

Returns the minimum of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.minIndex(array[, accessor]) · Source

Returns the index of the minimum of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.mode(array[, accessor]) · Source

Returns the mode or modes, represented as an array of numbers, of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity). If there is no mode, returns undefined.

# arr.sum(array[, accessor]) · Source

Returns the sum of an array. You can map each item in the array to the value returned by an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).

# arr.variance(array[, accessor]) · Source

Returns the variance of an array of values. You can map each item in the array to a value with an optional accessor function. Ignores invalid values (null, undefined, NaN, Infinity).