superlock 1.1.3 → 1.2.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +0 -0
- package/README.md +1 -1
- package/package.json +17 -17
- package/src/create.js +12 -0
package/LICENSE.md
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -84,4 +84,4 @@ It returns `false` if there is at least one free concurrency slots in the lock.
|
|
|
84
84
|
**superlock** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/lock/blob/master/LICENSE.md) License.<br>
|
|
85
85
|
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/Kikobeats/lock/contributors).
|
|
86
86
|
|
|
87
|
-
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) ·
|
|
87
|
+
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · X [@Kikobeats](https://x.com/Kikobeats)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "superlock",
|
|
3
3
|
"description": "The most simple mutex/semaphore implementation",
|
|
4
4
|
"homepage": "https://github.com/Kikobeats/superlock",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.0-0",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"exports": {
|
|
@@ -53,21 +53,6 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"src"
|
|
55
55
|
],
|
|
56
|
-
"scripts": {
|
|
57
|
-
"clean": "rm -rf node_modules",
|
|
58
|
-
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
59
|
-
"coverage": "c8 report --reporter=text-lcov > coverage/lcov.info",
|
|
60
|
-
"lint": "standard",
|
|
61
|
-
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
62
|
-
"prerelease": "npm run update:check && npm run contributors",
|
|
63
|
-
"pretest": "npm run lint",
|
|
64
|
-
"release": "standard-version -a",
|
|
65
|
-
"release:github": "github-generate-release",
|
|
66
|
-
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
67
|
-
"test": "c8 ava",
|
|
68
|
-
"update": "ncu -u",
|
|
69
|
-
"update:check": "ncu -- --error-level 2"
|
|
70
|
-
},
|
|
71
56
|
"license": "MIT",
|
|
72
57
|
"ava": {
|
|
73
58
|
"files": [
|
|
@@ -97,5 +82,20 @@
|
|
|
97
82
|
"simple-git-hooks": {
|
|
98
83
|
"commit-msg": "npx commitlint --edit",
|
|
99
84
|
"pre-commit": "npx nano-staged"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"clean": "rm -rf node_modules",
|
|
88
|
+
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
89
|
+
"coverage": "c8 report --reporter=text-lcov > coverage/lcov.info",
|
|
90
|
+
"lint": "standard",
|
|
91
|
+
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
92
|
+
"prerelease": "npm run update:check && npm run contributors",
|
|
93
|
+
"pretest": "npm run lint",
|
|
94
|
+
"release": "standard-version -a",
|
|
95
|
+
"release:github": "github-generate-release",
|
|
96
|
+
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
97
|
+
"test": "c8 ava",
|
|
98
|
+
"update": "ncu -u",
|
|
99
|
+
"update:check": "ncu -- --error-level 2"
|
|
100
100
|
}
|
|
101
|
-
}
|
|
101
|
+
}
|
package/src/create.js
CHANGED
|
@@ -25,6 +25,16 @@ class LinkedList {
|
|
|
25
25
|
this.head = this.head.next
|
|
26
26
|
return data
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
size () {
|
|
30
|
+
let count = 0
|
|
31
|
+
let current = this.head
|
|
32
|
+
while (current) {
|
|
33
|
+
count++
|
|
34
|
+
current = current.next
|
|
35
|
+
}
|
|
36
|
+
return count
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
module.exports = (slots = 1) => {
|
|
@@ -48,5 +58,7 @@ module.exports = (slots = 1) => {
|
|
|
48
58
|
|
|
49
59
|
lock.isLocked = () => slots === 0
|
|
50
60
|
|
|
61
|
+
lock.awaiting = () => queue.size()
|
|
62
|
+
|
|
51
63
|
return lock
|
|
52
64
|
}
|