Skip to content

Commit

Permalink
Merge pull request #202 from skrtheboss/develop
Browse files Browse the repository at this point in the history
Merge Develop
  • Loading branch information
skrtheboss authored Jan 17, 2022
2 parents ab27843 + 6db49a8 commit 6b2ee88
Show file tree
Hide file tree
Showing 7 changed files with 2,735 additions and 4,203 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ aliases:
- &job-defaults
working_directory: ~/semaphore
docker:
- image: circleci/node:14.5.0
- image: circleci/node:14.18.2

- &yarn-install
run:
Expand All @@ -18,7 +18,8 @@ aliases:

- &save-cache
name: Save Yarn Package Cache
paths: node_modules
paths:
- node_modules
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}

- &release_branches_filter
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
docs
49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,34 @@
"node": ">=14.5.0"
},
"devDependencies": {
"@commitlint/cli": "^12.0.0",
"@commitlint/config-conventional": "^12.0.0",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/github": "^7.2.0",
"@semantic-release/npm": "^7.0.10",
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/github": "^8.0.2",
"@semantic-release/npm": "^8.0.3",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/jest": "^27.4.0",
"@types/node": "^14.18.7",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"commitlint-circle": "^1.0.0",
"condition-circle": "^2.0.2",
"coveralls": "^3.1.0",
"coveralls": "^3.1.1",
"dependency-check": "^4.1.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^5.1.1",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"jest-silent-reporter": "^0.4.0",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"eslint": "^8.7.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "^27.4.7",
"jest-junit": "^13.0.0",
"jest-silent-reporter": "^0.5.0",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"semantic-release": "^17.4.0",
"shx": "^0.3.3",
"ts-jest": "^26.5.2",
"typedoc": "^0.20.28",
"typescript": "~4.1.5"
"semantic-release": "^18.0.1",
"shx": "^0.3.4",
"ts-jest": "^27.1.3",
"typedoc": "^0.22.10",
"typescript": "~4.5.4"
}
}
11 changes: 6 additions & 5 deletions src/semaphore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ describe('Semaphore', () => {
expect(semaphore.availablePermits()).toEqual(0);
});

test('expect acquire() should wait till permits are available', async done => {
test('expect acquire() should wait till permits are available', async () => {
const semaphore = new Semaphore(0);
const test = jest.fn();

expect(await semaphore.tryAcquire()).toBeFalsy();

semaphore.acquire().then(() => {
expect(test).toBeCalled();
done();
});
const promise = semaphore.acquire();

expect(semaphore.hasQueuedAcquirers()).toBeTruthy();

await awaitTime(10);
test();
semaphore.release(1);

await promise;

expect(test).toBeCalled();
});

test('expect reducePermit() to reduce permits', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,6 @@ export class Semaphore {
this._checkSemaphore();
});

return { promise, acquirer: (acquirer as unknown) as Acquirer };
return { promise, acquirer: acquirer as unknown as Acquirer };
}
}
Loading

0 comments on commit 6b2ee88

Please sign in to comment.