superlock 1.1.3 → 1.1.5

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/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) · Twitter [@Kikobeats](https://twitter.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.1.3",
5
+ "version": "1.1.5",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "exports": {
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
  }
package/src/index.js CHANGED
@@ -15,6 +15,7 @@ const withLock = opts => {
15
15
  }
16
16
 
17
17
  withLock.isLocked = lock.isLocked
18
+ withLock.awaiting = lock.awaiting
18
19
 
19
20
  return withLock
20
21
  }