All Projects → ide → Mux

ide / Mux

Licence: mit
Creates a promise that waits for the promises in nested data structures and resolves to data structures of the same form. It recursively traverses the input data structure and multiplexes its promises.

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Mux

Form Validation.js
The most customizable validation framework for JavaScript.
Stars: ✭ 127 (-16.99%)
Mutual labels:  promise
Fe Interview
😃 每日一道经典前端面试题,一起共同成长。
Stars: ✭ 134 (-12.42%)
Mutual labels:  promise
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-6.54%)
Mutual labels:  promise
Kitchen Async
A Promise library for ClojureScript, or a poor man's core.async
Stars: ✭ 128 (-16.34%)
Mutual labels:  promise
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (-13.07%)
Mutual labels:  promise
Poloniex Api Node
Poloniex API client for REST and WebSocket API
Stars: ✭ 138 (-9.8%)
Mutual labels:  promise
Easysoap
A simple to use SoapClient for Node.js
Stars: ✭ 122 (-20.26%)
Mutual labels:  promise
Vue Prom
Vue promise wrapper component
Stars: ✭ 148 (-3.27%)
Mutual labels:  promise
Sieppari
Small, fast, and complete interceptor library for Clojure/Script
Stars: ✭ 133 (-13.07%)
Mutual labels:  promise
Functional Promises
Write code like a story w/ a powerful Fluent (function chaining) API
Stars: ✭ 141 (-7.84%)
Mutual labels:  promise
Image Promise
🎑🤞 Load one or more images, return a promise. Tiny, browser-only, no dependencies.
Stars: ✭ 129 (-15.69%)
Mutual labels:  promise
Node Stratum
Stratum protocol server and client for Node.js
Stars: ✭ 129 (-15.69%)
Mutual labels:  promise
Jstransformer
Normalize the API of any JSTransformer.
Stars: ✭ 139 (-9.15%)
Mutual labels:  promise
Tas
Make it easy to develop large, complex Node.js app.
Stars: ✭ 128 (-16.34%)
Mutual labels:  promise
Qtpromise
Promises/A+ implementation for Qt/C++
Stars: ✭ 137 (-10.46%)
Mutual labels:  promise
Notes
前端学习笔记,面试复习手册
Stars: ✭ 127 (-16.99%)
Mutual labels:  promise
Toolkit
Collection of useful patterns
Stars: ✭ 137 (-10.46%)
Mutual labels:  promise
Promise
Promise / Future library for Go
Stars: ✭ 149 (-2.61%)
Mutual labels:  promise
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (-5.88%)
Mutual labels:  promise
Pq
Human Readable Promise Chains
Stars: ✭ 140 (-8.5%)
Mutual labels:  promise

mux Tests codecov

A simple and convenient function that resolves promises in data structures like arrays, objects, Maps, and Sets

What is mux?

Mux is a function that multiplexes promises in nested data structures and resolves them like this:

await mux({
  a: asyncFunction1(),
  b: asyncFunction2(),
});

// Result:
{
  a: result1,
  b: result2,
}

Installing mux

yarn add @expo/mux

And import it like this:

import mux from '@expo/mux';

More examples

You can also pass in deeply nested data structures like this:

await mux({
  a: {
    b: asyncFunction1(),
  },
});

// Result:
{
  a: {
    b: result1,
  },
}

Mux supports several standard JavaScript data structures:

await mux(new Set([
  asyncFunction1(),
  asyncFunction2(),
]));

// Result:
new Set([
  result1,
  result2,
])

And if your promises themselves result in data structures, mux will recurse into them and resolve the nested promises.

await mux([
  Promise.resolve({
    a: asyncFunction1(),
  }),
]);

// Result:
[
  {
    a: result1,
  },
]

Check out the test suite for even more examples.

Interesting use cases

If you've discovered a particularly interesting way to use mux, add it here and send a PR to share it.

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].