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

claimyr-rubico

v1.9.3

Published

[a]synchronous functional programming

Downloads

8

Readme

rubico

rubico

a shallow river in northeastern Italy, just south of Ravenna

Node.js CI codecov npm version License: MIT Gitter

[a]synchronous functional programming

const { pipe, map, filter } = rubico

const isOdd = number => number % 2 == 1

const asyncSquare = async number => number ** 2

const squaredOdds = pipe([
  filter(isOdd),
  map(asyncSquare),
])

squaredOdds([1, 2, 3, 4, 5]).then(console.log) // [1, 9, 25]

Installation

Core build (~6.1 kB minified and gzipped)

with npm

npm i rubico

require rubico in Node.js

const rubico = require('rubico')
const pipe = require('rubico/pipe')
const tap = require('rubico/tap')
const defaultsDeep = require('rubico/x/defaultsDeep')

import rubico globally

<script src="https://unpkg.com/rubico"></script>
<script src="https://unpkg.com/rubico/dist/pipe.js"></script>
<script src="https://unpkg.com/rubico/dist/tap.js"></script>
<script src="https://unpkg.com/rubico/dist/x/defaultsDeep.js"></script>
<script>
console.log(rubico) // { pipe, tap, ... }
console.log(pipe) // [Function: pipe]
console.log(tap) // [Function: tap]
console.log(defaultsDeep) // [Function: defaultsDeep]
</script>

<!-- minified -->
<script src="https://unpkg.com/rubico/dist/rubico.min.js"></script>
<script src="https://unpkg.com/rubico/dist/pipe.min.js"></script>
<script src="https://unpkg.com/rubico/dist/tap.min.js"></script>
<script src="https://unpkg.com/rubico/dist/x/defaultsDeep.min.js"></script>
<script>
console.log(rubico) // { pipe, tap, ... }
console.log(pipe) // [Function: pipe]
console.log(tap) // [Function: tap]
console.log(defaultsDeep) // [Function: defaultsDeep]
</script>

import rubico in the browser via ES (JavaScript) Modules

import rubico from 'https://unpkg.com/rubico/dist/rubico.es.js'
import pipe from 'https://unpkg.com/rubico/dist/pipe.es.js'
import tap from 'https://unpkg.com/rubico/dist/tap.es.js'
import defaultsDeep from 'https://unpkg.com/rubico/dist/x/defaultsDeep.es.js'

// minified
import rubico from 'https://unpkg.com/rubico/dist/rubico.es.min.js'
import pipe from 'https://unpkg.com/rubico/dist/pipe.es.min.js'
import tap from 'https://unpkg.com/rubico/dist/tap.es.min.js'
import defaultsDeep from 'https://unpkg.com/rubico/dist/x/defaultsDeep.es.min.js'

import rubico as ESM in Node 16 and up

import rubico from 'rubico/dist/rubico.mjs'
import pipe from 'rubico/dist/pipe.mjs'
import tap from 'rubico/dist/tap.mjs'
import defaultsDeep from 'rubico/dist/x/defaultsDeep.mjs'

// minified
import rubico from 'rubico/dist/rubico.min.mjs'
import pipe from 'rubico/dist/pipe.min.mjs'
import tap from 'rubico/dist/tap.min.mjs'
import defaultsDeep from 'rubico/dist/x/defaultsDeep.min.mjs'

Motivation

A note from the author

At a certain point in my career, I grew frustrated with the entanglement of my own code. While looking for something better, I found functional programming. I was excited by the idea of functional composition, but disillusioned by the redundancy of effectful types. I started Rubico to capitalize on the prior while rebuking the latter. Many iterations since then, the library has grown into something I personally enjoy using, and continue to use to this day.

Rubico is founded on the following principles:

  • asynchronous code should be simple
  • functional style should not care about async
  • functional transformations should be composable, performant, and simple to express

When you import this library, you obtain the freedom that comes from having those three points fulfilled. The result is something you may enjoy.

Introduction

Rubico is a module of twenty-nine operators for async-enabled functional programming in JavaScript.

const {
  pipe, tap,
  switchCase, tryCatch,
  fork, assign, get, set, pick, omit,
  map, filter, reduce, transform, flatMap,
  and, or, not, any, all,
  eq, gt, lt, gte, lte,
  thunkify, always,
  curry, __,
} = rubico

These operators act sensibly on a wide range of vanilla JavaScript types to create declarative, extensible, and async-enabled function compositions.

const { pipe, map } = rubico

const toTodosUrl = id => `https://jsonplaceholder.typicode.com/todos/${id}`

const logTodoByID = pipe([ // fetch a Todo and log it
  toTodosUrl,
  fetch,
  response => response.json(),
  console.log,
])

const todoIDs = [1, 2, 3, 4, 5]

map(logTodoByID)(todoIDs) // fetch Todos per id of TodoIDs and log them
// { userId: 1, id: 4, title: 'et porro tempora', completed: true }
// { userId: 1, id: 1, title: 'delectus aut autem', completed: false }
// { userId: 1, id: 3, title: 'fugiat veniam minus', completed: false }
// { userId: 1, id: 2, title: 'quis ut nam facilis...', completed: false }
// { userId: 1, id: 5, title: 'laboriosam mollitia...', completed: false }

// same as above but with limited concurrency
// map.pool(2, logTodoByID)(todoIDs)

For advanced asynchronous use cases, check out some of Rubico's property functions:

  • map - apply a mapper function concurrently
  • map.pool - apply a mapper function concurrently with a concurrency limit
  • map.series - apply a mapper function serially

For even more advanced functions, please visit rubico/x. You can find the full method documentation at rubico.land/docs.

Contributing

Your feedback and contributions are welcome. If you have a suggestion, please raise an issue. Prior to that, please search through the issues first in case your suggestion has been made already. If you decide to work on an issue, or feel like taking initiative and contributing anything at all, feel free to create a pull request and I will get back to you shortly.

Pull requests should provide some basic context and link the relevant issue. Here is an example pull request. If you are interested in contributing, the help wanted tag is a good place to start.

License

Rubico is MIT Licensed.

Support

  • minimum Node.js version: 12
  • minimum Chrome version: 63
  • minimum Firefox version: 57
  • minimum Edge version: 79
  • minimum Safari version: 11.1