@twin.org/core 0.0.3-next.8 → 0.0.3

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.
Files changed (163) hide show
  1. package/README.md +1 -9
  2. package/dist/es/encoding/base32.js +1 -1
  3. package/dist/es/encoding/base32.js.map +1 -1
  4. package/dist/es/encoding/base64.js +1 -1
  5. package/dist/es/encoding/base64.js.map +1 -1
  6. package/dist/es/errors/alreadyExistsError.js +1 -1
  7. package/dist/es/errors/alreadyExistsError.js.map +1 -1
  8. package/dist/es/errors/baseError.js +1 -1
  9. package/dist/es/errors/baseError.js.map +1 -1
  10. package/dist/es/errors/conflictError.js +1 -1
  11. package/dist/es/errors/conflictError.js.map +1 -1
  12. package/dist/es/errors/generalError.js +1 -1
  13. package/dist/es/errors/generalError.js.map +1 -1
  14. package/dist/es/errors/guardError.js +1 -1
  15. package/dist/es/errors/guardError.js.map +1 -1
  16. package/dist/es/errors/notFoundError.js +1 -1
  17. package/dist/es/errors/notFoundError.js.map +1 -1
  18. package/dist/es/errors/notSupportedError.js +1 -1
  19. package/dist/es/errors/notSupportedError.js.map +1 -1
  20. package/dist/es/errors/unauthorizedError.js +2 -2
  21. package/dist/es/errors/unauthorizedError.js.map +1 -1
  22. package/dist/es/errors/unprocessableError.js +1 -1
  23. package/dist/es/errors/unprocessableError.js.map +1 -1
  24. package/dist/es/factories/factory.js +41 -0
  25. package/dist/es/factories/factory.js.map +1 -1
  26. package/dist/es/helpers/arrayHelper.js +2 -0
  27. package/dist/es/helpers/arrayHelper.js.map +1 -1
  28. package/dist/es/helpers/errorHelper.js +18 -14
  29. package/dist/es/helpers/errorHelper.js.map +1 -1
  30. package/dist/es/helpers/jsonHelper.js.map +1 -1
  31. package/dist/es/helpers/objectHelper.js +12 -36
  32. package/dist/es/helpers/objectHelper.js.map +1 -1
  33. package/dist/es/helpers/randomHelper.js +50 -2
  34. package/dist/es/helpers/randomHelper.js.map +1 -1
  35. package/dist/es/helpers/stringHelper.js +11 -0
  36. package/dist/es/helpers/stringHelper.js.map +1 -1
  37. package/dist/es/index.js +8 -1
  38. package/dist/es/index.js.map +1 -1
  39. package/dist/es/models/IComponent.js +0 -2
  40. package/dist/es/models/IComponent.js.map +1 -1
  41. package/dist/es/models/IError.js.map +1 -1
  42. package/dist/es/models/IHealth.js +2 -0
  43. package/dist/es/models/IHealth.js.map +1 -0
  44. package/dist/es/models/IMutexWorkerMessage.js +2 -0
  45. package/dist/es/models/IMutexWorkerMessage.js.map +1 -0
  46. package/dist/es/models/healthStatus.js +21 -0
  47. package/dist/es/models/healthStatus.js.map +1 -0
  48. package/dist/es/models/mutexMessageTypes.js +13 -0
  49. package/dist/es/models/mutexMessageTypes.js.map +1 -0
  50. package/dist/es/types/objectOrArray.js.map +1 -0
  51. package/dist/es/types/singleOccurrenceArray.js +2 -0
  52. package/dist/es/types/singleOccurrenceArray.js.map +1 -0
  53. package/dist/es/types/singleOccurrenceArrayDepthHelper.js +2 -0
  54. package/dist/es/types/singleOccurrenceArrayDepthHelper.js.map +1 -0
  55. package/dist/es/types/urn.js +1 -2
  56. package/dist/es/types/urn.js.map +1 -1
  57. package/dist/es/utils/asyncCache.js +236 -88
  58. package/dist/es/utils/asyncCache.js.map +1 -1
  59. package/dist/es/utils/guards.js +16 -0
  60. package/dist/es/utils/guards.js.map +1 -1
  61. package/dist/es/utils/i18n.js.map +1 -1
  62. package/dist/es/utils/is.js +16 -0
  63. package/dist/es/utils/is.js.map +1 -1
  64. package/dist/es/utils/mutex.js +185 -0
  65. package/dist/es/utils/mutex.js.map +1 -0
  66. package/dist/types/encoding/base32.d.ts +1 -1
  67. package/dist/types/errors/alreadyExistsError.d.ts +1 -1
  68. package/dist/types/errors/baseError.d.ts +1 -1
  69. package/dist/types/errors/conflictError.d.ts +1 -1
  70. package/dist/types/errors/generalError.d.ts +1 -1
  71. package/dist/types/errors/guardError.d.ts +1 -1
  72. package/dist/types/errors/notFoundError.d.ts +1 -1
  73. package/dist/types/errors/notSupportedError.d.ts +1 -1
  74. package/dist/types/errors/unauthorizedError.d.ts +2 -2
  75. package/dist/types/errors/unprocessableError.d.ts +1 -1
  76. package/dist/types/factories/factory.d.ts +23 -1
  77. package/dist/types/helpers/arrayHelper.d.ts +1 -8
  78. package/dist/types/helpers/errorHelper.d.ts +11 -4
  79. package/dist/types/helpers/objectHelper.d.ts +18 -14
  80. package/dist/types/helpers/randomHelper.d.ts +16 -0
  81. package/dist/types/helpers/stringHelper.d.ts +6 -0
  82. package/dist/types/index.d.ts +8 -1
  83. package/dist/types/models/IComponent.d.ts +12 -0
  84. package/dist/types/models/IError.d.ts +1 -1
  85. package/dist/types/models/IHealth.d.ts +32 -0
  86. package/dist/types/models/IMutexWorkerMessage.d.ts +23 -0
  87. package/dist/types/models/healthStatus.d.ts +21 -0
  88. package/dist/types/models/mutexMessageTypes.d.ts +13 -0
  89. package/dist/types/types/singleOccurrenceArray.d.ts +6 -0
  90. package/dist/types/types/singleOccurrenceArrayDepthHelper.d.ts +4 -0
  91. package/dist/types/utils/asyncCache.d.ts +11 -3
  92. package/dist/types/utils/guards.d.ts +10 -1
  93. package/dist/types/utils/is.d.ts +7 -0
  94. package/dist/types/utils/mutex.d.ts +53 -0
  95. package/docs/changelog.md +945 -216
  96. package/docs/examples.md +308 -1
  97. package/docs/reference/classes/AlreadyExistsError.md +36 -36
  98. package/docs/reference/classes/ArrayHelper.md +10 -44
  99. package/docs/reference/classes/AsyncCache.md +13 -12
  100. package/docs/reference/classes/Base32.md +4 -4
  101. package/docs/reference/classes/Base58.md +3 -3
  102. package/docs/reference/classes/Base64.md +4 -4
  103. package/docs/reference/classes/Base64Url.md +3 -3
  104. package/docs/reference/classes/BaseError.md +35 -35
  105. package/docs/reference/classes/BitString.md +6 -6
  106. package/docs/reference/classes/Coerce.md +11 -11
  107. package/docs/reference/classes/Compression.md +3 -3
  108. package/docs/reference/classes/ConflictError.md +36 -36
  109. package/docs/reference/classes/Converter.md +18 -18
  110. package/docs/reference/classes/EnvHelper.md +1 -1
  111. package/docs/reference/classes/ErrorHelper.md +20 -10
  112. package/docs/reference/classes/Factory.md +112 -18
  113. package/docs/reference/classes/FilenameHelper.md +1 -1
  114. package/docs/reference/classes/GeneralError.md +36 -36
  115. package/docs/reference/classes/GuardError.md +36 -36
  116. package/docs/reference/classes/Guards.md +72 -30
  117. package/docs/reference/classes/HexHelper.md +6 -6
  118. package/docs/reference/classes/I18n.md +14 -14
  119. package/docs/reference/classes/Is.md +67 -39
  120. package/docs/reference/classes/JsonHelper.md +10 -10
  121. package/docs/reference/classes/Mutex.md +128 -0
  122. package/docs/reference/classes/NotFoundError.md +36 -36
  123. package/docs/reference/classes/NotImplementedError.md +35 -35
  124. package/docs/reference/classes/NotSupportedError.md +36 -36
  125. package/docs/reference/classes/NumberHelper.md +2 -2
  126. package/docs/reference/classes/ObjectHelper.md +135 -73
  127. package/docs/reference/classes/RandomHelper.md +53 -1
  128. package/docs/reference/classes/SharedStore.md +3 -3
  129. package/docs/reference/classes/StringHelper.md +45 -23
  130. package/docs/reference/classes/Uint8ArrayHelper.md +1 -1
  131. package/docs/reference/classes/UnauthorizedError.md +37 -37
  132. package/docs/reference/classes/UnprocessableError.md +36 -36
  133. package/docs/reference/classes/Url.md +8 -8
  134. package/docs/reference/classes/Urn.md +24 -24
  135. package/docs/reference/classes/Validation.md +25 -25
  136. package/docs/reference/classes/ValidationError.md +35 -35
  137. package/docs/reference/index.md +9 -0
  138. package/docs/reference/interfaces/IComponent.md +40 -4
  139. package/docs/reference/interfaces/IError.md +11 -11
  140. package/docs/reference/interfaces/IHealth.md +55 -0
  141. package/docs/reference/interfaces/II18nShared.md +4 -4
  142. package/docs/reference/interfaces/IKeyValue.md +2 -2
  143. package/docs/reference/interfaces/ILabelledValue.md +2 -2
  144. package/docs/reference/interfaces/ILocale.md +2 -2
  145. package/docs/reference/interfaces/ILocaleDictionary.md +1 -1
  146. package/docs/reference/interfaces/ILocalesIndex.md +1 -1
  147. package/docs/reference/interfaces/IMutexWorkerMessage.md +35 -0
  148. package/docs/reference/interfaces/IPatchOperation.md +6 -6
  149. package/docs/reference/interfaces/IUrlParts.md +9 -9
  150. package/docs/reference/interfaces/IValidationFailure.md +4 -4
  151. package/docs/reference/type-aliases/HealthStatus.md +5 -0
  152. package/docs/reference/type-aliases/MutexMessageTypes.md +5 -0
  153. package/docs/reference/type-aliases/SingleOccurrenceArray.md +15 -0
  154. package/docs/reference/type-aliases/SingleOccurrenceArrayDepthHelper.md +19 -0
  155. package/docs/reference/variables/CoerceType.md +10 -10
  156. package/docs/reference/variables/CompressionType.md +2 -2
  157. package/docs/reference/variables/HealthStatus.md +25 -0
  158. package/docs/reference/variables/MutexMessageTypes.md +13 -0
  159. package/locales/en.json +11 -2
  160. package/package.json +6 -6
  161. package/dist/es/models/objectOrArray.js.map +0 -1
  162. /package/dist/es/{models → types}/objectOrArray.js +0 -0
  163. /package/dist/types/{models → types}/objectOrArray.d.ts +0 -0
@@ -14,7 +14,7 @@ Class to check types of objects.
14
14
 
15
15
  ## Methods
16
16
 
17
- ### undefined()
17
+ ### undefined() {#undefined}
18
18
 
19
19
  > `static` **undefined**(`value`): `value is undefined`
20
20
 
@@ -36,7 +36,7 @@ True if the value is a empty.
36
36
 
37
37
  ***
38
38
 
39
- ### null()
39
+ ### null() {#null}
40
40
 
41
41
  > `static` **null**(`value`): `value is null`
42
42
 
@@ -58,7 +58,7 @@ True if the value is a empty.
58
58
 
59
59
  ***
60
60
 
61
- ### empty()
61
+ ### empty() {#empty}
62
62
 
63
63
  > `static` **empty**(`value`): value is null \| undefined
64
64
 
@@ -80,7 +80,7 @@ True if the value is a empty.
80
80
 
81
81
  ***
82
82
 
83
- ### notEmpty()
83
+ ### notEmpty() {#notempty}
84
84
 
85
85
  > `static` **notEmpty**(`value`): `boolean`
86
86
 
@@ -102,7 +102,7 @@ True if the value is a not empty.
102
102
 
103
103
  ***
104
104
 
105
- ### string()
105
+ ### string() {#string}
106
106
 
107
107
  > `static` **string**(`value`): `value is string`
108
108
 
@@ -124,7 +124,7 @@ True if the value is a string.
124
124
 
125
125
  ***
126
126
 
127
- ### stringValue()
127
+ ### stringValue() {#stringvalue}
128
128
 
129
129
  > `static` **stringValue**(`value`): `value is string`
130
130
 
@@ -146,7 +146,7 @@ True if the value is a string.
146
146
 
147
147
  ***
148
148
 
149
- ### json()
149
+ ### json() {#json}
150
150
 
151
151
  > `static` **json**(`value`): `value is string`
152
152
 
@@ -168,7 +168,7 @@ True if the value is a JSON string.
168
168
 
169
169
  ***
170
170
 
171
- ### stringBase64()
171
+ ### stringBase64() {#stringbase64}
172
172
 
173
173
  > `static` **stringBase64**(`value`): `value is string`
174
174
 
@@ -190,7 +190,7 @@ True if the value is a base64 string.
190
190
 
191
191
  ***
192
192
 
193
- ### stringBase64Url()
193
+ ### stringBase64Url() {#stringbase64url}
194
194
 
195
195
  > `static` **stringBase64Url**(`value`): `value is string`
196
196
 
@@ -212,7 +212,7 @@ True if the value is a base64 string.
212
212
 
