From ed0045ecf656b89c39c56c96465e85c91bb01a3f Mon Sep 17 00:00:00 2001 From: nev21 <82737406+nev21@users.noreply.github.com> Date: Thu, 28 Mar 2024 23:01:23 -0700 Subject: [PATCH] Remove unnecessary _processPendingItems function (#157) --- lib/src/helpers/doWhileAsync.ts | 2 +- lib/src/promise/itemProcessor.ts | 22 +++++++++------------- lib/src/promise/syncPromise.ts | 2 +- rush.json | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/src/helpers/doWhileAsync.ts b/lib/src/helpers/doWhileAsync.ts index bb63bca..600bb0f 100644 --- a/lib/src/helpers/doWhileAsync.ts +++ b/lib/src/helpers/doWhileAsync.ts @@ -13,7 +13,7 @@ import { doAwait } from "../promise/await"; import { RejectPromiseHandler, ResolvePromiseHandler } from "../interfaces/types"; import { IWhileState } from "../interfaces/IWhileState"; -const _doneChk = /*#__PURE__*/(isDone: boolean, state: IWhileState, value: T, thisArg?: any) => { +function _doneChk(isDone: boolean, state: IWhileState, value: T, thisArg?: any) { let result: boolean | IPromise = isDone; state.res = value; if (!result) { diff --git a/lib/src/promise/itemProcessor.ts b/lib/src/promise/itemProcessor.ts index 7b0dae6..bd6c8d5 100644 --- a/lib/src/promise/itemProcessor.ts +++ b/lib/src/promise/itemProcessor.ts @@ -14,7 +14,13 @@ export type PromisePendingProcessor = (pending: PromisePendingFn[]) => void; export type PromisePendingFn = () => void; export type PromiseCreatorFn = (newExecutor: PromiseExecutor, ...extraArgs: any) => IPromise; -const _processPendingItems = /*#__PURE__*/(pending: PromisePendingFn[]) => { +/** + * @internal + * @ignore + * Return an item processor that processes all of the pending items synchronously + * @return An item processor + */ +export function syncItemProcessor(pending: PromisePendingFn[]): void { arrForEach(pending, (fn: PromisePendingFn) => { try { fn(); @@ -25,16 +31,6 @@ const _processPendingItems = /*#__PURE__*/(pending: PromisePendingFn[]) => { }); } -/** - * @internal - * @ignore - * Return an item processor that processes all of the pending items synchronously - * @return An item processor - */ -export function syncItemProcessor(): (pending: PromisePendingFn[]) => void { - return _processPendingItems; -} - /** * @internal * @ignore @@ -47,7 +43,7 @@ export function timeoutItemProcessor(timeout?: number): (pending: PromisePending return (pending: PromisePendingFn[]) => { scheduleTimeout(() => { - _processPendingItems(pending); + syncItemProcessor(pending); }, callbackTimeout); } } @@ -70,7 +66,7 @@ export function idleItemProcessor(timeout?: number): (pending: PromisePendingFn[ return (pending: PromisePendingFn[]) => { scheduleIdleCallback((deadline: IdleDeadline) => { - _processPendingItems(pending); + syncItemProcessor(pending); }, options); }; } \ No newline at end of file diff --git a/lib/src/promise/syncPromise.ts b/lib/src/promise/syncPromise.ts index 5b6008b..f4199d1 100644 --- a/lib/src/promise/syncPromise.ts +++ b/lib/src/promise/syncPromise.ts @@ -30,7 +30,7 @@ let _anySyncCreator: ICachedValue<(values: T, * cause the promise to be rejected. The return value of the executor is always ignored */ export function createSyncPromise(executor: PromiseExecutor): IPromise { - return _createPromise(createSyncPromise, syncItemProcessor(), executor); + return _createPromise(createSyncPromise, syncItemProcessor, executor); } /** diff --git a/rush.json b/rush.json index 8979015..e4b7729 100644 --- a/rush.json +++ b/rush.json @@ -3,7 +3,7 @@ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", "npmVersion": "8.19.4", - "rushVersion": "5.118.6", + "rushVersion": "5.118.7", "projectFolderMaxDepth": 4, "projects": [ {