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

better-arrays.js

v1.0.7

Published

More array tools for JavaScript

Readme

better-arrays.js

Better-arrays.js is a library to improve working with arrays in JavaScript and TypeScript.

Set-Up:

Install the module with npm i better-arrays.js. Use it in JavaScript with

require("better-arrays.js"); //ES6 or
require("better-arrays.js/ES5/"); //ES5

The library is written in TypeScript and can be used with

import "better-arrays.js"; //or
import "better-arrays.js/ts/" //to directly include the TypeScript files

Functions:

Array.selectRandom(n?: number)

The Array.selectRandom method selects n random elements out of an array and returns them as a new array, the default is 1.

Array.selectOneItem(minIndex?: number, maxIndex?: number)

This functions returns one random item out of the array as an object. The optional parameters minIndex defines a starting index for the method to search, while the optional parameter maxIndex defines an ending index.

Array.deepcopy()

Returns a new array which is a deep copy of the old one.

Array.shallowCopy()

Returns a new array which is a shallow copy of the old one.

Array.toStringArray()

Returns a new array in which all elements have been parsed to strings.

Array.toFloatArray(includeNaNs?: boolean)

Returns a new array in which all elements have been parsed to floats. The parameter includeNaNs specifies whether NaN values should be kept in the Array or not, default is false.

Array.toIntArray(includeNaNs?: boolean)

Returns a new array in which all elements have been parsed to integers. The parameter includeNaNs specifies whether NaN values should be kept in the Array or not, default is false.

Array.sortNumeric()

Sorts all values in the array numeric ascending.

Array.delete(item: T)

Deletes every instance of the given item out of the array wihtout chaning the indices of the other items.

Array.replace(oldItem: T, newItem: T)

Replaces all instances of oldItem with newItem.