@defer.run/client
Advanced tools
Comparing version 0.4.0-alpha-20230202153019-86bc7f8 to 0.4.0-alpha-20230202153941-61d314d
@@ -90,27 +90,2 @@ "use strict"; | ||
}; | ||
// EXAMPLES: | ||
// interface Contact { | ||
// id: string; | ||
// name: string; | ||
// } | ||
// const importContacts = (companyId: string, contacts: Contact[]) => { | ||
// return new Promise<{ imported: number; companyId: string }>((resolve) => { | ||
// console.log(`Start importing contacts for company#${companyId}`); | ||
// setTimeout(() => { | ||
// console.log(contacts); | ||
// console.log("Done."); | ||
// resolve({ imported: 10000, companyId }); | ||
// }, 5000); | ||
// }); | ||
// }; | ||
// const importContactsD = defer(importContacts); | ||
// async function myFunction() { | ||
// return 1; | ||
// } | ||
// defer.schedule(myFunction, "every day"); | ||
// async function test() { | ||
// await importContactsD("1", []); // fire and forget | ||
// await importContactsD.await("1", []); // wait for execution result | ||
// await importContactsD.delayed("1", [], { delay: "2 days" }); // scheduled | ||
// } | ||
/** | ||
@@ -123,3 +98,5 @@ * Delay the execution of a background function | ||
*/ | ||
const delay = (deferFn, delay) => (...args) => { | ||
const delay = (deferFn, delay) => | ||
// @ts-expect-error (charly) to fix | ||
(...args) => { | ||
const fn = deferFn.__fn; | ||
@@ -145,3 +122,28 @@ if (debug) { | ||
exports.delay = delay; | ||
// EXAMPLES: | ||
// interface Contact { | ||
// id: string; | ||
// name: string; | ||
// } | ||
// const importContacts = (companyId: string, contacts: Contact[]) => { | ||
// return new Promise<{ imported: number; companyId: string }>((resolve) => { | ||
// console.log(`Start importing contacts for company#${companyId}`); | ||
// setTimeout(() => { | ||
// console.log(contacts); | ||
// console.log("Done."); | ||
// resolve({ imported: 10000, companyId }); | ||
// }, 5000); | ||
// }); | ||
// }; | ||
// const importContactsD = defer(importContacts); | ||
// async function myFunction() { | ||
// return 1; | ||
// } | ||
// defer.schedule(myFunction, "every day"); | ||
// async function test() { | ||
// await importContactsD("1", []); // fire and forget | ||
// await importContactsD.await("1", []); // wait for execution result | ||
// await importContactsD.delayed("1", [], { delay: "2 days" }); // scheduled | ||
// } | ||
// const delayed = delay(importContactsD, '1h') | ||
// delayed() | ||
// delayed('', []) |
@@ -81,27 +81,2 @@ // @ts-expect-error untyped dep | ||
}; | ||
// EXAMPLES: | ||
// interface Contact { | ||
// id: string; | ||
// name: string; | ||
// } | ||
// const importContacts = (companyId: string, contacts: Contact[]) => { | ||
// return new Promise<{ imported: number; companyId: string }>((resolve) => { | ||
// console.log(`Start importing contacts for company#${companyId}`); | ||
// setTimeout(() => { | ||
// console.log(contacts); | ||
// console.log("Done."); | ||
// resolve({ imported: 10000, companyId }); | ||
// }, 5000); | ||
// }); | ||
// }; | ||
// const importContactsD = defer(importContacts); | ||
// async function myFunction() { | ||
// return 1; | ||
// } | ||
// defer.schedule(myFunction, "every day"); | ||
// async function test() { | ||
// await importContactsD("1", []); // fire and forget | ||
// await importContactsD.await("1", []); // wait for execution result | ||
// await importContactsD.delayed("1", [], { delay: "2 days" }); // scheduled | ||
// } | ||
/** | ||
@@ -114,3 +89,5 @@ * Delay the execution of a background function | ||
*/ | ||
export const delay = (deferFn, delay) => (...args) => { | ||
export const delay = (deferFn, delay) => | ||
// @ts-expect-error (charly) to fix | ||
(...args) => { | ||
const fn = deferFn.__fn; | ||
@@ -135,3 +112,28 @@ if (debug) { | ||
}; | ||
// EXAMPLES: | ||
// interface Contact { | ||
// id: string; | ||
// name: string; | ||
// } | ||
// const importContacts = (companyId: string, contacts: Contact[]) => { | ||
// return new Promise<{ imported: number; companyId: string }>((resolve) => { | ||
// console.log(`Start importing contacts for company#${companyId}`); | ||
// setTimeout(() => { | ||
// console.log(contacts); | ||
// console.log("Done."); | ||
// resolve({ imported: 10000, companyId }); | ||
// }, 5000); | ||
// }); | ||
// }; | ||
// const importContactsD = defer(importContacts); | ||
// async function myFunction() { | ||
// return 1; | ||
// } | ||
// defer.schedule(myFunction, "every day"); | ||
// async function test() { | ||
// await importContactsD("1", []); // fire and forget | ||
// await importContactsD.await("1", []); // wait for execution result | ||
// await importContactsD.delayed("1", [], { delay: "2 days" }); // scheduled | ||
// } | ||
// const delayed = delay(importContactsD, '1h') | ||
// delayed() | ||
// delayed('', []) |
{ | ||
"name": "@defer.run/client", | ||
"version": "0.4.0-alpha-20230202153019-86bc7f8", | ||
"version": "0.4.0-alpha-20230202153941-61d314d", | ||
"description": "cua JavaScript client", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -51,2 +51,2 @@ import type { Units } from "parse-duration"; | ||
*/ | ||
export declare const delay: <F extends (...args: any | undefined) => Promise<any>>(deferFn: DeferRetFn<F>, delay: DelayString | Date) => () => F; | ||
export declare const delay: <F extends (...args: any | undefined) => Promise<any>>(deferFn: DeferRetFn<F>, delay: DelayString | Date) => F; |
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
30294
614