Socket
Socket
Sign inDemoInstall

@dxos/async

Package Overview
Dependencies
Maintainers
13
Versions
2980
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dxos/async - npm Package Compare versions

Comparing version 1.0.1-alpha.0 to 1.0.2-alpha.0

2

dist/es/run-with-timeout.d.ts

@@ -7,3 +7,3 @@ /**

*/
export declare function runWithTimeout<T>(action: () => Promise<T>, timeout: number, getError?: () => Error): Promise<T>;
export declare function runWithTimeout<T>(action: () => Promise<T>, timeout: number, error?: Error): Promise<T>;
//# sourceMappingURL=run-with-timeout.d.ts.map

@@ -10,10 +10,12 @@ "use strict";

*/
function runWithTimeout(action, timeout, getError) {
function throwOnTimeout(timeout, getError) {
function runWithTimeout(action, timeout, error) {
// It's important to create this error object here and not inside `setTimeout` callback because this is the place where the stack trace will be captured.
const actualError = error !== null && error !== void 0 ? error : new Error(`Timed out in ${timeout}ms.`);
function throwOnTimeout() {
// eslint-disable-next-line promise/param-names
return new Promise((_, reject) => setTimeout(() => reject(getError()), timeout));
return new Promise((_, reject) => setTimeout(() => reject(actualError), timeout));
}
return Promise.race([
action(),
throwOnTimeout(timeout, getError !== null && getError !== void 0 ? getError : (() => new Error(`Timed out in ${timeout}ms.`)))
throwOnTimeout()
]);

@@ -20,0 +22,0 @@ }

{
"name": "@dxos/async",
"version": "1.0.1-alpha.0",
"version": "1.0.2-alpha.0",
"description": "Basic async utils",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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