@twin.org/core 0.0.3 → 0.0.4-next.10

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 (103) hide show
  1. package/dist/es/encoding/base64.js +2 -1
  2. package/dist/es/encoding/base64.js.map +1 -1
  3. package/dist/es/errors/conflictError.js +1 -1
  4. package/dist/es/errors/conflictError.js.map +1 -1
  5. package/dist/es/errors/generalError.js +1 -1
  6. package/dist/es/errors/generalError.js.map +1 -1
  7. package/dist/es/errors/notImplementedError.js +1 -1
  8. package/dist/es/errors/notImplementedError.js.map +1 -1
  9. package/dist/es/errors/validationError.js +1 -1
  10. package/dist/es/errors/validationError.js.map +1 -1
  11. package/dist/es/factories/factory.js +9 -0
  12. package/dist/es/factories/factory.js.map +1 -1
  13. package/dist/es/helpers/arrayHelper.js +1 -1
  14. package/dist/es/helpers/arrayHelper.js.map +1 -1
  15. package/dist/es/helpers/errorHelper.js +1 -1
  16. package/dist/es/helpers/errorHelper.js.map +1 -1
  17. package/dist/es/helpers/jsonHelper.js +1 -1
  18. package/dist/es/helpers/jsonHelper.js.map +1 -1
  19. package/dist/es/helpers/objectHelper.js +2 -2
  20. package/dist/es/helpers/objectHelper.js.map +1 -1
  21. package/dist/es/helpers/stringHelper.js +2 -2
  22. package/dist/es/helpers/stringHelper.js.map +1 -1
  23. package/dist/es/index.js +4 -0
  24. package/dist/es/index.js.map +1 -1
  25. package/dist/es/models/IComponent.js.map +1 -1
  26. package/dist/es/models/ILocale.js.map +1 -1
  27. package/dist/es/models/ISharedObjectBufferOptions.js +4 -0
  28. package/dist/es/models/ISharedObjectBufferOptions.js.map +1 -0
  29. package/dist/es/models/ISharedObjectBufferWorkerMessage.js +2 -0
  30. package/dist/es/models/ISharedObjectBufferWorkerMessage.js.map +1 -0
  31. package/dist/es/models/IValidationFailure.js.map +1 -1
  32. package/dist/es/models/sharedObjectBufferMessageTypes.js +13 -0
  33. package/dist/es/models/sharedObjectBufferMessageTypes.js.map +1 -0
  34. package/dist/es/utils/asyncCache.js +4 -1
  35. package/dist/es/utils/asyncCache.js.map +1 -1
  36. package/dist/es/utils/coerce.js +10 -20
  37. package/dist/es/utils/coerce.js.map +1 -1
  38. package/dist/es/utils/compression.js +1 -1
  39. package/dist/es/utils/compression.js.map +1 -1
  40. package/dist/es/utils/guards.js +36 -0
  41. package/dist/es/utils/guards.js.map +1 -1
  42. package/dist/es/utils/is.js +9 -9
  43. package/dist/es/utils/is.js.map +1 -1
  44. package/dist/es/utils/mutex.js +55 -23
  45. package/dist/es/utils/mutex.js.map +1 -1
  46. package/dist/es/utils/sharedObjectBuffer.js +305 -0
  47. package/dist/es/utils/sharedObjectBuffer.js.map +1 -0
  48. package/dist/es/utils/sharedStore.js +2 -2
  49. package/dist/es/utils/sharedStore.js.map +1 -1
  50. package/dist/types/errors/conflictError.d.ts +1 -1
  51. package/dist/types/errors/generalError.d.ts +1 -1
  52. package/dist/types/errors/notImplementedError.d.ts +1 -1
  53. package/dist/types/errors/validationError.d.ts +1 -1
  54. package/dist/types/factories/factory.d.ts +6 -0
  55. package/dist/types/helpers/arrayHelper.d.ts +1 -1
  56. package/dist/types/helpers/errorHelper.d.ts +1 -1
  57. package/dist/types/helpers/jsonHelper.d.ts +1 -1
  58. package/dist/types/helpers/objectHelper.d.ts +2 -2
  59. package/dist/types/helpers/stringHelper.d.ts +2 -2
  60. package/dist/types/index.d.ts +4 -0
  61. package/dist/types/models/IComponent.d.ts +2 -2
  62. package/dist/types/models/ILocale.d.ts +1 -1
  63. package/dist/types/models/ISharedObjectBufferOptions.d.ts +17 -0
  64. package/dist/types/models/ISharedObjectBufferWorkerMessage.d.ts +29 -0
  65. package/dist/types/models/IValidationFailure.d.ts +1 -1
  66. package/dist/types/models/sharedObjectBufferMessageTypes.d.ts +13 -0
  67. package/dist/types/utils/asyncCache.d.ts +1 -8
  68. package/dist/types/utils/coerce.d.ts +10 -20
  69. package/dist/types/utils/compression.d.ts +1 -1
  70. package/dist/types/utils/guards.d.ts +24 -0
  71. package/dist/types/utils/is.d.ts +9 -9
  72. package/dist/types/utils/mutex.d.ts +7 -7
  73. package/dist/types/utils/sharedObjectBuffer.d.ts +74 -0
  74. package/dist/types/utils/sharedStore.d.ts +2 -2
  75. package/docs/changelog.md +306 -0
  76. package/docs/reference/classes/ArrayHelper.md +1 -1
  77. package/docs/reference/classes/AsyncCache.md +1 -1
  78. package/docs/reference/classes/Coerce.md +10 -50
  79. package/docs/reference/classes/Compression.md +1 -1
  80. package/docs/reference/classes/ConflictError.md +1 -1
  81. package/docs/reference/classes/ErrorHelper.md +1 -1
  82. package/docs/reference/classes/Factory.md +28 -0
  83. package/docs/reference/classes/GeneralError.md +1 -1
  84. package/docs/reference/classes/Guards.md +108 -0
  85. package/docs/reference/classes/Is.md +9 -9
  86. package/docs/reference/classes/JsonHelper.md +1 -1
  87. package/docs/reference/classes/Mutex.md +8 -8
  88. package/docs/reference/classes/NotImplementedError.md +1 -1
  89. package/docs/reference/classes/ObjectHelper.md +2 -2
  90. package/docs/reference/classes/SharedObjectBuffer.md +192 -0
  91. package/docs/reference/classes/SharedStore.md +2 -2
  92. package/docs/reference/classes/StringHelper.md +16 -13
  93. package/docs/reference/classes/ValidationError.md +1 -1
  94. package/docs/reference/index.md +5 -0
  95. package/docs/reference/interfaces/IComponent.md +2 -2
  96. package/docs/reference/interfaces/ILocale.md +1 -1
  97. package/docs/reference/interfaces/ISharedObjectBufferOptions.md +33 -0
  98. package/docs/reference/interfaces/ISharedObjectBufferWorkerMessage.md +44 -0
  99. package/docs/reference/interfaces/IValidationFailure.md +1 -1
  100. package/docs/reference/type-aliases/SharedObjectBufferMessageTypes.md +5 -0
  101. package/docs/reference/variables/SharedObjectBufferMessageTypes.md +13 -0
  102. package/locales/en.json +10 -2
  103. package/package.json +4 -4
