All Projects → a-synchronous → Rubico

a-synchronous / Rubico

Licence: mit
[a]synchronous functional programming

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Rubico

Metasync
Asynchronous Programming Library for JavaScript & Node.js
Stars: ✭ 164 (+23.31%)
Mutual labels:  async, asynchronous, promise, parallel, series
P Map
Map over promises concurrently
Stars: ✭ 639 (+380.45%)
Mutual labels:  async, promise, parallel, async-await
Fun Task
Abstraction for managing asynchronous code in JS
Stars: ✭ 363 (+172.93%)
Mutual labels:  monad, async, promise, functional-programming
Thunks
A small and magical composer for all JavaScript asynchronous.
Stars: ✭ 523 (+293.23%)
Mutual labels:  asynchronous, promise, async-await, generator
Fluture
🦋 Fantasy Land compliant (monadic) alternative to Promises
Stars: ✭ 2,249 (+1590.98%)
Mutual labels:  monad, async, promise, functional-programming
Bach
Compose your async functions with elegance.
Stars: ✭ 117 (-12.03%)
Mutual labels:  async, promise, parallel, series
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (+8.27%)
Mutual labels:  async, asynchronous, promise, concurrent
do
Simplest way to manage asynchronicity
Stars: ✭ 33 (-75.19%)
Mutual labels:  asynchronous, promise, parallel, series
Flowa
🔥Service level control flow for Node.js
Stars: ✭ 66 (-50.38%)
Mutual labels:  async, promise, parallel, series
Recoil
Asynchronous coroutines for PHP 7.
Stars: ✭ 765 (+475.19%)
Mutual labels:  async, asynchronous, generator
Then
🎬 Tame async code with battle-tested promises
Stars: ✭ 908 (+582.71%)
Mutual labels:  async, promise, async-await
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-15.79%)
Mutual labels:  async, asynchronous, async-await
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+418.8%)
Mutual labels:  async, asynchronous, async-await
Vue Loadable
⏳ Improve your loading state control with pretty simple methods and helpers.
Stars: ✭ 23 (-82.71%)
Mutual labels:  async, asynchronous, promise
Posterus
Composable async primitives with cancelation, control over scheduling, and coroutines. Superior replacement for JS Promises.
Stars: ✭ 536 (+303.01%)
Mutual labels:  async, promise, async-await
Before After Hook
wrap methods with before/after hooks
Stars: ✭ 49 (-63.16%)
Mutual labels:  async, asynchronous, promise
Ea Async
EA Async implements async-await methods in the JVM.
Stars: ✭ 1,085 (+715.79%)
Mutual labels:  async, asynchronous, async-await
Parallel Ssh
Asynchronous parallel SSH client library.
Stars: ✭ 864 (+549.62%)
Mutual labels:  async, asynchronous, parallel
Async Backplane
Simple, Erlang-inspired fault-tolerance framework for Rust Futures.
Stars: ✭ 113 (-15.04%)
Mutual labels:  async, asynchronous, async-await
Cyclops
An advanced, but easy to use, platform for writing functional applications in Java 8.
Stars: ✭ 1,180 (+787.22%)
Mutual labels:  monad, asynchronous, functional-programming

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 (~7.0 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

<!-- development -->
<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>

<!-- production -->
<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 via ES (JavaScript) Modules

// development
import rubico from 'https://unpkg.com/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'

// production
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'

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-eight operators for async-enabled functional programming in JavaScript.

const {
  pipe, tap,
  switchCase, tryCatch,
  fork, assign, get, 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 }

For different but semanticaly related functionality, Rubico exposes additional methods as property functions. For example,

  • 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 advanced functions, please visit rubico/x. You can find the full method documentation at rubico.land/docs.

Further Reading

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, please announce on the issue thread that you will work on it.

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: 10.3
  • minimum Chrome version: 63
  • minimum Firefox version: 57
  • minimum Edge version: 79
  • minimum Safari version: 11.1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].