Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-es

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-es - npm Package Compare versions

Comparing version 2.4.0 to 2.4.1

2

package.json
{
"name": "async-es",
"description": "Higher-order functions and common patterns for asynchronous code",
"version": "2.4.0",
"version": "2.4.1",
"main": "index.js",

@@ -6,0 +6,0 @@ "author": "Caolan McMahon",

@@ -46,31 +46,30 @@ import initialParams from './internal/initialParams';

export default function timeout(asyncFn, milliseconds, info) {
var originalCallback, timer;
var timedOut = false;
var fn = wrapAsync(asyncFn);
function injectedCallback() {
if (!timedOut) {
originalCallback.apply(null, arguments);
clearTimeout(timer);
}
}
return initialParams(function (args, callback) {
var timedOut = false;
var timer;
function timeoutCallback() {
var name = asyncFn.name || 'anonymous';
var error = new Error('Callback function "' + name + '" timed out.');
error.code = 'ETIMEDOUT';
if (info) {
error.info = info;
function timeoutCallback() {
var name = asyncFn.name || 'anonymous';
var error = new Error('Callback function "' + name + '" timed out.');
error.code = 'ETIMEDOUT';
if (info) {
error.info = info;
}
timedOut = true;
callback(error);
}
timedOut = true;
originalCallback(error);
}
var fn = wrapAsync(asyncFn);
args.push(function () {
if (!timedOut) {
callback.apply(null, arguments);
clearTimeout(timer);
}
});
return initialParams(function (args, origCallback) {
originalCallback = origCallback;
// setup timer and call original function
timer = setTimeout(timeoutCallback, milliseconds);
fn.apply(null, args.concat(injectedCallback));
fn.apply(null, args);
});
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc