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

pipe-with

v0.1.5

Published

(type-aware) utility function for defining how a pipeline of functions should be composed

Downloads

10

Readme

pipe-with

Build Status

(type-aware) utility function for defining how a pipeline of functions should be composed

const pipe = pipeWith(fn => ma => ma.then(fn))

const fn = pipe(
  v => Promise.resolve(v + 1),
  v => Promise.resolve(v * 2))

fn(23).then(console.log)  // 48

important note for type definitions

When using this library with flow or typescript, there is a limit of 16 arguments for pipe functions.

api

pipeWith(bindFn)

Takes in a bind function and returns a corresponding pipe function. The pipe function composes the functions passed to it from left to right, but processes the result of each function call using the bind function. The bind function should have a type signature of (a -> m b) -> (m a -> m b).

For example, if we wanted to compose promise-returning functions, bindFn could look like this:

const bind = <A, B>(fn: A => Promise<B>): ((Promise<A>) => Promise<B>) =>
  ma => ma.then(fn)

pipe([...fns])

Composes the given functions from left to right. For e.g. pipe(fn1, fn2)(v) would return the same result as fn2(fn1(v)).

install

You can use this library as the npm package pipe-with:

npm i pipe-with
# or
yarn add pipe-with

It can be used in both es-module-aware and commonjs bundlers/environments.

// es module
import { pipeWith } from 'pipe-with'

// commonjs
const { pipeWith } = require('pipe-with')

It can also be used a <script>:

<script
  crossorigin
  src="https://unpkg.com/pipe-with/dist/umd/pipe-with.js"
></script>

<script>
pipeWith(...)
</script>