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

@njlr/seq

v3.8.2

Published

A simple library for manipulating generators and arrays in JavaScript.

Downloads

86

Readme

seq

A simple library for manipulating generators and arrays in JavaScript.

Travis

Get Started

Install using Yarn:

yarn add @njlr/seq

Install using NPM:

npm install --save @njlr/seq

You can browse the documentation on GitHub.

Why? 🤔

  • Some of the built-in Array functions are mutating (e.g. Array.prototype.sort).
  • Many array functions are missing. Where is Array.prototype.flatMap?
  • A chain of array functions creates a new array at every stage: the operations are not lazy.
  • lodash and friends require either a wrapper object or binding for chaining calls. We use the pipeline operator (|>) to achieve this at compile-time!
  • This package is a good citizen. It has no dependencies and does not mutate any global objects.
  • The code is simple. You can review the whole thing in about an hour.

Demo

import * as seq from '@njlr/seq';

const xs = [ 1, 5, 1, 2, 7, 3, 3, 4, 5, 0 ] 
  |> seq.unique()
  |> seq.map(x => x * 2)
  |> seq.filter(x => x > 4)
  |> seq.sorted()
  |> seq.toArray;

// xs is [ 6, 8, 10, 14 ]

Since seq works on iterables, you can also use for...of loops:

import * as seq from '@njlr/seq';

for (const x of seq.range(10) |> seq.map(x => x * x)) {
  console.log(x);
}

This library also plays nicely with spread syntax!

const squares = [ ... seq.range(10) |> seq.map(x => x * x) ];

Development

Dependencies are managed by Yarn:

yarn install --pure-lockfile

To run all tests:

yarn test

To build the library:

yarn build

To build the documentation:

yarn docs

To release a new version:

npm publish --access public