Socket
Socket
Sign inDemoInstall

neo-async

Package Overview
Dependencies
0
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    neo-async

Neo-Async is thought to be used as a drop-in replacement for Async, it almost fully covers its functionality and runs faster


Version published
Maintainers
1
Install size
194 kB
Created

Package description

What is neo-async?

The neo-async package is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. It is similar to the async package but with some performance improvements.

What are neo-async's main functionalities?

Control Flow

Execute a series of functions in sequential order. Each function is passed a callback it must call on completion.

async.series([
  function(callback) {
    // do some stuff ...
    callback(null, 'one');
  },
  function(callback) {
    // do some more stuff ...
    callback(null, 'two');
  }
],
function(err, results) {
  // results is now equal to ['one', 'two']
});

Collections

Apply a function to each item in a collection and collect the results.

async.map(['file1','file2','file3'], fs.stat, function(err, results) {
  // results is now an array of stats for each file
});

Utilities

Call a function a certain number of times and collect the results.

async.times(5, function(n, next) {
  createUser(n, function(err, user) {
    next(err, user);
  });
}, function(err, users) {
  // we should now have 5 users
});

Other packages similar to neo-async

Readme

Source

Neo-Async

Build Status codecov.io

Neo-Async is thought to be used as a drop-in replacement for Async, it almost fully covers its functionality and runs faster

Neo-Async

nodei

Speed Comparison

  • async v0.9.0
  • neo-async v0.4.9

Front-end

Speed comparison of front-end measured by jsPerf.
Measurement environment are as follows.

  • Chrome 40.0.2214
  • FireFox 34.0
  • Safari 8.0.2

waterfall figure 1: waterfall sample

The value is the ratio (Neo-Async/Async) of the executions numbers per second.

functionChromeFireFoxSafariurl
waterfall2.182.202.36http://jsperf.com/async-waterfall/7
series1.501.311.10http://jsperf.com/async-series/8
parallel15.6710.175.01http://jsperf.com/async-parallel/5
parallelLimit1.351.411.11http://jsperf.com/async-parallel-limit/2

Server-side

Speed comparison of server-side measured by func-comparator.
Specifications are as follows.

  • n times trials
  • Random execution order
  • Execute GC every time
  • Measure the average speed[μs] of n times

demo.js

var comparator = require('func-comparator');
var _ = require('lodash');
var async = require('async');
var neo_async = require('neo-async');

var count = 10; // the number of parallel tasks
var n = 1000; // the number of trial times
var array = _.shuffle(_.times(count));
var tasks = _.map(array, function(n) {
    return function(next) {
        next(null, n);
    };
});

// functions will be executed by random order
var funcs = {
    'async': function(callback) {
        async.parallel(tasks, callback);
    },
    'neo-async': function(callback) {
        neo_async.parallel(tasks, callback);
    }
};

comparator
.set(funcs)
.option({
    async: true,
    times: n
})
.start()
.result(console.log);

execute

  • 10 times trials
  • 1000 tasks

Execution environment are as follows.

  • node v0.10.35
  • iojs v1.0.2
$ node --expose_gc demo.js
$ iojs --expose_gc demo.js

result

The value is the ratio (Neo-Async/Async) of the average speed per n times.

functionnodeiojs
waterfall3.4712.05
series1.986.38
parallel2.948.94
paralellLimit2.886.13

The results show that we could improve perfomance by using either node or iojs.

Improvement of convenience

neo-async also have loop support for Object which is unsupported in async.

var object = {
    HOGE: 'hoge',
    FUGA: 'fuga',
    PIYO: 'piyo'
};

async.each(Object.keys(object), function(key, done) {
    var str = object[key];
    /* processing */
    done();
}, callback);

neo_async.each(object, function(str, done) {
    /* processing */
    done();
}, callback, thisArg);

Installation

In a browser

<script src="async.min.js"></script>

In an AMD loader

require(['async'], function(async) {});

Node.js

standard
$ npm install neo-async
var async = require('neo-async');
replacement
$ npm install neo-async
$ ln -s ./node_modules/neo-async ./node_modules/async
var async = require('async');

Bower

bower install neo-async

Feature not in Async

Collections

Control Flow

Utils

Keywords

FAQs

Last updated on 19 Feb 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc