Skip to content

Commit

Permalink
Remove unnecessary _processPendingItems function (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
nev21 authored Mar 29, 2024
1 parent 9c9666f commit ed0045e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/src/helpers/doWhileAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { doAwait } from "../promise/await";
import { RejectPromiseHandler, ResolvePromiseHandler } from "../interfaces/types";
import { IWhileState } from "../interfaces/IWhileState";

const _doneChk = /*#__PURE__*/<T>(isDone: boolean, state: IWhileState<T>, value: T, thisArg?: any) => {
function _doneChk<T>(isDone: boolean, state: IWhileState<T>, value: T, thisArg?: any) {
let result: boolean | IPromise<boolean> = isDone;
state.res = value;
if (!result) {
Expand Down
22 changes: 9 additions & 13 deletions lib/src/promise/itemProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ export type PromisePendingProcessor = (pending: PromisePendingFn[]) => void;
export type PromisePendingFn = () => void;
export type PromiseCreatorFn = <T, TResult2 = never>(newExecutor: PromiseExecutor<T>, ...extraArgs: any) => IPromise<T | TResult2>;

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();
Expand All @@ -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
Expand All @@ -47,7 +43,7 @@ export function timeoutItemProcessor(timeout?: number): (pending: PromisePending

return (pending: PromisePendingFn[]) => {
scheduleTimeout(() => {
_processPendingItems(pending);
syncItemProcessor(pending);
}, callbackTimeout);
}
}
Expand All @@ -70,7 +66,7 @@ export function idleItemProcessor(timeout?: number): (pending: PromisePendingFn[

return (pending: PromisePendingFn[]) => {
scheduleIdleCallback((deadline: IdleDeadline) => {
_processPendingItems(pending);
syncItemProcessor(pending);
}, options);
};
}
2 changes: 1 addition & 1 deletion lib/src/promise/syncPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let _anySyncCreator: ICachedValue<<T extends readonly unknown[] | []>(values: T,
* cause the promise to be rejected. The return value of the executor is always ignored
*/
export function createSyncPromise<T>(executor: PromiseExecutor<T>): IPromise<T> {
return _createPromise(createSyncPromise, syncItemProcessor(), executor);
return _createPromise(createSyncPromise, syncItemProcessor, executor);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit ed0045e

Please sign in to comment.