213
213
  ***
214
214
 
215
- ### stringBase58()
215
+ ### stringBase58() {#stringbase58}
216
216
 
217
217
  > `static` **stringBase58**(`value`): `value is string`
218
218
 
@@ -234,9 +234,9 @@ True if the value is a base58 string.
234
234
 
235
235
  ***
236
236
 
237
- ### stringHex()
237
+ ### stringHex() {#stringhex}
238
238
 
239
- > `static` **stringHex**(`value`, `allowPrefix`): `value is string`
239
+ > `static` **stringHex**(`value`, `allowPrefix?`): `value is string`
240
240
 
241
241
  Is the value a hex string.
242
242
 
@@ -248,7 +248,7 @@ Is the value a hex string.
248
248
 
249
249
  The value to test.
250
250
 
251
- ##### allowPrefix
251
+ ##### allowPrefix?
252
252
 
253
253
  `boolean` = `false`
254
254
 
@@ -262,9 +262,9 @@ True if the value is a hex string.
262
262
 
263
263
  ***
264
264
 
265
- ### stringHexLength()
265
+ ### stringHexLength() {#stringhexlength}
266
266
 
267
- > `static` **stringHexLength**(`value`, `length`, `allowPrefix`): `value is string`
267
+ > `static` **stringHexLength**(`value`, `length`, `allowPrefix?`): `value is string`
268
268
 
269
269
  Is the value a hex string of fixed length.
270
270
 
@@ -282,7 +282,7 @@ The value to test.
282
282
 
283
283
  The length to test.
284
284
 
285
- ##### allowPrefix
285
+ ##### allowPrefix?
286
286
 
287
287
  `boolean` = `false`
288
288
 
@@ -296,7 +296,7 @@ True if the value is a hex string of required length.
296
296
 
297
297
  ***
298
298
 
299
- ### number()
299
+ ### number() {#number}
300
300
 
301
301
  > `static` **number**(`value`): `value is number`
302
302
 
@@ -318,7 +318,7 @@ True if the value is a number.
318
318
 
319
319
  ***
320
320
 
321
- ### integer()
321
+ ### integer() {#integer}
322
322
 
323
323
  > `static` **integer**(`value`): `value is number`
324
324
 
@@ -340,7 +340,7 @@ True if the value is an integer.
340
340
 
341
341
  ***
342
342
 
343
- ### bigint()
343
+ ### bigint() {#bigint}
344
344
 
345
345
  > `static` **bigint**(`value`): `value is bigint`
346
346
 
@@ -362,7 +362,7 @@ True if the value is a big integer.
362
362
 
363
363
  ***
364
364
 
365
- ### boolean()
365
+ ### boolean() {#boolean}
366
366
 
367
367
  > `static` **boolean**(`value`): `value is boolean`
368
368
 
@@ -384,7 +384,7 @@ True if the value is a boolean.
384
384
 
385
385
  ***
386
386
 
387
- ### date()
387
+ ### date() {#date}
388
388
 
389
389
  > `static` **date**(`value`): `value is Date`
390
390
 
@@ -406,7 +406,7 @@ True if the value is a date.
406
406
 
407
407
  ***
408
408
 
409
- ### dateEmpty()
409
+ ### dateEmpty() {#dateempty}
410
410
 
411
411
  > `static` **dateEmpty**(`value`): `boolean`
412
412
 
@@ -428,7 +428,7 @@ True if the value is an empty date.
428
428
 
429
429
  ***
430
430
 
431
- ### dateString()
431
+ ### dateString() {#datestring}
432
432
 
433
433
  > `static` **dateString**(`value`): `boolean`
434
434
 
@@ -450,7 +450,7 @@ True if the value is a string in ISO 8601 date format.
450
450
 
451
451
  ***
452
452
 
453
- ### dateTimeString()
453
+ ### dateTimeString() {#datetimestring}
454
454
 
455
455
  > `static` **dateTimeString**(`value`): `boolean`
456
456
 
@@ -472,7 +472,7 @@ True if the value is a string in ISO 8601 date/time format.
472
472
 
473
473
  ***
474
474
 
475
- ### timeString()
475
+ ### timeString() {#timestring}
476
476
 
477
477
  > `static` **timeString**(`value`): `boolean`
478
478
 
@@ -494,7 +494,7 @@ True if the value is a string in ISO 8601 time format.
494
494
 
495
495
  ***
496
496
 
497
- ### timestampSeconds()
497
+ ### timestampSeconds() {#timestampseconds}
498
498
 
499
499
  > `static` **timestampSeconds**(`value`): `value is number`
500
500
 
@@ -516,7 +516,7 @@ True if the value is a date.
516
516
 
517
517
  ***
518
518
 
519
- ### timestampMilliseconds()
519
+ ### timestampMilliseconds() {#timestampmilliseconds}
520
520
 
521
521
  > `static` **timestampMilliseconds**(`value`): `value is number`
522
522
 
@@ -538,7 +538,7 @@ True if the value is a date.
538
538
 
539
539
  ***
540
540
 
541
- ### object()
541
+ ### object() {#object}
542
542
 
543
543
  > `static` **object**\<`T`\>(`value`): `value is T`
544
544
 
@@ -566,7 +566,7 @@ True if the value is a object.
566
566
 
567
567
  ***
568
568
 
569
- ### objectValue()
569
+ ### objectValue() {#objectvalue}
570
570
 
571
571
  > `static` **objectValue**\<`T`\>(`value`): `value is T`
572
572
 
@@ -594,7 +594,7 @@ True if the value is a object.
594
594
 
595
595
  ***
596
596
 
597
- ### array()
597
+ ### array() {#array}
598
598
 
599
599
  > `static` **array**\<`T`\>(`value`): `value is T[]`
600
600
 
@@ -622,7 +622,7 @@ True if the value is an array.
622
622
 
623
623
  ***
624
624
 
625
- ### arrayValue()
625
+ ### arrayValue() {#arrayvalue}
626
626
 
627
627
  > `static` **arrayValue**\<`T`\>(`value`): `value is T[]`
628
628
 
@@ -650,7 +650,7 @@ True if the value is an array with at least one element.
650
650
 
651
651
  ***
652
652
 
653
- ### arrayOneOf()
653
+ ### arrayOneOf() {#arrayoneof}
654
654
 
655
655
  > `static` **arrayOneOf**\<`T`\>(`value`, `options`): `value is T`
656
656
 
@@ -684,7 +684,7 @@ True if the value is an element from the options array.
684
684
 
685
685
  ***
686
686
 
687
- ### uint8Array()
687
+ ### uint8Array() {#uint8array}
688
688
 
689
689
  > `static` **uint8Array**(`value`): `value is Uint8Array<ArrayBufferLike>`
690
690
 
@@ -706,7 +706,7 @@ True if the value is a Uint8Array.
706
706
 
707
707
  ***
708
708
 
709
- ### typedArray()
709
+ ### typedArray() {#typedarray}
710
710
 
711
711
  > `static` **typedArray**(`value`): value is Uint8Array\<ArrayBufferLike\> \| Int8Array\<ArrayBufferLike\> \| Uint16Array\<ArrayBufferLike\> \| Int16Array\<ArrayBufferLike\> \| Uint32Array\<ArrayBufferLike\> \| Int32Array\<ArrayBufferLike\> \| Float32Array\<ArrayBufferLike\> \| Float64Array\<ArrayBufferLike\>
712
712
 
@@ -728,7 +728,7 @@ True if the value is a TypedArray.
728
728
 
729
729
  ***
730
730
 
731
- ### function()
731
+ ### function() {#function}
732
732
 
733
733
  > `static` **function**\<`T`\>(`value`): `value is T`
734
734
 
@@ -756,7 +756,7 @@ True if the value is a function.
756
756
 
757
757
  ***
758
758
 
759
- ### email()
759
+ ### email() {#email}
760
760
 
761
761
  > `static` **email**(`value`): `value is string`
762
762
 
@@ -778,7 +778,7 @@ True if the value is a string.
778
778
 
779
779
  ***
780
780
 
781
- ### promise()
781
+ ### promise() {#promise}
782
782
 
783
783
  > `static` **promise**\<`T`\>(`value`): `value is Promise<T>`
784
784
 
@@ -806,7 +806,7 @@ True if the value is a promise.
806
806
 
807
807
  ***
808
808
 
809
- ### regexp()
809
+ ### regexp() {#regexp}
810
810
 
811
811
  > `static` **regexp**(`value`): `value is RegExp`
812
812
 
@@ -828,7 +828,7 @@ True if the value is a regexp.
828
828
 
829
829
  ***
830
830
 
831
- ### class()
831
+ ### class() {#class}
832
832
 
833
833
  > `static` **class**\<`T`\>(`obj`): `obj is (args: any[]) => T`
834
834
 
@@ -853,3 +853,31 @@ The object to check.
853
853
  `obj is (args: any[]) => T`
854
854
 
855
855
  True if the object is a class, false otherwise.
856
+
857
+ ***
858
+
859
+ ### uuidV7() {#uuidv7}
860
+
861
+ > `static` **uuidV7**(`value`, `format?`): `value is string`
862
+
863
+ Is the value a uuidV7 string.
864
+
865
+ #### Parameters
866
+
867
+ ##### value
868
+
869
+ `unknown`
870
+
871
+ The value to test.
872
+
873
+ ##### format?
874
+
875
+ `"standard"` \| `"compact"`
876
+
877
+ The format of the UUIDv7 string.
878
+
879
+ #### Returns
880
+
881
+ `value is string`
882
+
883
+ True if the value is a uuidV7 string.
@@ -14,7 +14,7 @@ Helpers methods for JSON objects.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### CLASS\_NAME
17
+ ### CLASS\_NAME {#class_name}
18
18
 
19
19
  > `readonly` `static` **CLASS\_NAME**: `string`
20
20
 
@@ -22,7 +22,7 @@ Runtime name for the class.
22
22
 
23
23
  ## Methods
24
24
 
25
- ### canonicalize()
25
+ ### canonicalize() {#canonicalize}
26
26
 
27
27
  > `static` **canonicalize**(`object`): `string`
28
28
 
@@ -45,7 +45,7 @@ The serialized object.
45
45
 
46
46
  ***
47
47
 
48
- ### diff()
48
+ ### diff() {#diff}
49
49
 
50
50
  > `static` **diff**\<`T`\>(`object1`, `object2`): [`IPatchOperation`](../interfaces/IPatchOperation.md)[]
51
51
 
@@ -80,7 +80,7 @@ The list of patches.
80
80
 
81
81
  ***
82
82
 
83
- ### patch()
83
+ ### patch() {#patch}
84
84
 
85
85
  > `static` **patch**\<`T`\>(`object`, `patches`): `T`
86
86
 
@@ -119,7 +119,7 @@ GeneralError if the patch fails.
119
119
 
120
120
  ***
121
121
 
122
- ### stringifyEx()
122
+ ### stringifyEx() {#stringifyex}
123
123
 
124
124
  > `static` **stringifyEx**(`object`, `space?`): `string`
125
125
 
@@ -135,9 +135,9 @@ The object to stringify.
135
135
 
136
136
  ##### space?
137
137
 
138
- Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
138
+ `string` \| `number`
139
139
 
140
- `string` | `number`
140
+ Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
141
141
 
142
142
  #### Returns
143
143
 
@@ -147,7 +147,7 @@ The stringified object.
147
147
 
148
148
  ***
149
149
 
150
- ### parseEx()
150
+ ### parseEx() {#parseex}
151
151
 
152
152
  > `static` **parseEx**(`json`): `any`
153
153
 
@@ -169,7 +169,7 @@ The object.
169
169
 
170
170
  ***
171
171
 
172
- ### stringifyExReplacer()
172
+ ### stringifyExReplacer() {#stringifyexreplacer}
173
173
 
174
174
  > `static` **stringifyExReplacer**(`this`, `key`, `value`): `unknown`
175
175
 
@@ -203,7 +203,7 @@ The value.
203
203
 
