All Projects → shutterstock → Node Procedural Async

shutterstock / Node Procedural Async

Licence: mit
Write procedural style code that runs asynchronously. It may look synchronous, but it's not!

Programming Languages

javascript
184084 projects - #8 most used programming language
procedural
45 projects

Projects that are alternatives of or similar to Node Procedural Async

Madelineproto
Async PHP client/server API for the telegram MTProto protocol
Stars: ✭ 1,776 (+10347.06%)
Mutual labels:  async, proxy, easy
Pyproxy Async
基于 Python Asyncio + Redis 实现的代理池
Stars: ✭ 123 (+623.53%)
Mutual labels:  async, proxy
Gruvi
Async IO for Python, Simplified
Stars: ✭ 96 (+464.71%)
Mutual labels:  async, fibers
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (+864.71%)
Mutual labels:  async, fibers
Futures Batch
An adapter for futures, which chunks up elements and flushes them after a timeout, or when the buffer is full. (Formerly known as tokio-batch.)
Stars: ✭ 37 (+117.65%)
Mutual labels:  async, futures
Gaia
C++ framework for rapid server development
Stars: ✭ 58 (+241.18%)
Mutual labels:  async, fibers
Hydra
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift
Stars: ✭ 1,954 (+11394.12%)
Mutual labels:  async, futures
Lwt
OCaml promises and concurrent I/O
Stars: ✭ 505 (+2870.59%)
Mutual labels:  futures, fibers
Ok ip proxy pool
🍿爬虫代理IP池(proxy pool) python🍟一个还ok的IP代理池
Stars: ✭ 196 (+1052.94%)
Mutual labels:  async, proxy
Fibrous
Easily mix asynchronous and synchronous programming styles in node.js.
Stars: ✭ 183 (+976.47%)
Mutual labels:  async, fibers
May
rust stackful coroutine library
Stars: ✭ 909 (+5247.06%)
Mutual labels:  async, fibers
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+3958.82%)
Mutual labels:  async, futures
Mioco
[no longer maintained] Scalable, coroutine-based, fibers/green-threads for Rust. (aka MIO COroutines).
Stars: ✭ 125 (+635.29%)
Mutual labels:  async, fibers
Smol
A small and fast async runtime for Rust
Stars: ✭ 2,206 (+12876.47%)
Mutual labels:  async, futures
Funfix
Functional Programming Library for JavaScript, TypeScript and Flow ✨⚡️
Stars: ✭ 596 (+3405.88%)
Mutual labels:  async, futures
Mycat2
MySQL Proxy using Java NIO based on Sharding SQL,Calcite ,simple and fast
Stars: ✭ 750 (+4311.76%)
Mutual labels:  async, proxy
Recoil
Asynchronous coroutines for PHP 7.
Stars: ✭ 765 (+4400%)
Mutual labels:  async
Fod
Freedom of Developers
Stars: ✭ 815 (+4694.12%)
Mutual labels:  proxy
Wx Promise Pro
✨强大、优雅的微信小程序异步库🚀
Stars: ✭ 762 (+4382.35%)
Mutual labels:  async
Corvus
A fast and lightweight Redis Cluster Proxy for Redis 3.0
Stars: ✭ 758 (+4358.82%)
Mutual labels:  proxy

node-procedural-async

Write procedural style code that runs asynchronously. It may look synchronous, but it's not!

Basic Example

var Bernhard = require('procedural-async');
var models = require('./models');

Bernhard.async(function(){
	try {
		// Not needed now, don't block.
		var current_user = models.User.retrieveByName(req.session.username);
		var genre = models.Genre.retrieveByName(req.query.genre);
		// Will wait on results.
		var book_results = models.Book.search({genre: genre.id});
		var favorite_book_ids = current_user.retrieveFavoriteBookIds();
		var response_data = book_results.map(function(book){
			return {
				id: book.id,
				title: book.title,
				author: book.retrieveAuthor().name,
				is_favorite: favorite_book_ids.indexOf(book.id) > -1
			};
		});
	} catch (e) {
		return next(e);
	}
	
	res.json(response_data);
});

Full Example Code

Example Using caolan's (excellent) async

Features

  • Fully asynchronous, with the option to be synchronous
  • Execute asynchronous calls immediately, but wait for the results only at the time you need them
  • Allows for try/catch error handling
  • instances are subclasses of any class you like
  • Easy to read and write

How it Works

Under the hood, node-procedural-async uses a combination of Proxies and node-fibers. When you call Bernhard.generate, a proxy class is dynamically generated, instanciated and returned. All calls to the proxy will yield until whatever asynchronous task you started has completed. The asynchronous/synchronous magic comes from fibers, so you must write your procedural-async code inside a function that you pass to Bernhard.async.

Installation

The current version requires node.js v0.11.4 and an experimental untagged version of node-fibers.

Usage

Setting Up Your Asynchronous Code

Bernhard.generate(Class)

Returns an instance that derives from Class. You should return this instance from your asynchronous function immediately.

instance.callback([err, [result]])

Call this on the instance you got from Bernhard.generate when your asynchronous function has completed.

Using Your Asynchronous Code

Bernhard.async(function)

Put all your procedural-async code inside a function that you pass to this method. Inside this function, you can try/catch any errors.

Authors

This library was developed by Ben Kovacevich, David Fenster, and Carlos Gomez at Shutterstock

Acknowledgments

This library would not be possible without Marcel Laverdet's outstanding fibers library.

License

MIT © 2013-2017 Shutterstock Images, LLC

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