@@ -32,11 +32,7 @@ The value to coerce.
32
32
 
33
33
  `string` \| `undefined`
34
34
 
35
- The value if it can be coerced.
36
-
37
- #### Throws
38
-
39
- TypeError If the value can not be coerced.
35
+ The coerced string, or undefined if the value cannot be coerced.
40
36
 
41
37
  ***
42
38
 
@@ -58,11 +54,7 @@ The value to coerce.
58
54
 
59
55
  `number` \| `undefined`
60
56
 
61
- The value if it can be coerced.
62
-
63
- #### Throws
64
-
65
- TypeError If the value can not be coerced.
57
+ The coerced number, or undefined if the value cannot be coerced.
66
58
 
67
59
  ***
68
60
 
@@ -84,11 +76,7 @@ The value to coerce.
84
76
 
85
77
  `number` \| `undefined`
86
78
 
87
- The value if it can be coerced.
88
-
89
- #### Throws
90
-
91
- TypeError If the value can not be coerced.
79
+ The coerced integer, or undefined if the value cannot be coerced.
92
80
 
93
81
  ***
94
82
 
@@ -110,11 +98,7 @@ The value to coerce.
110
98
 
111
99
  `bigint` \| `undefined`
112
100
 
113
- The value if it can be coerced.
114
-
115
- #### Throws
116
-
117
- TypeError If the value can not be coerced.
101
+ The coerced bigint, or undefined if the value cannot be coerced.
118
102
 
