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

rocket-pipes

v0.11.0

Published

Powerful pipes for TypeScript, that chain Promise and ADT for you

Downloads

18

Readme

Rocket pipes

Powerful pipes for TypeScript, that chain Promise and ADT like Maybe or Either from popular FP libraries.

Features

  • 🍬 Sugar pipes. No worries about promises or ADT itself. Work with resolved values directly.
  • 💡 Type inference. No worries about manual typing work. Types of resolved values inferred automatically.
  • ⛓️ FP libraries friendly. Understand Catamorphism/Foldable libraries.
  • 🖇️ Mix of Promise with FP library. Yes! Catamorphism/Foldable can be included in Promise.
  • 📉 Context. Easy pass context through all pipes.
  • 🚪 Pipeline exit (even nested exit). You can exit from any place of pipeline with result value (it's also have proper type inference 🤘)
  • 🏹 Pipeline replace. You can replace function on pipeline to another on the fly. Useful for mock testing.
  • ➰ AOP. Use beforeAll/afterAll hooks for your pipelines.
  • 🦥 Lazy. Pipeline returns function, that can be used later. It's friendly with Ramda or Sanctuary.

Library support

| Vanilla | Monet | Purify | fp-ts | RxJS / IxJS | |---------|-----------------------|------------------------|-------------------|-------------| | Promise | Either | Either | Either | pipe | | | Maybe | Maybe | Promise<Either> | | | | Validation | EitherAsync | | | | | Promise<Either> | MaybeAsync | | | | | Promise<Maybe> | Promise<Either> | | | | | Promise<Validation> | Promise<Maybe> | | | | | | Promise<EitherAsync> | | | | | | Promise<MaybeAsync> | | |

if you want slim version without libraries support, install slim version npm install rocket-pipes-slim

Examples

Basic
const resp = await p(
  () => 123,
  (n) => n + 1
)();
expect(resp + 1).toEqual(125);
Context
const resp = await p(
  () => 123,
  pc((ctx: {n: number}) => n => n + ctx.n),
  n => n + 1
).context({n: 1})();
expect(resp + 1).toEqual(126);
Exit pipeline
const resp = await p(
  () => 123,
  (n) => ep(n + 1),
  (n) => "qwe"
)();
iep(resp) && expect(resp.r + 1).toEqual(125);
Replace pipeline
const fn = p(
  () => 123,
  (n) => n + 1
);
const resp = await fn.replace([[0, () => 124]])();
expect(resp + 1).toEqual(126);

fn.replaceUndo();
expect(await fn()).toEqual(125);
AOP beforeAll/afterAll hooks
beforeAll((label, n) => {
  expect(label).toEqual("(n) => n + 1\n(n) => n + 1");
  expect(n).toEqual(123);
});
afterAll((label, n) => {
  expect(label).toEqual("(n) => n + 1\n(n) => n + 1");
  expect(n).toEqual(125);
});
p(
  (n: number) => n + 1,
  (n) => n + 1
)(123);
AOP clear hooks
clearAfterAll();
clearBeforeAll();
Promise basic
const resp = await p(
  () => Promise.resolve(123),
  (n) => n + 1
)();
expect(resp + 1).toEqual(125);
Either right
const resp = await p(
  () => Either.right(123),
  (n) => n + 1
)();
expect(resp + 1).toEqual(125);
Promise can include anything supported
const resp = await p(
  () => Promise.resolve(Either.right(123)),
  (n) => n + 1
)();
expect(resp + 1).toEqual(125);
Either left
const resp = await p(
  () => Either.left(123),
  (_, l) => l + 1
)();
expect(resp + 1).toEqual(125);
Maybe some
const resp = await p(
  () => Maybe.some(123),
  (n) => n + 1
)();
expect(resp + 1).toEqual(125);
Maybe none
const resp = await p(
  () => Maybe.none(),
  (s, n) => s || n
)();
expect(resp).toEqual(void 0);
Validation success
const resp = await p(
  () => Validation.success(123),
  (n) => n + 1
)();
expect(resp + 1).toEqual(125);
Validation fail
const resp = await p(
  () => Validation.fail(123),
  (_, l) => l + 1
)();
expect(resp + 1).toEqual(125);