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

metho-array

v1.1.0

Published

JavaScript Array prototype extensions using Metho

Readme

Metho Array

Array prototype extensions using the Metho library:

Usage

import { chunk, pieces, reverse, head, tail, sum, product, join, first, last, min, max } from 'metho-array'

// chunk (if already imported from metho-string, it will also work with arrays)
[1, 2, 3, 4, 5, 6][chunk(2)] // [[1, 2], [3, 4], [5, 6]]
[1, 2, 3, 4, 5][chunk(3)] // [[1, 2, 3], [4, 5]]

// pieces (if already imported from metho-string, it will also work with arrays)
// > balanced - attempt to balance the number of items in each piece
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1][pieces(4)] // [[1, 1, 1], [1, 1, 1], [1, 1], [1, 1]]
// > not balanced
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1][pieces(4, false)] // [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1]]

// reverse (if already imported from metho-string, it will also work with arrays) - does not mutate original array
[1, 2, 3][reverse] // [3, 2, 1]

// head (if already imported from metho-string, it will also work with arrays)
[1, 2, 3, 4][head] // 1

// tail (if already imported from metho-string, it will also work with arrays)
[1, 2, 3, 4][tail] // [2, 3, 4]

// sum - sum the items in array (will behave like 'join' if any item is a string)
[1, 3, 5][sum] // 9
[1, '3', 5][sum] // '135'

// product - product of all items in array
[1, 3, 5][product] // 15

// join - join all items (as strings) in array, with optional separator
['a', 1, 'b'][join] // 'a1b'
['a', 1, 'b'][join('--')] // 'a--1--b'

// first - return the first element in the array, or the first n elements as an array
['a', 'b', 'c'][first] // 'a'
['a', 'b', 'c'][first(1)] // ['a']
['a', 'b', 'c'][first(2)] // ['a', 'b']

// last - return the last element in the array, or the last n elements as an array
['a', 'b', 'c'][last] // 'c'
['a', 'b', 'c'][last(1)] // ['c']
['a', 'b', 'c'][last(2)] // ['b', 'c']

// min - return the minimum number (using Math.min), the minimum from sorting with .sort(), or
// the minimum from sorting with the given comparison function
[4, 11, 3][min] // 3
[4, 11, 3][min(false)] // 11
['dog', 'ant', 'cat'][min(false)] // 'ant'
[{a:31}, {a:2}, {a:5}][min((i,j) => i.a-j.a)] // {a:2}

// max - return the maximum number (using Math.max), the maximum from sorting with .sort(), or
// the maximum from sorting with the given comparison function
[4, 11, 3][max] // 11
[4, 11, 3][max(false)] // 4
['dog', 'ant', 'cat'][max(false)] // 'dog'
[{a:31}, {a:2}, {a:5}][max((i,j) => i.a-j.a)] // {a:31}

// shuffle - return a shuffled version of the array
[1, 2, 3][shuffle] // [2, 1, 3]
[1, 2, 3][shuffle] // [3, 2, 1]

// sample - return a random sample of the array (pass nothing for a random element, or sample size for a sample array)
[1, 2, 3, 4][sample] // 4
[1, 2, 3, 4][sample(1)] // [2]
[1, 2, 3, 4][sample(3)] // [4, 1, 3]