@defer/client
Advanced tools
Comparing version 1.11.0-alpha-20230919164910-a392419 to 1.11.0-alpha-20230919170114-b9c4a8e
@@ -160,7 +160,7 @@ "use strict"; | ||
} | ||
function defer(func, config) { | ||
function defer(fn, config) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func; | ||
wrapped.__fn = fn; | ||
wrapped.__metadata = { | ||
@@ -175,7 +175,7 @@ version: constants_js_1.INTERNAL_VERSION, | ||
exports.defer = defer; | ||
defer.cron = function (func, cronExpr, config) { | ||
defer.cron = function (fn, cronExpr, config) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func; | ||
wrapped.__fn = fn; | ||
wrapped.__metadata = { | ||
@@ -190,36 +190,36 @@ version: constants_js_1.INTERNAL_VERSION, | ||
}; | ||
function delay(func, delay) { | ||
function delay(fn, delay) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func.__fn; | ||
wrapped.__metadata = func.__metadata; | ||
wrapped.__execOptions = { ...func.__execOptions, delay }; | ||
wrapped.__fn = fn.__fn; | ||
wrapped.__metadata = fn.__metadata; | ||
wrapped.__execOptions = { ...fn.__execOptions, delay }; | ||
return wrapped; | ||
} | ||
exports.delay = delay; | ||
function addMetadata(func, metadata) { | ||
const gatheredMetadata = { ...func.__execOptions?.metadata, ...metadata }; | ||
function addMetadata(fn, metadata) { | ||
const gatheredMetadata = { ...fn.__execOptions?.metadata, ...metadata }; | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func.__fn; | ||
wrapped.__metadata = func.__metadata; | ||
wrapped.__execOptions = { ...func.__execOptions, metadata: gatheredMetadata }; | ||
wrapped.__fn = fn.__fn; | ||
wrapped.__metadata = fn.__metadata; | ||
wrapped.__execOptions = { ...fn.__execOptions, metadata: gatheredMetadata }; | ||
return wrapped; | ||
} | ||
exports.addMetadata = addMetadata; | ||
function discardAfter(func, value) { | ||
function discardAfter(fn, value) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func.__fn; | ||
wrapped.__metadata = func.__metadata; | ||
wrapped.__execOptions = { ...func.__execOptions, discardAfter: value }; | ||
wrapped.__fn = fn.__fn; | ||
wrapped.__metadata = fn.__metadata; | ||
wrapped.__execOptions = { ...fn.__execOptions, discardAfter: value }; | ||
return wrapped; | ||
} | ||
exports.discardAfter = discardAfter; | ||
function awaitResult(func) { | ||
function awaitResult(fn) { | ||
return async function (...args) { | ||
const originalFunction = func.__fn; | ||
const originalFunction = fn.__fn; | ||
const functionArguments = (0, utils_js_1.sanitizeFunctionArguments)(args); | ||
@@ -226,0 +226,0 @@ const httpClient = getHTTPClient(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = "1.11.0-alpha-20230919164910-a392419"; | ||
exports.default = "1.11.0-alpha-20230919170114-b9c4a8e"; |
@@ -130,7 +130,7 @@ import parseDuration from "parse-duration"; | ||
} | ||
export function defer(func, config) { | ||
export function defer(fn, config) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func; | ||
wrapped.__fn = fn; | ||
wrapped.__metadata = { | ||
@@ -144,7 +144,7 @@ version: INTERNAL_VERSION, | ||
} | ||
defer.cron = function (func, cronExpr, config) { | ||
defer.cron = function (fn, cronExpr, config) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func; | ||
wrapped.__fn = fn; | ||
wrapped.__metadata = { | ||
@@ -159,33 +159,33 @@ version: INTERNAL_VERSION, | ||
}; | ||
export function delay(func, delay) { | ||
export function delay(fn, delay) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func.__fn; | ||
wrapped.__metadata = func.__metadata; | ||
wrapped.__execOptions = { ...func.__execOptions, delay }; | ||
wrapped.__fn = fn.__fn; | ||
wrapped.__metadata = fn.__metadata; | ||
wrapped.__execOptions = { ...fn.__execOptions, delay }; | ||
return wrapped; | ||
} | ||
export function addMetadata(func, metadata) { | ||
const gatheredMetadata = { ...func.__execOptions?.metadata, ...metadata }; | ||
export function addMetadata(fn, metadata) { | ||
const gatheredMetadata = { ...fn.__execOptions?.metadata, ...metadata }; | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func.__fn; | ||
wrapped.__metadata = func.__metadata; | ||
wrapped.__execOptions = { ...func.__execOptions, metadata: gatheredMetadata }; | ||
wrapped.__fn = fn.__fn; | ||
wrapped.__metadata = fn.__metadata; | ||
wrapped.__execOptions = { ...fn.__execOptions, metadata: gatheredMetadata }; | ||
return wrapped; | ||
} | ||
export function discardAfter(func, value) { | ||
export function discardAfter(fn, value) { | ||
const wrapped = async function (...args) { | ||
return enqueue(wrapped, ...args); | ||
}; | ||
wrapped.__fn = func.__fn; | ||
wrapped.__metadata = func.__metadata; | ||
wrapped.__execOptions = { ...func.__execOptions, discardAfter: value }; | ||
wrapped.__fn = fn.__fn; | ||
wrapped.__metadata = fn.__metadata; | ||
wrapped.__execOptions = { ...fn.__execOptions, discardAfter: value }; | ||
return wrapped; | ||
} | ||
export function awaitResult(func) { | ||
export function awaitResult(fn) { | ||
return async function (...args) { | ||
const originalFunction = func.__fn; | ||
const originalFunction = fn.__fn; | ||
const functionArguments = sanitizeFunctionArguments(args); | ||
@@ -192,0 +192,0 @@ const httpClient = getHTTPClient(); |
@@ -1,1 +0,1 @@ | ||
export default "1.11.0-alpha-20230919164910-a392419"; | ||
export default "1.11.0-alpha-20230919170114-b9c4a8e"; |
{ | ||
"name": "@defer/client", | ||
"version": "1.11.0-alpha-20230919164910-a392419", | ||
"version": "1.11.0-alpha-20230919170114-b9c4a8e", | ||
"description": "Zero infrastructure NodeJS background jobs", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -58,10 +58,10 @@ import { Units } from "parse-duration"; | ||
} | ||
export declare function defer<F extends DeferableFunction>(func: F, config?: DeferredFunctionConfiguration): DeferredFunction<F>; | ||
export declare function defer<F extends DeferableFunction>(fn: F, config?: DeferredFunctionConfiguration): DeferredFunction<F>; | ||
export declare namespace defer { | ||
var cron: (func: DeferableFunction, cronExpr: string, config?: DeferredFunctionConfiguration | undefined) => DeferredFunction<DeferableFunction>; | ||
var cron: (fn: DeferableFunction, cronExpr: string, config?: DeferredFunctionConfiguration | undefined) => DeferredFunction<DeferableFunction>; | ||
} | ||
export declare function delay<F extends DeferableFunction>(func: DeferredFunction<F>, delay: Duration | Date): DeferredFunction<F>; | ||
export declare function addMetadata<F extends DeferableFunction>(func: DeferredFunction<F>, metadata: ExecutionMetadata): DeferredFunction<F>; | ||
export declare function discardAfter<F extends DeferableFunction>(func: DeferredFunction<F>, value: Duration | Date): DeferredFunction<F>; | ||
export declare function awaitResult<F extends DeferableFunction>(func: DeferredFunction<F>): (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>>; | ||
export declare function delay<F extends DeferableFunction>(fn: DeferredFunction<F>, delay: Duration | Date): DeferredFunction<F>; | ||
export declare function addMetadata<F extends DeferableFunction>(fn: DeferredFunction<F>, metadata: ExecutionMetadata): DeferredFunction<F>; | ||
export declare function discardAfter<F extends DeferableFunction>(fn: DeferredFunction<F>, value: Duration | Date): DeferredFunction<F>; | ||
export declare function awaitResult<F extends DeferableFunction>(fn: DeferredFunction<F>): (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>>; | ||
export declare function getExecution(id: string): Promise<client.FetchExecutionResponse>; | ||
@@ -68,0 +68,0 @@ export declare function cancelExecution(id: string, force?: boolean): Promise<client.CancelExecutionResponse>; |
@@ -1,2 +0,2 @@ | ||
declare const _default: "1.11.0-alpha-20230919164910-a392419"; | ||
declare const _default: "1.11.0-alpha-20230919170114-b9c4a8e"; | ||
export default _default; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63221