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

@defer/client

Package Overview
Dependencies
Maintainers
2
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@defer/client - npm Package Compare versions

Comparing version 1.0.0-alpha-20230226000522-b9231b3 to 1.0.0

49

cjs/index.js

@@ -66,47 +66,2 @@ "use strict";

ret.__metadata = { version: constants_js_1.INTERNAL_VERSION, retry: retryPolicy };
ret.await = async (...args) => {
let functionArguments;
try {
functionArguments = JSON.parse(JSON.stringify(args));
}
catch (error) {
const e = error;
throw new errors_js_1.DeferError(`cannot serialize argument: ${e.message}`);
}
if (__httpClient) {
const { id } = await (0, client_js_1.enqueueExecution)(__httpClient, {
name: fn.name,
arguments: functionArguments,
scheduleFor: new Date(),
});
const response = await (0, client_js_1.waitExecutionResult)(__httpClient, { id: id });
if (response.state === "failed") {
let error = new Error("Defer execution failed");
if (response.result?.message) {
error = new Error(response.result.message);
error.stack = response.result.stack;
}
else if (response.result) {
error = response.result;
}
throw error;
}
return response.result;
}
try {
return Promise.resolve(await fn(...functionArguments));
}
catch (error) {
// const e = error as Error;
let deferError = new Error("Defer execution failed");
if (error instanceof Error) {
deferError = new Error(error.message);
deferError.stack = error.stack || "";
}
else {
deferError = error;
}
throw error;
}
};
return ret;

@@ -191,5 +146,5 @@ };

if (response.state === "failed") {
let error = new Error("Defer execution failed");
let error = new errors_js_1.DeferError("Defer execution failed");
if (response.result?.message) {
error = new Error(response.result.message);
error = new errors_js_1.DeferError(response.result.message);
error.stack = response.result.stack;

@@ -196,0 +151,0 @@ }

@@ -59,47 +59,2 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

ret.__metadata = { version: INTERNAL_VERSION, retry: retryPolicy };
ret.await = async (...args) => {
let functionArguments;
try {
functionArguments = JSON.parse(JSON.stringify(args));
}
catch (error) {
const e = error;
throw new DeferError(`cannot serialize argument: ${e.message}`);
}
if (__httpClient) {
const { id } = await enqueueExecution(__httpClient, {
name: fn.name,
arguments: functionArguments,
scheduleFor: new Date(),
});
const response = await waitExecutionResult(__httpClient, { id: id });
if (response.state === "failed") {
let error = new Error("Defer execution failed");
if (response.result?.message) {
error = new Error(response.result.message);
error.stack = response.result.stack;
}
else if (response.result) {
error = response.result;
}
throw error;
}
return response.result;
}
try {
return Promise.resolve(await fn(...functionArguments));
}
catch (error) {
// const e = error as Error;
let deferError = new Error("Defer execution failed");
if (error instanceof Error) {
deferError = new Error(error.message);
deferError.stack = error.stack || "";
}
else {
deferError = error;
}
throw error;
}
};
return ret;

@@ -182,5 +137,5 @@ };

if (response.state === "failed") {
let error = new Error("Defer execution failed");
let error = new DeferError("Defer execution failed");
if (response.result?.message) {
error = new Error(response.result.message);
error = new DeferError(response.result.message);
error.stack = response.result.stack;

@@ -187,0 +142,0 @@ }

2

package.json
{
"name": "@defer/client",
"version": "1.0.0-alpha-20230226000522-b9231b3",
"version": "1.0.0",
"description": "Zero infrastructure NodeJS background jobs",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -30,4 +30,2 @@ import { Units } from "parse-duration";

__fn: F;
/** @deprecated use `waitResult(deferFn)` instead */
await: DeferAwaitRetFn<F>;
}

@@ -34,0 +32,0 @@ export interface DeferScheduledFn<F extends (...args: never) => Promise<any>> extends HasDeferMetadata {

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