@neurodevs/node-lsl 17.1.1 → 18.1.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.
Files changed (198) hide show
  1. package/.claude/settings.local.json +10 -0
  2. package/.vscode/launch.json +54 -57
  3. package/.vscode/settings.json +61 -66
  4. package/.vscode/tasks.json +98 -129
  5. package/README.md +20 -44
  6. package/build/__tests__/AbstractPackageTest.d.ts +7 -5
  7. package/build/__tests__/AbstractPackageTest.js +22 -15
  8. package/build/__tests__/AbstractPackageTest.js.map +1 -1
  9. package/build/__tests__/impl/BleDeviceController.test.d.ts +54 -0
  10. package/build/__tests__/impl/BleDeviceController.test.js +333 -0
  11. package/build/__tests__/impl/BleDeviceController.test.js.map +1 -0
  12. package/build/__tests__/impl/LslEventMarkerEmitter.test.d.ts +34 -0
  13. package/build/__tests__/impl/LslEventMarkerEmitter.test.js +243 -0
  14. package/build/__tests__/impl/LslEventMarkerEmitter.test.js.map +1 -0
  15. package/build/__tests__/impl/LslStreamInfo.test.d.ts +0 -3
  16. package/build/__tests__/impl/LslStreamInfo.test.js +2 -27
  17. package/build/__tests__/impl/LslStreamInfo.test.js.map +1 -1
  18. package/build/__tests__/impl/LslStreamInlet.test.d.ts +20 -8
  19. package/build/__tests__/impl/LslStreamInlet.test.js +224 -69
  20. package/build/__tests__/impl/LslStreamInlet.test.js.map +1 -1
  21. package/build/__tests__/impl/LslStreamOutlet.test.d.ts +3 -7
  22. package/build/__tests__/impl/LslStreamOutlet.test.js +40 -50
  23. package/build/__tests__/impl/LslStreamOutlet.test.js.map +1 -1
  24. package/build/__tests__/impl/LslWebSocketBridge.test.js +19 -20
  25. package/build/__tests__/impl/LslWebSocketBridge.test.js.map +1 -1
  26. package/build/assertions.d.ts +1 -1
  27. package/build/assertions.js.map +1 -1
  28. package/build/impl/LslEventMarkerEmitter.d.ts +35 -0
  29. package/build/impl/LslEventMarkerEmitter.js +86 -0
  30. package/build/impl/LslEventMarkerEmitter.js.map +1 -0
  31. package/build/impl/LslStreamInfo.d.ts +4 -8
  32. package/build/impl/LslStreamInfo.js +8 -21
  33. package/build/impl/LslStreamInfo.js.map +1 -1
  34. package/build/impl/LslStreamInlet.d.ts +31 -50
  35. package/build/impl/LslStreamInlet.js +79 -149
  36. package/build/impl/LslStreamInlet.js.map +1 -1
  37. package/build/impl/LslStreamOutlet.d.ts +15 -18
  38. package/build/impl/LslStreamOutlet.js +39 -47
  39. package/build/impl/LslStreamOutlet.js.map +1 -1
  40. package/build/impl/LslWebSocketBridge.d.ts +4 -5
  41. package/build/impl/LslWebSocketBridge.js +10 -10
  42. package/build/impl/LslWebSocketBridge.js.map +1 -1
  43. package/build/impl/controllers/BleDeviceController.d.ts +58 -0
  44. package/build/impl/controllers/BleDeviceController.js +145 -0
  45. package/build/impl/controllers/BleDeviceController.js.map +1 -0
  46. package/build/impl/workers/inlet/LslStreamInlet.worker.d.ts +22 -0
  47. package/build/impl/workers/inlet/LslStreamInlet.worker.js +42 -0
  48. package/build/impl/workers/inlet/LslStreamInlet.worker.js.map +1 -0
  49. package/build/impl/workers/inlet/StreamInletWorker.d.ts +73 -0
  50. package/build/impl/workers/inlet/StreamInletWorker.js +253 -0
  51. package/build/impl/workers/inlet/StreamInletWorker.js.map +1 -0
  52. package/build/impl/workers/outlet/LslStreamOutlet.worker.d.ts +32 -0
  53. package/build/impl/workers/outlet/LslStreamOutlet.worker.js +82 -0
  54. package/build/impl/workers/outlet/LslStreamOutlet.worker.js.map +1 -0
  55. package/build/index.d.ts +14 -14
  56. package/build/index.js +16 -16
  57. package/build/index.js.map +1 -1
  58. package/build/scripts/discoverMuse.js +40 -0
  59. package/build/scripts/discoverMuse.js.map +1 -0
  60. package/build/scripts/finalizeHandles.d.ts +2 -0
  61. package/build/scripts/finalizeHandles.js +48 -0
  62. package/build/scripts/finalizeHandles.js.map +1 -0
  63. package/build/scripts/runLslEventMarkerEmitter.d.ts +1 -0
  64. package/build/scripts/runLslEventMarkerEmitter.js +11 -0
  65. package/build/scripts/runLslEventMarkerEmitter.js.map +1 -0
  66. package/build/scripts/runMuse.d.ts +1 -0
  67. package/build/scripts/runMuse.js +40 -0
  68. package/build/scripts/runMuse.js.map +1 -0
  69. package/build/scripts/runOutletToInlet.js +7 -6
  70. package/build/scripts/runOutletToInlet.js.map +1 -1
  71. package/build/scripts/testDestroyOutlet.d.ts +1 -0
  72. package/build/scripts/testDestroyOutlet.js +4 -0
  73. package/build/scripts/testDestroyOutlet.js.map +1 -0
  74. package/build/testDoubles/BleController/FakeBleController.d.ts +24 -0
  75. package/build/testDoubles/BleController/FakeBleController.js +42 -0
  76. package/build/testDoubles/BleController/FakeBleController.js.map +1 -0
  77. package/build/testDoubles/BleController/SpyBleController.d.ts +14 -0
  78. package/build/testDoubles/BleController/SpyBleController.js +48 -0
  79. package/build/testDoubles/BleController/SpyBleController.js.map +1 -0
  80. package/build/testDoubles/EventMarkerEmitter/FakeEventMarkerEmitter.d.ts +17 -0
  81. package/build/testDoubles/EventMarkerEmitter/FakeEventMarkerEmitter.js +30 -0
  82. package/build/testDoubles/EventMarkerEmitter/FakeEventMarkerEmitter.js.map +1 -0
  83. package/build/testDoubles/EventMarkerEmitter/SpyEventMarkerEmitter.d.ts +10 -0
  84. package/build/testDoubles/EventMarkerEmitter/SpyEventMarkerEmitter.js +23 -0
  85. package/build/testDoubles/EventMarkerEmitter/SpyEventMarkerEmitter.js.map +1 -0
  86. package/build/testDoubles/EventMarkerEmitter/ThrowingEventMarkerEmitter.d.ts +9 -0
  87. package/build/testDoubles/EventMarkerEmitter/ThrowingEventMarkerEmitter.js +19 -0
  88. package/build/testDoubles/EventMarkerEmitter/ThrowingEventMarkerEmitter.js.map +1 -0
  89. package/build/testDoubles/StreamInfo/FakeStreamInfo.d.ts +3 -3
  90. package/build/testDoubles/StreamInfo/FakeStreamInfo.js +3 -3
  91. package/build/testDoubles/StreamInfo/FakeStreamInfo.js.map +1 -1
  92. package/build/testDoubles/StreamInlet/FakeStreamInlet.d.ts +8 -10
  93. package/build/testDoubles/StreamInlet/FakeStreamInlet.js +6 -7
  94. package/build/testDoubles/StreamInlet/FakeStreamInlet.js.map +1 -1
  95. package/build/testDoubles/StreamInlet/SpyStreamInlet.d.ts +2 -5
  96. package/build/testDoubles/StreamInlet/SpyStreamInlet.js +2 -8
  97. package/build/testDoubles/StreamInlet/SpyStreamInlet.js.map +1 -1
  98. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.d.ts +7 -9
  99. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js +8 -8
  100. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js.map +1 -1
  101. package/build/testDoubles/WebSocketBridge/FakeWebSocketBridge.d.ts +1 -1
  102. package/build/testDoubles/WebSocketBridge/FakeWebSocketBridge.js +1 -1
  103. package/build/testDoubles/WebSocketBridge/FakeWebSocketBridge.js.map +1 -1
  104. package/build/testDoubles/WorkerThreads/FakeWorker.d.ts +27 -0
  105. package/build/testDoubles/WorkerThreads/FakeWorker.js +67 -0
  106. package/build/testDoubles/WorkerThreads/FakeWorker.js.map +1 -0
  107. package/build/testDoubles/generateRandomOutletOptions.js +1 -1
  108. package/build/testDoubles/generateRandomOutletOptions.js.map +1 -1
  109. package/build/validations.js +0 -2
  110. package/build/validations.js.map +1 -1
  111. package/eslint.config.js +3 -0
  112. package/package.json +27 -49
  113. package/prettier.config.js +3 -0
  114. package/src/__tests__/AbstractPackageTest.ts +38 -21
  115. package/src/__tests__/impl/BleDeviceController.test.ts +492 -0
  116. package/src/__tests__/impl/LslEventMarkerEmitter.test.ts +323 -0
  117. package/src/__tests__/impl/LslStreamInfo.test.ts +3 -40
  118. package/src/__tests__/impl/LslStreamInlet.test.ts +344 -97
  119. package/src/__tests__/impl/LslStreamOutlet.test.ts +65 -73
  120. package/src/__tests__/impl/LslWebSocketBridge.test.ts +22 -21
  121. package/src/assertions.ts +2 -1
  122. package/src/impl/LslEventMarkerEmitter.ts +133 -0
  123. package/src/impl/LslStreamInfo.ts +17 -29
  124. package/src/impl/LslStreamInlet.ts +102 -215
  125. package/src/impl/LslStreamOutlet.ts +54 -78
  126. package/src/impl/LslWebSocketBridge.ts +14 -14
  127. package/src/impl/controllers/BleDeviceController.ts +223 -0
  128. package/src/impl/workers/inlet/LslStreamInlet.worker.ts +74 -0
  129. package/src/impl/workers/inlet/StreamInletWorker.ts +348 -0
  130. package/src/impl/workers/outlet/LslStreamOutlet.worker.ts +144 -0
  131. package/src/index.ts +16 -16
  132. package/src/scripts/discoverMuse.ts +50 -0
  133. package/src/scripts/finalizeHandles.ts +63 -0
  134. package/src/scripts/runLslEventMarkerEmitter.ts +15 -0
  135. package/src/scripts/runMuse.ts +50 -0
  136. package/src/scripts/runOutletToInlet.ts +10 -8
  137. package/src/scripts/testDestroyOutlet.ts +5 -0
  138. package/src/testDoubles/BleController/FakeBleController.ts +70 -0
  139. package/src/testDoubles/BleController/SpyBleController.ts +61 -0
  140. package/src/testDoubles/EventMarkerEmitter/FakeEventMarkerEmitter.ts +46 -0
  141. package/src/testDoubles/EventMarkerEmitter/SpyEventMarkerEmitter.ts +31 -0
  142. package/src/testDoubles/EventMarkerEmitter/ThrowingEventMarkerEmitter.ts +29 -0
  143. package/src/testDoubles/StreamInfo/FakeStreamInfo.ts +4 -4
  144. package/src/testDoubles/StreamInlet/FakeStreamInlet.ts +11 -17
  145. package/src/testDoubles/StreamInlet/SpyStreamInlet.ts +3 -16
  146. package/src/testDoubles/StreamOutlet/FakeStreamOutlet.ts +15 -15
  147. package/src/testDoubles/WebSocketBridge/FakeWebSocketBridge.ts +1 -1
  148. package/src/testDoubles/WorkerThreads/FakeWorker.ts +99 -0
  149. package/src/testDoubles/generateRandomOutletOptions.ts +2 -1
  150. package/src/validations.ts +0 -2
  151. package/tsconfig.json +23 -27
  152. package/build/.spruce/settings.json +0 -11
  153. package/build/__tests__/impl/LiblslAdapter.test.d.ts +0 -79
  154. package/build/__tests__/impl/LiblslAdapter.test.js +0 -688
  155. package/build/__tests__/impl/LiblslAdapter.test.js.map +0 -1
  156. package/build/__tests__/impl/LslEventMarkerOutlet.test.d.ts +0 -21
  157. package/build/__tests__/impl/LslEventMarkerOutlet.test.js +0 -160
  158. package/build/__tests__/impl/LslEventMarkerOutlet.test.js.map +0 -1
  159. package/build/handleError.d.ts +0 -8
  160. package/build/handleError.js +0 -25
  161. package/build/handleError.js.map +0 -1
  162. package/build/impl/LiblslAdapter.d.ts +0 -154
  163. package/build/impl/LiblslAdapter.js +0 -317
  164. package/build/impl/LiblslAdapter.js.map +0 -1
  165. package/build/impl/LslEventMarkerOutlet.d.ts +0 -28
  166. package/build/impl/LslEventMarkerOutlet.js +0 -63
  167. package/build/impl/LslEventMarkerOutlet.js.map +0 -1
  168. package/build/scripts/runLslEventMarkerOutlet.js +0 -18
  169. package/build/scripts/runLslEventMarkerOutlet.js.map +0 -1
  170. package/build/testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet.d.ts +0 -13
  171. package/build/testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet.js +0 -26
  172. package/build/testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet.js.map +0 -1
  173. package/build/testDoubles/EventMarkerOutlet/MockEventMarkerOutlet.d.ts +0 -17
  174. package/build/testDoubles/EventMarkerOutlet/MockEventMarkerOutlet.js +0 -46
  175. package/build/testDoubles/EventMarkerOutlet/MockEventMarkerOutlet.js.map +0 -1
  176. package/build/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.d.ts +0 -9
  177. package/build/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.js +0 -19
  178. package/build/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.js.map +0 -1
  179. package/build/testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet.d.ts +0 -9
  180. package/build/testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet.js +0 -19
  181. package/build/testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet.js.map +0 -1
  182. package/build/testDoubles/Liblsl/FakeLiblsl.d.ts +0 -50
  183. package/build/testDoubles/Liblsl/FakeLiblsl.js +0 -126
  184. package/build/testDoubles/Liblsl/FakeLiblsl.js.map +0 -1
  185. package/eslint.config.mjs +0 -3
  186. package/src/.spruce/settings.json +0 -11
  187. package/src/__tests__/impl/LiblslAdapter.test.ts +0 -817
  188. package/src/__tests__/impl/LslEventMarkerOutlet.test.ts +0 -195
  189. package/src/handleError.ts +0 -24
  190. package/src/impl/LiblslAdapter.ts +0 -543
  191. package/src/impl/LslEventMarkerOutlet.ts +0 -97
  192. package/src/scripts/runLslEventMarkerOutlet.ts +0 -23
  193. package/src/testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet.ts +0 -36
  194. package/src/testDoubles/EventMarkerOutlet/MockEventMarkerOutlet.ts +0 -75
  195. package/src/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.ts +0 -24
  196. package/src/testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet.ts +0 -28
  197. package/src/testDoubles/Liblsl/FakeLiblsl.ts +0 -182
  198. /package/build/scripts/{runLslEventMarkerOutlet.d.ts → discoverMuse.d.ts} +0 -0
