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

lazyer

v0.2.1

Published

Lazy iteration in JavaScript.

Downloads

5

Readme

Lazyer

Lazy iteration in JavaScript.
Based heavily on the Rust iterator trait.

Overview

Lazyer allows for lazy iteration.
It can be used for working with finite sequences:

const lazy = require('lazyer');
lazy.from(people)
    .filter(person => person.age >= 65)
    .map(person => `${person.firstName} ${person.lastName}`)
    .map(name => name.toUpperCase())
    .forEach(name => console.log(name));

And infinite sequences:

const lazy = require('lazyer');

lazy.range()
    .scan(([a, b]) => [b, a + b], [0, 1])
    .map(([a]) => a)
    .take(10)
    .collect();
→ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

Works with anything iterable:

const lazy = require('lazyer');
const string = 'Hello World!';
const set = new Set(string);

lazy.range(0)
    .zip(set)
    .collectMap()
→ Map {
    0 => 'H',
    1 => 'e',
    2 => 'l',
    3 => 'o',
    4 => ' ',
    5 => 'W',
    6 => 'r',
    7 => 'd',
    8 => '!'
}

And does a bunch of useful things:

const lazy = require('lazyer');
const longest = lazy.from(listOfListOfNodes)
    .flat()
    .flatMap(node => node.children)
    .max(node => node.data.length);

Functions

Functions that create a lazy iterator.

  • from
  • of
  • range
  • repeat
  • repeatWith
  • iterate

Adaptors

Methods that adapt the iterator.
A consumer needs to be called before any of these will be executed.

  • stepBy
  • skip
  • take
  • skipWhile
  • takeWhile
  • chunk
  • enumerate
  • concat
  • cycle
  • map
  • filter
  • scan
  • zip
  • flat
  • flatMap
  • join
  • joinWith
  • each

Consumers

Methods that consume the iterator.
These methods start the iteration.

  • next
  • peek
  • at
  • count
  • last
  • forEach
  • reduce
  • sum
  • product
  • find
  • findIndex
  • includes
  • every
  • some
  • max
  • min
  • maxBy
  • minBy
  • collect
  • partition
  • unzip
  • group
  • categorize
  • clone
  • cloneMany

Docs

See the documented source code.
And for examples, see the test file.