119
103
  ***
120
104
 
@@ -136,11 +120,7 @@ The value to coerce.
136
120
 
137
121
  `boolean` \| `undefined`
138
122
 
139
- The value if it can be coerced.
140
-
141
- #### Throws
142
-
143
- TypeError If the value can not be coerced.
123
+ The coerced boolean, or undefined if the value cannot be coerced.
144
124
 
145
125
  ***
146
126
 
@@ -162,11 +142,7 @@ The value to coerce.
162
142
 
163
143
  `Date` \| `undefined`
164
144
 
165
- The value if it can be coerced.
166
-
167
- #### Throws
168
-
169
- TypeError If the value can not be coerced.
145
+ The coerced date, or undefined if the value cannot be coerced.
170
146
 
171
147
  ***
172
148
 
@@ -188,11 +164,7 @@ The value to coerce.
188
164
 
189
165
  `Date` \| `undefined`
190
166
 
191
- The value if it can be coerced.
192
-
193
- #### Throws
194
-
195
- TypeError If the value can not be coerced.
167
+ The coerced date/time, or undefined if the value cannot be coerced.
196
168
 
197
169
  ***
198
170
 
@@ -214,11 +186,7 @@ The value to coerce.
214
186
 
215
187
  `Date` \| `undefined`
216
188
 
217
- The value if it can be coerced.
218
-
219
- #### Throws
220
-
221
- TypeError If the value can not be coerced.
189
+ The coerced time, or undefined if the value cannot be coerced.
222
190
 
223
191
  ***
224
192
 
@@ -246,11 +214,7 @@ The value to coerce.
246
214
 
247
215
  `T` \| `undefined`
248
216
 
249
- The value if it can be coerced.
250
-
251
- #### Throws
252
-
253
- TypeError If the value can not be coerced.
217
+ The coerced object, or undefined if the value cannot be coerced.
254
218
 
255
219
  ***
256
220
 
@@ -272,11 +236,7 @@ The value to coerce.
272
236
 
273
237
  `Uint8Array`\<`ArrayBufferLike`\> \| `undefined`
274
238
 
275
- The value if it can be coerced.
276
-
277
- #### Throws
278
-
279
- TypeError If the value can not be coerced.
239
+ The coerced Uint8Array, or undefined if the value cannot be coerced.
280
240
 
281
241
  ***
282
242
 
@@ -26,7 +26,7 @@ Runtime name for the class.
26
26
 