@@ -1,75 +0,0 @@
1
- import { assert } from '@neurodevs/node-tdd'
2
-
3
- import { LslSample } from 'impl/LiblslAdapter.js'
4
- import {
5
- DurationMarker,
6
- EventMarkerOutlet,
7
- } from '../../impl/LslEventMarkerOutlet.js'
8
-
9
- export default class MockEventMarkerOutlet implements EventMarkerOutlet {
10
- private didPushMarkers = false
11
- private pushedMarkers?: DurationMarker[]
12
- private didPushSamples = false
13
- private pushedSamples?: LslSample[]
14
-
15
- public stop() {
16
- throw new Error('Method not implemented.')
17
- }
18
-
19
- public destroy() {
20
- throw new Error('Method not implemented.')
21
- }
22
-
23
- public pushMarker(_markerName: string) {
24
- throw new Error('Method not implemented.')
25
- }
26
-
27
- public pushSample(sample: LslSample) {
28
- if (!this.didPushSamples) {
29
- this.didPushSamples = true
30
- this.pushedSamples = []
31
- }
32
- this.pushedSamples?.push(sample)
33
- }
34
-
35
- public async pushMarkers(markers: DurationMarker[]) {
36
- this.didPushMarkers = true
37
- this.pushedMarkers = markers
38
- }
39
-
40
- public assertDidPushSamples(samples?: LslSample[]) {
41
- assert.isTrue(
42
- this.didPushSamples,
43
- `Expected to have pushed samples but didn't. Try 'outlet.pushSample(...)'`
44
- )
45
-
46
- if (samples) {
47
- assert.isEqualDeep(this.pushedSamples, samples)
48
- }
49
- }
50
-
51
- public assertDidNotPushSamples() {
52
- assert.isFalse(
53
- this.didPushSamples,
54
- `Expected to NOT have pushed samples but did. Try 'outlet.pushSample(...)'`
55
- )
56
- }
57
-
58
- public assertDidPushMarkers(markers?: DurationMarker[]) {
59
- assert.isTrue(
60
- this.didPushMarkers,
61
- `Expected to have pushed markers but didn't. Try 'outlet.pushMarkers(...)'`
62
- )
63
-
64
- if (markers) {
65
- assert.isEqualDeep(this.pushedMarkers, markers)
66
- }
67
- }
68
-
69
- public assertDidNotPushMarkers() {
70
- assert.isFalse(
71
- this.didPushMarkers,
72
- `Expected to NOT have pushed markers but did. Try 'outlet.pushMarkers(...)'`
73
- )
74
- }
75
- }
@@ -1,24 +0,0 @@
1
- import LslEventMarkerOutlet from '../../impl/LslEventMarkerOutlet.js'
2
- import { StreamOutlet } from '../../impl/LslStreamOutlet.js'
3
-
4
- export default class SpyEventMarkerOutlet extends LslEventMarkerOutlet {
5
- public totalWaitTimeMs: number
6
-
7
- public constructor(outlet: StreamOutlet) {
8
- super(outlet)
9
- this.totalWaitTimeMs = 0
10
- }
11
-
12
- public async wait(durationMs: number) {
13
- this.totalWaitTimeMs += durationMs
14
- return Promise.resolve()
15
- }
16
-
17
- public getStreamOutlet() {
18
- return this.outlet
19
- }
20
-
21
- public resetTestDouble() {
22
- this.totalWaitTimeMs = 0
23
- }
24
- }
@@ -1,28 +0,0 @@
1
- import {
2
- DurationMarker,
3
- EventMarkerOutlet,
4
- } from '../../impl/LslEventMarkerOutlet.js'
5
-
6
- export default class ThrowingEventMarkerOutlet implements EventMarkerOutlet {
7
- private errorMsg = 'Intentional throwing: '
8
-
9
- public constructor() {
10
- throw new Error(this.errorMsg + 'constructor')
11
- }
12
-
13
- public async pushMarker(_markerName: string) {
14
- throw new Error(this.errorMsg + 'pushMarker')
15
- }
16
-
17
- public async pushMarkers(_markers: DurationMarker[]) {
18
- throw new Error(this.errorMsg + 'pushMarkers')
19
- }
20
-
21
- public stop() {
22
- throw new Error(this.errorMsg + 'stop')
23
- }
24
-
25
- public destroy() {
26
- throw new Error(this.errorMsg + 'destroy')
27
- }
28
- }
@@ -1,182 +0,0 @@
1
- import generateId from '@neurodevs/generate-id'
2
-
3
- import {
4
- BoundOutlet,
5
- BoundStreamInfo,
6
- CreateStreamInfoOptions,
7
- AppendChannelsToStreamInfoOptions,
8
- CreateOutletOptions,
9
- PushSampleFloatTimestampOptions,
10
- PushSampleStringTimestampOptions,
11
- Liblsl,
12
- CreateInletOptions,
13
- DestroyInletOptions,
14
- BoundInlet,
15
- FlushInletOptions,
16
- PullChunkOptions,
17
- PullSampleOptions,
18
- DestroyStreamInfoOptions,
19
- ResolveByPropOptions,
20
- DestroyOutletOptions,
21
- } from 'impl/LiblslAdapter.js'
22
-
23
- export default class FakeLiblsl implements Liblsl {
24
- public static fakeStreamInfoHandles: BoundStreamInfo[] = []
25
-
26
- public static fakeSamples: Float32Array[] = [
27
- new Float32Array([1, 2, 3]),
28
- new Float32Array([4, 5, 6]),
29
- ]
30
-
31
- public static fakeChunks: Float32Array[] = [
32
- new Float32Array([1, 2, 3, 4, 5, 6]),
33
- new Float32Array([1, 2, 3, 4, 5, 6]),
34
- ]
35
-
36
- public static fakeTimestamps: Float64Array[] = [
37
- new Float64Array([7, 8]),
38
- new Float64Array([7, 8]),
39
- ]
40
-
41
- public static fakeErrorCode = 0
42
-
43
- public liblslPath: string = generateId()
44
-
45
- public fakeSamples = FakeLiblsl.fakeSamples.slice()
46
- public fakeChunks = FakeLiblsl.fakeChunks.slice()
47
- public fakeTimestamps = FakeLiblsl.fakeTimestamps.slice()
48
-
49
- public outlet: BoundOutlet = {} as BoundOutlet
50
- public streamInfo: BoundStreamInfo = {} as BoundStreamInfo
51
-
52
- public lastCreateStreamInfoOptions?: CreateStreamInfoOptions
53
- public lastAppendChannelsToStreamInfoOptions?: AppendChannelsToStreamInfoOptions
54
- public lastDestroyStreamInfoOptions?: DestroyStreamInfoOptions
55
- public lastResolveByPropOptions?: ResolveByPropOptions
56
- public lastCreateOutletOptions?: CreateOutletOptions
57
- public lastPushSampleFloatTimestampOptions?: PushSampleFloatTimestampOptions
58
- public lastPushSampleStringTimestampOptions?: PushSampleStringTimestampOptions
59
- public lastDestroyOutletOptions?: DestroyOutletOptions
60
- public lastCreateInletOptions?: CreateInletOptions
61
- public lastPullSampleOptions?: PullSampleOptions
62
- public lastPullChunkOptions?: PullChunkOptions
63
- public lastFlushInletOptions?: FlushInletOptions
64
- public lastDestroyInletOptions?: DestroyInletOptions
65
-
66
- public createStreamInfoHitCount = 0
67
- public createOutletHitCount = 0
68
- public destroyOutletHitCount = 0
69
- public createInletHitCount = 0
70
- public flushInletHitCount = 0
71
- public destroyInletHitCount = 0
72
- public localClockHitCount = 0
73
- public pushSampleStringTimestampHitCount = 0
74
-
75
- public createStreamInfo(options: CreateStreamInfoOptions) {
76
- this.createStreamInfoHitCount++
77
- this.lastCreateStreamInfoOptions = options
78
- return this.streamInfo
79
- }
80
-
81
- public appendChannelsToStreamInfo(
82
- options: AppendChannelsToStreamInfoOptions
83
- ) {
84
- this.lastAppendChannelsToStreamInfoOptions = options
85
- }
86
-
87
- public destroyStreamInfo(options: DestroyStreamInfoOptions) {
88
- this.lastDestroyStreamInfoOptions = options
89
- }
90
-
91
- public async resolveByProp(options: ResolveByPropOptions) {
92
- this.lastResolveByPropOptions = options
93
- return FakeLiblsl.fakeStreamInfoHandles as bigint[]
94
- }
95
-
96
- public pushSampleFloatTimestamp(options: PushSampleFloatTimestampOptions) {
97
- this.lastPushSampleFloatTimestampOptions = options
98
- return FakeLiblsl.fakeErrorCode
99
- }
100
-
101
- public pushSampleStringTimestamp(
102
- options: PushSampleStringTimestampOptions
103
- ) {
104
- this.lastPushSampleStringTimestampOptions = options
105
- this.pushSampleStringTimestampHitCount++
106
- return FakeLiblsl.fakeErrorCode
107
- }
108
-
109
- public createOutlet(options: CreateOutletOptions) {
110
- this.createOutletHitCount++
111
- this.lastCreateOutletOptions = options
112
- return this.outlet
113
- }
114
-
115
- public destroyOutlet(options: DestroyOutletOptions) {
116
- this.destroyOutletHitCount++
117
- this.lastDestroyOutletOptions = options
118
- }
119
-
120
- public createInlet(options: CreateInletOptions) {
121
- this.createInletHitCount++
122
- this.lastCreateInletOptions = options
123
- return {} as BoundInlet
124
- }
125
-
126
- public pullSample(options: PullSampleOptions) {
127
- this.lastPullSampleOptions = options
128
-
129
- const sample = this.fakeSamples.shift()
130
-
131
- if (sample) {
132
- return 1
133
- }
134
-
135
- return 0
136
- }
137
-
138
- public pullChunk(options: PullChunkOptions) {
139
- this.lastPullChunkOptions = options
140
-
141
- const chunk = this.fakeChunks.shift()
142
- const timestamps = this.fakeTimestamps.shift()
143
-
144
- if (chunk && timestamps) {
145
- return 1
146
- }
147
-
148
- return 0
149
- }
150
-
151
- public flushInlet(options: FlushInletOptions) {
152
- this.flushInletHitCount++
153
- this.lastFlushInletOptions = options
154
- }
155
-
156
- public destroyInlet(options: DestroyInletOptions) {
157
- this.destroyInletHitCount++
158
- this.lastDestroyInletOptions = options
159
- }
160
-
161
- public localClock() {
162
- this.localClockHitCount++
163
- return new Date().getTime()
164
- }
165
-
166
- public resetTestDouble() {
167
- this.lastCreateStreamInfoOptions = undefined
168
- this.lastAppendChannelsToStreamInfoOptions = undefined
169
- this.lastCreateOutletOptions = undefined
170
- this.lastPushSampleFloatTimestampOptions = undefined
171
- this.lastPushSampleStringTimestampOptions = undefined
172
-
173
- this.createStreamInfoHitCount = 0
174
- this.destroyOutletHitCount = 0
175
- this.localClockHitCount = 0
176
- this.pushSampleStringTimestampHitCount = 0
177
-
178
- this.fakeSamples = FakeLiblsl.fakeSamples.slice()
179
- this.fakeChunks = FakeLiblsl.fakeChunks.slice()
180
- this.fakeTimestamps = FakeLiblsl.fakeTimestamps.slice()
181
- }
182
- }