Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Feb 28, 2024 via pnpm

asynckit 0.4.0

Minimal async jobs utility library, with streams support
Package summary
Share
0
issues
1
license
1
MIT
Package created
18 May 2016
Version published
14 Jun 2016
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
asynckit@0.4.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of asynckit 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does asynckit do?

Asynckit is a minimal yet highly efficient asynchronous jobs utility library designed with streams support. It provides a harness for both parallel and serial iterators over lists of items, depicted as arrays or objects. Furthermore, the library also accommodates an abort function and can terminate leftover jobs upon detecting an error. This is particularly beneficial for maintaining stability during operations and preventing errors due to exceeding the maximum call stack size, potentially caused by synchronous iterators.

How do you use asynckit?

Asynckit can be installed by using npm install:

$ npm install --save asynckit

To use the Asynckit utility library, you can follow these examples.

  • For Parallel Jobs with an Input Array:
var parallel = require('asynckit').parallel,
    assert   = require('assert');

var source         = [ 1, 1, 4, 16, 64, 32, 8, 2 ],
    expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ],
    expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ],
    target         = [];

parallel(source, asyncJob, function(err, result)
{
  assert.deepEqual(result, expectedResult);
  assert.deepEqual(target, expectedTarget);
});

function asyncJob(item, cb)
{
  var delay = item * 25;
  var timeoutId = setTimeout(function() {
    target.push(item);
    cb(null, item * 2);
  }, delay);

  return clearTimeout.bind(null, timeoutId);
}
  • For Serial Jobs with an Input Object:
var serial = require('asynckit').serial
    assert = require('assert');

var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 },
     expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 },
     expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ],
     target         = [];

serial(source, asyncJob, function(err, result)
{
  assert.deepEqual(result, expectedResult);
  assert.deepEqual(target, expectedTarget);
});

function asyncJob(item, cb)
{
  target.push(item);
  cb(null, item * 2);
}

These examples demonstrate basic usage. More comprehensive examples can be found in the test folder of the Asynckit library repo.

Where are the asynckit docs?

The Asynckit documentation can be found directly in the GitHub repo accessible via https://github.com/alexindigo/asynckit.git. All the examples and functional details are included in the README file there. Further examples are available in the provided "test" folders found in the repository. You can also find more information or ask a question in the "issues" section of the GitHub repository.