204
204
  ***
205
205
 
206
- ### parseExReviver()
206
+ ### parseExReviver() {#parseexreviver}
207
207
 
208
208
  > `static` **parseExReviver**(`this`, `key`, `value`): `unknown`
209
209
 
@@ -0,0 +1,128 @@
1
+ # Class: Mutex
2
+
3
+ A cross-thread mutex built on Atomics and SharedArrayBuffer.
4
+
5
+ When isMainThread is true (main thread or fork-mode child process) the class acts as
6
+ the authoritative registry: it creates a SharedArrayBuffer-backed Int32Array for each
7
+ key on first use and never discards it, because worker threads may hold references to
8
+ the same underlying memory.
9
+
10
+ When isMainThread is false (a true worker thread) the class synchronously negotiates
11
+ the shared buffer with the main thread on first use of each key, then caches it locally.
12
+ The main thread must call Mutex.handleWorkerMessage(msg) from its worker message handler
13
+ before that worker first calls Mutex.lock().
14
+
15
+ The lock is not re-entrant: a thread that already holds a key and calls lock() again on
16
+ the same key will block until the timeout elapses.
17
+
18
+ ## Constructors
19
+
20
+ ### Constructor
21
+
22
+ > **new Mutex**(): `Mutex`
23
+
24
+ #### Returns
25
+
26
+ `Mutex`
27
+
28
+ ## Properties
29
+
30
+ ### CLASS\_NAME {#class_name}
31
+
32
+ > `readonly` `static` **CLASS\_NAME**: `string`
33
+
34
+ Runtime name for the class.
35
+
36
+ ## Methods
37
+
38
+ ### lock() {#lock}
39
+
40
+ > `static` **lock**(`key`, `options?`): `boolean`
41
+
42
+ Acquires a lock for the given key. If the lock is already held, it will wait until it is released or until the timeout is reached.
43
+ The lock is not re-entrant: if the same thread tries to acquire the same lock again, it will deadlock until the timeout is reached.
44
+
45
+ WARNING: this method calls Atomics.wait internally. On the main thread this blocks the Node.js event loop for the
46
+ duration of the wait. Do not call from the main thread while a worker thread may simultaneously need to fetch a
47
+ buffer for a new mutex key, as that fetch requires the main thread's message loop to be running and will deadlock.
48
+
49
+ #### Parameters
50
+
51
+ ##### key
52
+
53
+ `string`
54
+
55
+ The key to lock on.
56
+
57
+ ##### options?
58
+
59
+ Lock options.
60
+
61
+ ###### timeoutMs?
62
+
63
+ `number`
64
+
65
+ The maximum time to wait for the lock in milliseconds, default is 5000.
66
+
67
+ ###### throwOnTimeout?
68
+
69
+ `boolean`
70
+
71
+ Whether to throw an error if the lock could not be acquired within the timeout, default is false.
72
+
73
+ #### Returns
74
+
75
+ `boolean`
76
+
77
+ True if the lock was acquired, false if it timed out and throwOnTimeout is false.
78
+
79
+ #### Throws
80
+
81
+ GeneralError if the key is invalid or if the lock could not be acquired within the timeout and throwOnTimeout is true.
82
+
83
+ ***
84
+
85
+ ### unlock() {#unlock}
86
+
87
+ > `static` **unlock**(`key`): `void`
88
+
89
+ Releases the lock for the given key.
90
+
91
+ #### Parameters
92
+
93
+ ##### key
94
+
95
+ `string`
96
+
97
+ The key to unlock.
98
+
99
+ #### Returns
100
+
101
+ `void`
102
+
103
+ #### Throws
104
+
105
+ GeneralError if the key is invalid or the lock is not currently held.
106
+
107
+ ***
108
+
109
+ ### handleWorkerMessage() {#handleworkermessage}
110
+
111
+ > `static` **handleWorkerMessage**(`msg`): `boolean`
112
+
113
+ Inspect a message received from a worker and, if it is a Mutex buffer-fetch request,
114
+ respond to it synchronously. Call from the main thread's worker message handler.
115
+
116
+ #### Parameters
117
+
118
+ ##### msg
119
+
120
+ `unknown`
121
+
122
+ The raw message received from the worker.
123
+
124
+ #### Returns
125
+
126
+ `boolean`
127
+
128
+ True if the message was a Mutex protocol message and was handled, false otherwise.