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

interlude

v2.0.0

Published

Functional JavaScript library

Downloads

8,114

Readme

Interlude

npm status build status dependency status coverage status

Interlude is a functional ES6 based JavaScript library inspired by Haskell. It's aims to simplify and abstract common patterns by providing a set of common higher order functions.

Usage

Use it with qualified imports with the yet unfinished module import syntax or attach it to the short variable of choice. For selling points, here's how it will look with ES7 modules.

import { range, pow, times, all, eq, comparing, zipWith, zipWith3, iterate, gcd, uniqueBy, iterate, interval } from 'interlude'

range(5).map(pow(2));
// [ 1, 4, 9, 16, 25 ]

var nested = [ [ 1, 3, 2 ], [ 2, 2 ], [ 1, 4, 2, 3 ] ];
nested.filter(all(eq(2)));
// [ [2, 2] ]

// outer sort by property
nested.sort(comparing('length'));
// [ [ 2, 2 ], [ 1, 3, 2 ], [ 1, 4, 2, 3 ] ]

zipWith3((x, y, z) => x + y + z, [1,1,1,1,1], range(5), [1,0,0]);
// [ 3, 3, 4 ]

// Powers of two
iterate(8, 2, times(2));
// [ 2, 4, 8, 16, 32, 64, 128, 256 ]

// Pascal's Triangle
var pascalNext = (row) => zipWith((x, y) => x + y, row.concat(0), [0].concat(row));

iterate(6, [1], pascalNext);
// [ [ 1 ],
//   [ 1, 1 ],
//   [ 1, 2, 1 ],
//   [ 1, 3, 3, 1 ],
//   [ 1, 4, 6, 4, 1 ],
//   [ 1, 5, 10, 10, 5, 1 ] ]

// Prime numbers
var notCoprime = (x, y) => gcd(x, y) > 1;
uniqueBy(notCoprime, interval(2, 20));
// [ 2, 3, 5, 7, 11, 13, 17, 19 ]

Interlude is merely a stable front for three re-exported modules:

interlude
├─── autonomy
├─── operators
└─── subset

These modules are of course requirable by themselves, and we encourage you to require them directly. The submodules are small (<150 lines each) and focused.

Regardless, you should read their short and independent APIs:

Additionally, two extra modules (which were not included in interlude due to their smaller likelihood of use) are also good fits. They do not overlap in API, and are highly recommended when needed. You may wish to read their short APIs as well.

Installation

$ npm install interlude

License

MIT-Licensed. See LICENSE file for details.