27
27
  > `static` **compress**(`bytes`, `type`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
28
28
 
29
- Compress bytes using GZIP.
29
+ Compress bytes using the specified compression type.
30
30
 
31
31
  #### Parameters
32
32
 
@@ -48,7 +48,7 @@ Any additional information for the error.
48
48
 
49
49
  `unknown`
50
50
 
51
- The cause or the error if we have wrapped another error.
51
+ The cause of the error if we have wrapped another error.
52
52
 
53
53
  #### Returns
54
54
 
@@ -18,7 +18,7 @@ Error helper functions.
18
18
 
19
19
  > `static` **formatErrors**(`error`, `options?`): `string`[]
20
20
 
21
- Format Errors and returns just their messages.
21
+ Format errors and returns just their messages.
22
22
 
23
23
  #### Parameters
24
24
 
@@ -72,6 +72,34 @@ All the factories.
72
72
 
73
73
  ***
74
74
 
75
+ ### getFactory() {#getfactory}
76
+
77
+ > `static` **getFactory**\<`T`\>(`typeName`): `Factory`\<`T`\> \| `undefined`
78
+
79
+ Get a specific factory by type name.
80
+
81
+ #### Type Parameters
82
+
83
+ ##### T
84
+
85
+ `T` = `unknown`
86
+
87
+ #### Parameters
88
+
89
+ ##### typeName
90
+
91
+ `string`
92
+
93
+ The type name of the factory.
94
+
95
+ #### Returns
96
+
97
+ `Factory`\<`T`\> \| `undefined`
98
+
99
+ The factory instance if it exists, otherwise undefined.
100
+
101
+ ***
102
+
75
103
  ### resetFactories() {#resetfactories}
76
104
 
77
105
  > `static` **resetFactories**(): `void`
@@ -1,6 +1,6 @@
1
1
  # Class: GeneralError
2
2
 
3
- Class to handle errors.
3
+ Class to handle general-purpose errors.
4
4
 
5
5
  ## Extends
6
6
 
@@ -536,6 +536,114 @@ GuardError If the value does not match the assertion.
536
536
 
537
537
  ***
538
538
 
539
+ ### dateString() {#datestring}
540
+
541
+ > `static` **dateString**(`source`, `property`, `value`): `asserts value is string`
542
+
543
+ Is the property a date-only string (ISO 8601 date, no time component).
544
+
545
+ #### Parameters
546
+
547
+ ##### source
548
+
549
+ `string`
550
+
551
+ The source of the error.
552
+
553
+ ##### property
554
+
555
+ `string`
556
+
557
+ The name of the property.
558
+
559
+ ##### value
560
+
561
+ `unknown`
562
+
563
+ The value to test.
564
+
565
+ #### Returns
566
+
567
+ `asserts value is string`
568
+
569
+ #### Throws
570
+
571
+ GuardError If the value does not match the assertion.
572
+
573
+ ***
574
+
575
+ ### dateTimeString() {#datetimestring}
576
+
577
+ > `static` **dateTimeString**(`source`, `property`, `value`): `asserts value is string`
578
+
579
+ Is the property a date-time string (ISO 8601 with T separator).
580
+
581
+ #### Parameters
582
+
583
+ ##### source
584
+
585
+ `string`
586
+
587
+ The source of the error.
588
+
589
+ ##### property
590
+
591
+ `string`
592
+
593
+ The name of the property.
594
+
595
+ ##### value
596
+
597
+ `unknown`
598
+
599
+ The value to test.
600
+
601
+ #### Returns
602
+
603
+ `asserts value is string`
604
+
605
+ #### Throws
606
+
607
+ GuardError If the value does not match the assertion.
608
+
609
+ ***
610
+
611
+ ### timeString() {#timestring}
612
+
613
+ > `static` **timeString**(`source`, `property`, `value`): `asserts value is string`
614
+
615
+ Is the property a time-only string (ISO 8601 time, no date component).
616
+
617
+ #### Parameters
618
+
619
+ ##### source
620
+
621
+ `string`
622
+
623
+ The source of the error.
624
+
625
+ ##### property
626
+
627
+ `string`
628
+
629
+ The name of the property.
630
+
631
+ ##### value
632
+
633
+ `unknown`
634
+
635
+ The value to test.
636
+
637
+ #### Returns
638
+
639
+ `asserts value is string`
640
+
641
+ #### Throws
642
+
643
+ GuardError If the value does not match the assertion.
644
+
645
+ ***
646
+
539
647
  ### timestampMilliseconds() {#timestampmilliseconds}
540
648
 
541
649
  > `static` **timestampMilliseconds**(`source`, `property`, `value`): `asserts value is number`
@@ -32,7 +32,7 @@ The value to test.
32
32
 
33
33
  `value is undefined`
34
34
 
35
- True if the value is a empty.
35
+ True if the value is undefined.
36
36
 
37
37
  ***
38
38
 
@@ -54,7 +54,7 @@ The value to test.
54
54
 
55
55
  `value is null`
56
56
 
57
- True if the value is a empty.
57
+ True if the value is null.
58
58
 
59
59
  ***
60
60
 
@@ -76,7 +76,7 @@ The value to test.
76
76
 
77
77
  value is null \| undefined
78
78
 
79
- True if the value is a empty.
79
+ True if the value is null or undefined.
80
80
 
81
81
  ***
82
82
 
@@ -84,7 +84,7 @@ True if the value is a empty.
84
84
 
85
85
  > `static` **notEmpty**(`value`): `boolean`
86
86
 
87
- Is the property is not null or undefined.
87
+ Is the property not null or undefined.
88
88
 
89
89
  #### Parameters
90
90
 
@@ -98,7 +98,7 @@ The value to test.
98
98
 
99
99
  `boolean`
100
100
 
101
- True if the value is a not empty.
101
+ True if the value is not null or undefined.
102
102
 
103
103
  ***
104
104
 
@@ -128,7 +128,7 @@ True if the value is a string.
128
128
 
129
129
  > `static` **stringValue**(`value`): `value is string`
130
130
 
131
- Is the value a string.
131
+ Is the value a non-empty string.
132
132
 
133
133
  #### Parameters
134
134
 
@@ -142,7 +142,7 @@ The value to test.
142
142
 
143
143
  `value is string`
144
144
 
145
- True if the value is a string.
145
+ True if the value is a non-empty string.
146
146
 
147
147
  ***
148
148
 
@@ -512,7 +512,7 @@ The value to test.
512
512
 
513
513
  `value is number`
514
514
 
515
- True if the value is a date.
515
+ True if the value is a timestamp in seconds.
516
516
 
517
517
  ***
518
518
 
@@ -534,7 +534,7 @@ The value to test.
534
534
 
535
535
  `value is number`
536
536
 
537
- True if the value is a date.
537
+ True if the value is a timestamp in milliseconds.
538
538
 
539
539
  ***
540
540
 
@@ -105,7 +105,7 @@ The object to patch.
105
105
 
106
106
  [`IPatchOperation`](../interfaces/IPatchOperation.md)[]
107
107
 
108
- The second object.
108
+ The patch operations to apply.
109
109
 
110
110
  #### Returns
111
111
 
@@ -37,14 +37,14 @@ Runtime name for the class.
37
37
 
38
38
  ### lock() {#lock}
39
39
 
40
- > `static` **lock**(`key`, `options?`): `boolean`
40
+ > `static` **lock**(`key`, `options?`): `Promise`\<`boolean`\>
41
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.
42
+ Acquires a lock for the given key without blocking the event loop. If the lock is already
43
+ held, it suspends the current async task until the lock is released or the timeout is reached.
44
+ Use this in async single-threaded contexts (e.g. the main thread or a Fastify route handler)
45
+ where calling the synchronous lock() would freeze the event loop and deadlock.
46
+ The lock is not re-entrant: if the same context holds the key and calls lockAsync() again on
47
+ the same key, it will suspend until the timeout elapses.
48
48
 
49
49
  #### Parameters
50
50
 
@@ -72,7 +72,7 @@ Whether to throw an error if the lock could not be acquired within the timeout,
72
72
 
73
73
  #### Returns
74
74
 
75
- `boolean`
75
+ `Promise`\<`boolean`\>
76
76
 
77
77
  True if the lock was acquired, false if it timed out and throwOnTimeout is false.
78
78
 
@@ -1,6 +1,6 @@
1
1
  # Class: NotImplementedError
2
2
 
3
- Class to handle errors.
3
+ Class to handle errors raised when a method has not been implemented.
4
4
 
5
5
  ## Extends
6
6
 
@@ -506,7 +506,7 @@ The object without the omitted keys, or undefined if the input was undefined.
506
506
 
507
507
  > `static` **toExtended**(`obj`): `any`
508
508
 
509
- Converter the non JSON primitives to extended types.
509
+ Convert the non JSON primitives to extended types.
510
510
 
511
511
  #### Parameters
512
512
 
@@ -528,7 +528,7 @@ The object with extended properties.
528
528
 
529
529
  > `static` **fromExtended**(`obj`): `any`
530
530
 
531
- Converter the extended types to non JSON primitives.
531
+ Convert the extended types to non JSON primitives.
532
532
 
533
533
  #### Parameters
534
534
 
@@ -0,0 +1,192 @@
1
+ # Class: SharedObjectBuffer
2
+
3
+ Manages per-object SharedArrayBuffers that store objects as UTF-8 JSON.
4
+ Buffer layout: 4-byte Int32 header (current data byte length) followed by the JSON-encoded object.
5
+ Buffers are explicitly created with create and cached in SharedStore.
6
+ On a worker thread an existing buffer is fetched via a MessagePort handshake
7
+ (same protocol as Mutex) and cached locally.
8
+ Buffers grow automatically when the payload exceeds capacity; when the payload drops well below
9
+ capacity the buffer is replaced with a smaller one. The caller must hold the objectId-keyed Mutex
10
+ around every read and write. The main thread's worker message handler must forward messages to
11
+ both Mutex.handleWorkerMessage and SharedObjectBuffer.handleWorkerMessage.
12
+
13
+ ## Constructors
14
+
15
+ ### Constructor
16
+
17
+ > **new SharedObjectBuffer**(): `SharedObjectBuffer`
18
+
19
+ #### Returns
20
+
21
+ `SharedObjectBuffer`
22
+
23
+ ## Properties
24
+
25
+ ### CLASS\_NAME {#class_name}
26
+
27
+ > `readonly` `static` **CLASS\_NAME**: `string`
28
+
29
+ Runtime name for the class.
30
+
31
+ ***
32
+
33
+ ### DEFAULT\_CAPACITY\_BYTES {#default_capacity_bytes}
34
+
35
+ > `readonly` `static` **DEFAULT\_CAPACITY\_BYTES**: `number`
36
+
37
+ Default payload capacity per object (1 MiB). The first caller that creates the buffer
38
+ for an object determines its initial capacity; later callers that pass a different value
39
+ are ignored.
40
+
41
+ ***
42
+
43
+ ### MAX\_CAPACITY\_BYTES {#max_capacity_bytes}
44
+
45
+ > `readonly` `static` **MAX\_CAPACITY\_BYTES**: `number`
46
+
47
+ Default upper bound for how large a buffer may grow (256 MiB).
48
+ Override per-object via the maxCapacityBytes option on create.
49
+
50
+ ## Methods
51
+
52
+ ### create() {#create}
53
+
54
+ > `static` **create**(`objectId`, `options?`): `Promise`\<`void`\>
55
+
56
+ Create the buffer for the given objectId if it does not already exist.
57
+ Must be called while holding Mutex.lock(objectId).
58
+
59
+ #### Parameters
60
+
61
+ ##### objectId
62
+
63
+ `string`
64
+
65
+ The object id that identifies the buffer.
66
+
67
+ ##### options?
68
+
69
+ [`ISharedObjectBufferOptions`](../interfaces/ISharedObjectBufferOptions.md)
70
+
71
+ Optional capacity configuration used when creating the buffer.
72
+
73
+ #### Returns
74
+
75
+ `Promise`\<`void`\>
76
+
77
+ ***
78
+
79
+ ### read() {#read}
80
+
81
+ > `static` **read**\<`T`\>(`objectId`): `Promise`\<`T` \| `undefined`\>
82
+
83
+ Read and decode the object stored for the given objectId.
84
+ Must be called while holding Mutex.lock(objectId).
85
+
86
+ #### Type Parameters
87
+
88
+ ##### T
89
+
90
+ `T`
91
+
92
+ #### Parameters
93
+
94
+ ##### objectId
95
+
96
+ `string`
97
+
98
+ The object id that identifies the buffer.
99
+
100
+ #### Returns
101
+
102
+ `Promise`\<`T` \| `undefined`\>
103
+
104
+ The stored object, or undefined when nothing has been written yet.
105
+
106
+ ***
107
+
108
+ ### write() {#write}
109
+
110
+ > `static` **write**\<`T`\>(`objectId`, `value`): `Promise`\<`void`\>
111
+
112
+ Encode and write the object into the buffer for the given objectId.
113
+ The buffer must already exist, usually by calling create first.
114
+ When the encoded payload exceeds the current buffer capacity the buffer is grown
115
+ in-place via SharedArrayBuffer.grow so every thread with a reference sees the
116
+ new size without any pointer swap. When the payload is smaller than
117
+ _SHRINK_THRESHOLD of the current capacity and the capacity exceeds
118
+ DEFAULT_CAPACITY_BYTES, the buffer is replaced with a smaller one on the calling thread.
119
+ Must be called while holding Mutex.lock(objectId).
120
+
121
+ #### Type Parameters
122
+
123
+ ##### T
124
+
125
+ `T`
126
+
127
+ #### Parameters
128
+
129
+ ##### objectId
130
+
131
+ `string`
132
+
133
+ The object id that identifies the buffer.
134
+
135
+ ##### value
136
+
137
+ `T`
138
+
139
+ The object to persist.
140
+
141
+ #### Returns
142
+
143
+ `Promise`\<`void`\>
144
+
145
+ ***
146
+
147
+ ### remove() {#remove}
148
+
149
+ > `static` **remove**(`objectId`): `void`
150
+
151
+ Remove the stored object and release the buffer for the given objectId.
152
+ The entry is deleted from the local cache so subsequent reads or writes will
153
+ create or fetch a fresh buffer. Worker threads that have cached the old buffer
154
+ reference continue using it until they restart or re-request via the worker protocol.
155
+ Must be called while holding Mutex.lock(objectId).
156
+
157
+ #### Parameters
158
+
159
+ ##### objectId
160
+
161
+ `string`
162
+
163
+ The object id that identifies the buffer.
164
+
165
+ #### Returns
166
+
167
+ `void`
168
+
169
+ ***
170
+
171
+ ### handleWorkerMessage() {#handleworkermessage}
172
+
173
+ > `static` **handleWorkerMessage**(`msg`): `boolean`
174
+
175
+ Inspect a message from a worker thread and, if it is a SharedObjectBuffer
176
+ buffer-fetch request, respond to it synchronously.
177
+ Call this from the main thread's worker message handler alongside
178
+ Mutex.handleWorkerMessage.
179
+
180
+ #### Parameters
181
+
182
+ ##### msg
183
+
184
+ `unknown`
185
+
186
+ The raw message received from the worker.
187
+
188
+ #### Returns
189
+
190
+ `boolean`
191
+
192
+ True if the message was a SharedObjectBuffer protocol message, false otherwise.
@@ -1,7 +1,7 @@
1
1
  # Class: SharedStore
2
2
 
3
- Provide a store for shared objects which can be accesses through multiple
4
- instance loads of a packages.
3
+ Provide a store for shared objects which can be accessed through multiple
4
+ instance loads of a package.
5
5
 
6
6
  ## Constructors
7
7
 
@@ -297,19 +297,6 @@ The string split into words.
297
297
  > `static` **isUtf8**(`data`): `boolean`
298
298
 
299
299
  Check if a Node.js Buffer or Uint8Array is UTF-8.
300
- Url https://tools.ietf.org/html/rfc3629
301
- Source https://github.com/hcodes/isutf8
302
- UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4.
303
- UTF8-1 = %x00-7F.
304
- UTF8-2 = %xC2-DF UTF8-tail.
305
- UTF8-3 = %xE0 %xA0-BF UTF8-tail.
306
- - %xE1-EC 2( UTF8-tail ).
307
- - %xED %x80-9F UTF8-tail.
308
- - %xEE-EF 2( UTF8-tail ).
309
- UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ).
310
- - %xF1-F3 3( UTF8-tail ).
311
- - %xF4 %x80-8F 2( UTF8-tail ).
312
- UTF8-tail = %x80-BF.
313
300
 
314
301
  #### Parameters
315
302
 
@@ -324,3 +311,19 @@ The data to check.
324
311
  `boolean`
325
312
 
326
313
  True if the data is utf8.
314
+
315
+ #### See
316
+
317
+ - https://tools.ietf.org/html/rfc3629
318
+ - https://github.com/hcodes/isutf8
319
+ UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4.
320
+ UTF8-1 = %x00-7F.
321
+ UTF8-2 = %xC2-DF UTF8-tail.
322
+ UTF8-3 = %xE0 %xA0-BF UTF8-tail.
323
+ - %xE1-EC 2( UTF8-tail ).
324
+ - %xED %x80-9F UTF8-tail.
325
+ - %xEE-EF 2( UTF8-tail ).
326
+ UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ).
327
+ - %xF1-F3 3( UTF8-tail ).
328
+ - %xF4 %x80-8F 2( UTF8-tail ).
329
+ UTF8-tail = %x80-BF.