All Projects → doasync → doasync

doasync / doasync

Licence: MIT License
Promisify functions and objects immutably

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to doasync

chomex
Chrome Extension Messaging Routing Kit / Promisify Chrome Messaging / LocalStorage Object Mapper
Stars: ✭ 41 (+51.85%)
Mutual labels:  promise, promisify
alls
Just another library with the sole purpose of waiting till all promises to complete. Nothing more, Nothing less.
Stars: ✭ 13 (-51.85%)
Mutual labels:  promises, promise
promiviz
Visualize JavaScript Promises on the browser. Visualize the JavaScript Promise APIs and learn. It is a playground to learn about promises faster, ever!
Stars: ✭ 79 (+192.59%)
Mutual labels:  promises, promise
swear
🙏 Flexible promise handling with Javascript
Stars: ✭ 56 (+107.41%)
Mutual labels:  promises, promise
do
Simplest way to manage asynchronicity
Stars: ✭ 33 (+22.22%)
Mutual labels:  promise, promisify
Promise
Promise / Future library for Go
Stars: ✭ 149 (+451.85%)
Mutual labels:  promises, promise
market-pricing
Wrapper for the unofficial Steam Market Pricing API
Stars: ✭ 21 (-22.22%)
Mutual labels:  promises, promise
Breeze
Javascript async flow control manager
Stars: ✭ 38 (+40.74%)
Mutual labels:  promises, promise
redux-reducer-async
Create redux reducers for async behaviors of multiple actions.
Stars: ✭ 14 (-48.15%)
Mutual labels:  promises, promise
Fetch
Asynchronous HTTP client with promises.
Stars: ✭ 29 (+7.41%)
Mutual labels:  promises, promise
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (+433.33%)
Mutual labels:  promises, promise
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-25.93%)
Mutual labels:  promises, promise
Functional Promises
Write code like a story w/ a powerful Fluent (function chaining) API
Stars: ✭ 141 (+422.22%)
Mutual labels:  promises, promise
Q
A platform-independent promise library for C++, implementing asynchronous continuations.
Stars: ✭ 179 (+562.96%)
Mutual labels:  promises, promise
Vine
Python promises
Stars: ✭ 83 (+207.41%)
Mutual labels:  promises, promise
bluff
🙏 Promise A+ implementation
Stars: ✭ 14 (-48.15%)
Mutual labels:  promises, promise
Promise.hpp
C++ asynchronous promises like a Promises/A+
Stars: ✭ 31 (+14.81%)
Mutual labels:  promises, promise
Bluebird Api
Bluebird compatible API on top of native promises.
Stars: ✭ 36 (+33.33%)
Mutual labels:  promises, promise
nedb-promise
Promisified nedb wrapper
Stars: ✭ 95 (+251.85%)
Mutual labels:  promise-wrapper, promise
tsubaki
💮 Promisify with native promises
Stars: ✭ 18 (-33.33%)
Mutual labels:  promises, promisify

DoAsync logo

NPM Version NPM Downloads GitHub issues Telegram Tweet

Welcome to the async world!

Hey! I’m a tiny little npm module - doasync. ~40 lines of code! Don’t ignore me, I’m very helpful! With me you can call any method of your object without a callback and receive a promise! Object is not modified! Cool, ha?

I can promisify functions as well (not only objects) with the help of util.promisify. But first of all, we must give credit to Proxy and ES6 guys... WeakMap has also proved useful.


Installation

npm i --save doasync

Usage

With objects:

const fs = require('fs');
const doAsync = require('doasync');

doAsync(fs).readFile('package.json', 'utf8')
  .then(result => {
    console.dir(JSON.parse(result), {colors: true});
  });

With functions:

doAsync(request)('http://www.google.com')
  .then(({body}) => {
    console.log(body);
    // ...
  });

You can even use native call and apply to bind some context:

doAsync(myFunc).apply(context, params)
  .then(result => { /*...*/ });

util.promisify() which is under the hood of this module can interact directly with the V8 API, so it doesn't create closures and will be faster than userland implementations.

Memoization is used in the module to prevent functions from being promisified each time (with the use of WeakMaps).

You can use it in async/await of course!

Tip


If you need a custom promisify function - use util.promisify.custom

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