Skip to content

Commit

Permalink
fix: support chrome 91
Browse files Browse the repository at this point in the history
  • Loading branch information
Krivega committed Jan 31, 2024
1 parent e81f815 commit 5dd98d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"@typescript-eslint/no-magic-numbers": "off",
"no-undef-init": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/init-declarations": "off"
"@typescript-eslint/init-declarations": "off",
"unicorn/prefer-at": "off"
}
}
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import sequentPromisesList from 'sequent-promises';

const emptyStackError = new Error('Stack is empty');

const getLastItem = <T>(stack: T[]): T | undefined => {
return stack[stack.length - 1];
};

export const isEmptyStackError = (error: Error) => {
return error === emptyStackError;
};
Expand Down Expand Up @@ -80,7 +84,7 @@ const creteStackPromises = <T>({
};

const hasLastFromTasksStackByTask = ({ task: desiredTask }: { task: TTask }): boolean => {
const lastTaskRunner = tasksStack.at(-1);
const lastTaskRunner = getLastItem(tasksStack);
const isLastTask = lastTaskRunner?.task === desiredTask;

return isLastTask;
Expand Down Expand Up @@ -119,7 +123,7 @@ const creteStackPromises = <T>({
const isActual = sizePromises === sizeStackPromises;

if (isActual) {
const lastResult = results.at(-1);
const lastResult = getLastItem(results);

if (isSuccessful) {
resolve(lastResult as T);
Expand All @@ -133,7 +137,7 @@ const creteStackPromises = <T>({
}

if (noRejectIsNotActual) {
const lastResult = results.at(-1);
const lastResult = getLastItem(results);

resolve(lastResult as T);

Expand Down

0 comments on commit 5dd98d7

Please sign in to comment.