diff --git a/jsr.json b/jsr.json new file mode 100644 index 0000000..2318b49 --- /dev/null +++ b/jsr.json @@ -0,0 +1,5 @@ +{ + "name": "@bowencool/async-utilities", + "version": "2.5.5", + "exports": "./packages/index.ts" +} \ No newline at end of file diff --git a/package.json b/package.json index 9ea1ce9..1c3a7e2 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "description": "async utilities", "author": "bowencool", "name": "@bowencool/async-utilities", - "version": "2.5.4", + "version": "2.5.5", "gitHooks": { "pre-commit": "lint-staged && jest --onlyChanged --coverage", "post-merge": "jest --changedFilesWithAncestor --coverage", diff --git a/packages/abortableAsync/index.ts b/packages/abortableAsync/index.ts index a7a6cb0..c271681 100644 --- a/packages/abortableAsync/index.ts +++ b/packages/abortableAsync/index.ts @@ -10,7 +10,10 @@ export type AbortableOption = { // alwaysPendingWhenTimeout?: boolean; }; -export function abortableAsync(fn: (this: T, ...p: P) => Promise, opt: AbortableOption = {}) { +export function abortableAsync( + fn: (this: T, ...p: P) => Promise, + opt: AbortableOption = {}, +): (this: T, ...p: P) => Promise { return function abortabledAsync(this: T, ...args: P): Promise { return new Promise((resolve, reject) => { let timer: ReturnType | undefined; diff --git a/packages/concurrentAsync/index.ts b/packages/concurrentAsync/index.ts index e5bec1a..2586b7c 100644 --- a/packages/concurrentAsync/index.ts +++ b/packages/concurrentAsync/index.ts @@ -1,4 +1,7 @@ -export function concurrentAsync(fn: (this: T, ...p: P) => Promise, maxCount = 3) { +export function concurrentAsync( + fn: (this: T, ...p: P) => Promise, + maxCount = 3, +): (this: T, ...p: P) => Promise { let that: T; type Resolve = (arg: R) => void; diff --git a/packages/debounceAsync/index.ts b/packages/debounceAsync/index.ts index ca1201e..5a880ab 100644 --- a/packages/debounceAsync/index.ts +++ b/packages/debounceAsync/index.ts @@ -1,4 +1,7 @@ -export function debounceAsync(fn: (this: T, ...p: P) => Promise, ms: number = 300) { +export function debounceAsync( + fn: (this: T, ...p: P) => Promise, + ms: number = 300, +): (this: T, ...p: P) => Promise { let timeoutId: ReturnType; return function debouncedFiltered(this: T, ...args: P): Promise { return new Promise((resolve, reject) => { diff --git a/packages/debounceAsyncResult/index.ts b/packages/debounceAsyncResult/index.ts index fa05aec..2121a10 100644 --- a/packages/debounceAsyncResult/index.ts +++ b/packages/debounceAsyncResult/index.ts @@ -1,4 +1,6 @@ -export function debounceAsyncResult(fn: (this: T, ...p: P) => Promise) { +export function debounceAsyncResult( + fn: (this: T, ...p: P) => Promise, +): (this: T, ...p: P) => Promise { let lastFetchId = 0; return function asyncDebounced(this: T, ...args: P): Promise { const fetchId = ++lastFetchId; diff --git a/packages/throttleAsyncResult/index.ts b/packages/throttleAsyncResult/index.ts index 5885d25..eb53f6d 100644 --- a/packages/throttleAsyncResult/index.ts +++ b/packages/throttleAsyncResult/index.ts @@ -1,7 +1,7 @@ export function throttleAsyncResult( fn: (this: T, ...p: P) => Promise, { useSamePromise = false } = {}, -) { +): (this: T, ...p: P) => Promise { let isPending = false; let theLastPromise: null | Promise = null; return function asyncThrottled(this: T, ...args: P): Promise { diff --git a/packages/withRetryAsync/index.ts b/packages/withRetryAsync/index.ts index 25f97b6..7623843 100644 --- a/packages/withRetryAsync/index.ts +++ b/packages/withRetryAsync/index.ts @@ -14,7 +14,7 @@ export function withRetryAsync( */ onFailed = (i: number, lastFailedReason: unknown[]) => {}, } = {}, -) { +): (this: T, ...p: P) => Promise { return function withRetryedAsync(this: T, ...args: P): Promise { return new Promise((resolve, reject) => { let retriedCount = 0; diff --git a/readme.md b/readme.md index a8233c6..35de477 100644 --- a/readme.md +++ b/readme.md @@ -40,3 +40,7 @@ import { throttleAsyncResult } from '@bowencool/async-utilities'; - ~~cacheAsync~~ see [memoizee](https://github.com/medikoo/memoizee#memoizing-asynchronous-functions) or [lru-pcache](https://github.com/jmendiara/lru-pcache) - [ ] abort fetch & xhr + +## License + +MIT diff --git a/tsconfig.json b/tsconfig.json index 524bf7f..542a9c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "skipLibCheck": true, "noImplicitThis": true, "noImplicitAny": true, + "noImplicitReturns": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node",