Skip to content

Commit

Permalink
fix!: export
Browse files Browse the repository at this point in the history
  • Loading branch information
Krivega committed May 19, 2024
1 parent 44d3609 commit 5425ba9
Show file tree
Hide file tree
Showing 7 changed files with 1,438 additions and 1,287 deletions.
2 changes: 2 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
node node_modules/.bin/commitlint --edit "$1"
3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
yarn commitlint ${1}
npx lint-staged ${1}
yarn lint-staged ${1}
2 changes: 1 addition & 1 deletion .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"reject": []
"reject": ["eslint"]
}
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,45 @@
"test:coverage": "yarn test:ci --coverage --reporters=default --reporters=jest-junit"
},
"dependencies": {
"sequent-promises": "^1.0.0"
"sequent-promises": "^2.0.0"
},
"devDependencies": {
"@babel/preset-typescript": "^7.23.3",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@nabla/vite-plugin-eslint": "^2.0.2",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@babel/preset-typescript": "^7.24.1",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@nabla/vite-plugin-eslint": "^2.0.4",
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^50.0.1",
"husky": "^9.0.7",
"eslint-plugin-unicorn": "^53.0.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2",
"jest-junit": "^16.0.0",
"lint-staged": "^15.2.1",
"prettier": "^3.2.4",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"standard-version": "^9.5.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsc-files": "^1.1.4",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-dts": "^3.7.2",
"vite-tsconfig-paths": "^4.3.1"
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vite-plugin-dts": "^3.9.1",
"vite-tsconfig-paths": "^4.3.2"
},
"peerDependencies": {
"sequent-promises": "^2.0.0"
},
"peerDependencies": {},
"main:src": "src/index.ts"
}
12 changes: 7 additions & 5 deletions src/__tests__/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// <reference types="jest" />

/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable jest/no-conditional-expect */
import creteStackPromises, { isEmptyStackError, isPromiseIsNotActualError } from '../index';
import { creteStackPromises, isEmptyStackError, isPromiseIsNotActualError } from '../index';

const noop = () => {};
const deferred = <T = void>() => {
Expand Down Expand Up @@ -35,8 +37,8 @@ describe('creteStackPromises', () => {
it('empty stack', async () => {
expect.assertions(1);

return stackPromises().catch((error: Error) => {
expect(isEmptyStackError(error)).toBe(true);
return stackPromises().catch((error: unknown) => {
expect(isEmptyStackError(error as Error)).toBe(true);
});
});

Expand Down Expand Up @@ -471,7 +473,7 @@ describe('creteStackPromises', () => {
throw error;
});

return stackPromises().catch((error_) => {
return stackPromises().catch((error_: unknown) => {
expect(error_).toBe(error);
});
});
Expand All @@ -489,7 +491,7 @@ describe('creteStackPromises', () => {

stackPromises.stop();

return promise.catch((error_) => {
return promise.catch((error_: unknown) => {
expect(error_).toEqual(error);
});
});
Expand Down
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sequentPromisesList from 'sequent-promises';
import { sequentPromises } from 'sequent-promises';

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

Expand All @@ -20,7 +20,7 @@ const notFunctionError = new Error(
'stackPromises only works with functions that returns a Promise',
);

const creteStackPromises = <T>({
export const creteStackPromises = <T>({
noRejectIsNotActual = false,
noRunIsNotActual = false,
}: {
Expand Down Expand Up @@ -165,7 +165,7 @@ const creteStackPromises = <T>({
const runStackPromises = async () => {
enableRunTasks();

return sequentPromisesList(runnersStack, canRunTask);
return sequentPromises(runnersStack, canRunTask);
};

const result = async () => {
Expand All @@ -176,7 +176,11 @@ const creteStackPromises = <T>({
return new Promise<T>((resolve, reject) => {
const finishResultPromise = resolveFinishResultPromise({ resolve, reject });

runStackPromises().then(finishResultPromise).catch(finishResultPromise);
runStackPromises()
.then(finishResultPromise)
.catch((error: unknown) => {
finishResultPromise(error as { results: T[]; isSuccessful: boolean });
});
});
};

Expand Down Expand Up @@ -214,5 +218,3 @@ const creteStackPromises = <T>({

return result;
};

export default creteStackPromises;
Loading

0 comments on commit 5425ba9

Please sign in to comment.