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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@letele/ecmascripts

v0.1.3

Published

A collection of ES6 array modules.

Downloads

11

Readme

ecmascripts

A collection of ES6 array modules.

Array modules

// Creates a cartesian product, from an array of the form [Array, Array].
import {cartesian} from "@letele/ecmascripts"

cartesian([['a','b'],[1,2]])
// output: [ [ 'a', 1 ], [ 'a', 2 ], [ 'b', 1 ], [ 'b', 2 ] ]
// From a given key of an Object, it returns a collection of values of the given key.
import {keyArray} from "@letele/ecmascripts"

const candidates = [
    {name:'John', surname:'Doe'},{name:'Jane', surname:'Smith'},
    {name:'Foo', surname:'Bar'},{name:'Hello', surname:'World'}
]
keyArray(candidates,'name')
// output: [ 'John', 'Jane', 'Foo', 'Hello' ]
// Returns a randomly selected element from a given array.
import {randomElement} from "@letele/ecmascripts"

randomElement([1,undefined,'er',false])
// output: false
// Creates an array of randomly selected elements from a given array.
import {randomElements} from "@letele/ecmascripts"

randomElements([12,true,'a',2,3,'string'],4)
// output: [ 12, 'string', true, 2 ]
// Creates an array of numbers between low and high in steps of step.
import {range} from "@letele/ecmascripts"

range(-10,10,5)
// output: [ -10, -5, 0, 5, 10 ]

// For inexact floating point values, call a map method to transform inexact values.
range(-0.5,0,0.1)
// output: [ -0.5, -0.4, -0.3, -0.19999999999999996, -0.09999999999999998, 0 ]
range(-0.5,0,0.1).map(i => Number(i.toFixed(2)))
// output: [ -0.5, -0.4, -0.3, -0.2, -0.1, 0 ]
// Shuffles an array: randomly positions elements in an array.
import {shuffleArray} from "@letele/ecmascripts"

shuffleArray(['J','o','h','n', 'D', 'o', 'e'])
// output: ['h', 'o', 'e','J', 'D', 'o','n']
// Orders numbers in an array in ascending or descending order.
import {sortNumbers} from "@letele/ecmascripts"

sortNumbers([3,1,2,5,4])
// output: [ 1, 2, 3, 4, 5 ]
sortNumbers([3,1,2,5,4],true)
// output: [ 5, 4, 3, 2, 1 ]
// Orders strings in an array in ascending or descending order.
import {sortStrings} from "@letele/ecmascripts"

sortStrings(['b','c','a','Y','Z','X'])
// output: [ 'X', 'Y', 'Z', 'a', 'b', 'c' ]

// Note that sort does a case-sensitive comparison.
// Meaning capital letters take precedence over small letters. 
// Call a map method from output then a sort method for desired result. 
sortStrings(['b','c','a','Y','Z','X'].map(i => i.toUpperCase()))
// output: [ 'A', 'B', 'C', 'X', 'Y', 'Z' ]
sortStrings(['b','c','a','Y','Z','X'].map(i => i.toLowerCase()))
// output: [ 'a', 'b', 'c', 'x', 'y', 'z' ]
sortStrings(['b','c','a','Y','Z','X'].map(i => i.toLowerCase()),true)
// output: [ 'z', 'y', 'x', 'c', 'b', 'a' ]
// Creates from a given array,  chunks of arrays with n elements each.
// Size of last array has size less than n but greater than 0.
import {splitArray} from "@letele/ecmascripts"

splitArray([1,2,3,4,5,6,7,8,9,10],3)
// output: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10 ] ]
// Sums up numbers in an array and returns their sum.
import {sumNumbers} from "@letele/ecmascripts"

sumNumbers([0,0,1,0,1,1,0])
// output: 3