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

op-array

v2.2.0

Published

Adding extra functions to the JavaScript Array

Downloads

393

Readme

op-array

Maintainability codecov License: MIT

A small, tree-shakable, functional utility library that fills the gaps in JavaScript's built-in Array API. Written in TypeScript, ships ESM + CJS builds with first-class type definitions.

v2 is a complete rewrite. v1 mutated Array.prototype. v2 ships only standalone functions. See CHANGELOG.md for the migration guide.

Installation

npm install op-array

Usage

import { sum, unique, findBy } from 'op-array';

sum([1, 2, 3]);                     // 6
unique([1, 2, 2, 3]);               // [1, 2, 3]
findBy(users, 'profile.email', x);  // first matching user

Or import a single category as a subpath:

import { min, max, average, median } from 'op-array/numerical';

Subpaths available: op-array/collections, op-array/logical, op-array/numerical, op-array/positional, op-array/transformations.

Conventions

Any function that takes a key: string argument (findBy, where, pluck, keyBy, groupBy, countBy, uniqueBy, …) resolves it as a dot-delimited path through the nested object — the same semantics as findBy(arr, 'profile.email', 'a@x'). Missing segments resolve to undefined. There is no callback overload; this single, consistent way to address fields is intentional.

Limitation: extract currently accepts only top-level keys (keyof T) for type-safety reasons. Adding dot-path support would change its return type and is therefore deferred to v3. Use pluck for single-field projection if you need nested access today.

API overview

| Category | Functions | |---|---| | Collections | findBy, findById, where, extract, pluck, keyBy, groupBy, countBy | | Logical | intersection, except, union, exists, existsAll, existsAny, equals, symmetricDifference, isSubset, isSuperset, isDisjoint | | Numerical | min, max, sum, subtract, product, average, hasEvenLength, median, mode, range, variance, standardDeviation, quantile, cumulativeSum, minBy, maxBy, sumBy, averageBy | | Positional | first, second, third, last | | Transformations | unique, uniqueBy, flat, inGroups, inGroupsOf, occurrences, compact, compactNullish |

For details and examples see the per-category docs:

Migrating from v1

v1 patched Array.prototype. v2 exports plain functions taking the array as the first argument.

| v1 | v2 | |---|---| | import 'op-array/dist/numerical' then [1,2].sum() | import { sum } from 'op-array' then sum([1, 2]) | | arr.findBy('id', 1) | findBy(arr, 'id', 1) | | arr.first | first(arr) | | arr.subtraction() | subtract(arr) | | arr.isEvenLength() | hasEvenLength(arr) | | arr.exists([1, 2]) | existsAll(arr, [1, 2]) |

Development

This project uses mise for tool versioning and npm for packages.

mise install      # installs Node 22
npm install
npm test          # vitest with coverage
npm run lint
npm run typecheck
npm run build     # tsup -> dist/

Releasing

Releases are triggered by closing a GitHub milestone named vMAJOR.MINOR (e.g. v2.1). The release workflow then:

  1. Verifies every issue and PR in the milestone is closed/merged and the full quality gate passes.
  2. Opens a chore(release): MAJOR.MINOR.0 PR that bumps package.json and date-stamps the matching CHANGELOG.md heading. Auto-merge is enabled.
  3. On PR merge, tags vMAJOR.MINOR.0 and publishes to npm with provenance, then creates a GitHub Release with notes auto-generated from the milestone's merged PRs.

Authentication to npm uses npm Trusted Publishing (OIDC) — there is no long-lived NPM_TOKEN in the repo. The publish job runs inside the npm-publish GitHub Environment, which is restricted to the main branch and (optionally) gated on a manual approval. The matching Trusted Publisher is registered on npmjs.com against the publish-on-tag.yml workflow with environment npm-publish.

See .github/workflows/release.yml, tag-on-release-merge.yml, and publish-on-tag.yml.

License

MIT — see LICENSE.