@neurodevs/node-lsl 16.1.0 → 17.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.
- package/build/__tests__/AbstractPackageTest.d.ts +3 -1
- package/build/__tests__/AbstractPackageTest.js +3 -7
- package/build/__tests__/AbstractPackageTest.js.map +1 -1
- package/build/__tests__/impl/LslStreamInfo.test.d.ts +3 -2
- package/build/__tests__/impl/LslStreamInfo.test.js +19 -12
- package/build/__tests__/impl/LslStreamInfo.test.js.map +1 -1
- package/build/__tests__/impl/LslStreamInlet.test.d.ts +1 -3
- package/build/__tests__/impl/LslStreamInlet.test.js +6 -27
- package/build/__tests__/impl/LslStreamInlet.test.js.map +1 -1
- package/build/__tests__/impl/LslWebSocketBridge.test.js +10 -16
- package/build/__tests__/impl/LslWebSocketBridge.test.js.map +1 -1
- package/build/impl/LslStreamInfo.d.ts +5 -8
- package/build/impl/LslStreamInfo.js +13 -13
- package/build/impl/LslStreamInfo.js.map +1 -1
- package/build/impl/LslStreamInlet.d.ts +6 -17
- package/build/impl/LslStreamInlet.js +5 -21
- package/build/impl/LslStreamInlet.js.map +1 -1
- package/build/impl/LslStreamOutlet.d.ts +3 -3
- package/build/impl/LslStreamOutlet.js +5 -8
- package/build/impl/LslStreamOutlet.js.map +1 -1
- package/build/impl/LslWebSocketBridge.d.ts +3 -8
- package/build/impl/LslWebSocketBridge.js +3 -3
- package/build/impl/LslWebSocketBridge.js.map +1 -1
- package/build/scripts/runLslStreamOutlet.js +15 -10
- package/build/scripts/runLslStreamOutlet.js.map +1 -1
- package/build/scripts/runOutletToInlet.js +2 -7
- package/build/scripts/runOutletToInlet.js.map +1 -1
- package/build/testDoubles/Liblsl/FakeLiblsl.d.ts +1 -1
- package/build/testDoubles/Liblsl/FakeLiblsl.js +2 -2
- package/build/testDoubles/Liblsl/FakeLiblsl.js.map +1 -1
- package/build/testDoubles/StreamInfo/FakeStreamInfo.d.ts +4 -4
- package/build/testDoubles/StreamInfo/FakeStreamInfo.js +4 -4
- package/build/testDoubles/StreamInfo/FakeStreamInfo.js.map +1 -1
- package/build/testDoubles/StreamInfo/SpyStreamInfo.d.ts +0 -1
- package/build/testDoubles/StreamInfo/SpyStreamInfo.js +0 -3
- package/build/testDoubles/StreamInfo/SpyStreamInfo.js.map +1 -1
- package/build/testDoubles/StreamInlet/FakeStreamInlet.d.ts +3 -3
- package/build/testDoubles/StreamInlet/FakeStreamInlet.js.map +1 -1
- package/build/testDoubles/StreamInlet/SpyStreamInlet.d.ts +2 -3
- package/build/testDoubles/StreamInlet/SpyStreamInlet.js +0 -3
- package/build/testDoubles/StreamInlet/SpyStreamInlet.js.map +1 -1
- package/build/testDoubles/StreamOutlet/FakeStreamOutlet.d.ts +1 -0
- package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js +3 -0
- package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js.map +1 -1
- package/package.json +11 -11
- package/src/__tests__/AbstractPackageTest.ts +3 -7
- package/src/__tests__/impl/LslStreamInfo.test.ts +22 -11
- package/src/__tests__/impl/LslStreamInlet.test.ts +9 -34
- package/src/__tests__/impl/LslWebSocketBridge.test.ts +11 -25
- package/src/impl/LslStreamInfo.ts +24 -23
- package/src/impl/LslStreamInlet.ts +15 -46
- package/src/impl/LslStreamOutlet.ts +6 -9
- package/src/impl/LslWebSocketBridge.ts +6 -12
- package/src/scripts/runLslStreamOutlet.ts +16 -10
- package/src/scripts/runOutletToInlet.ts +7 -9
- package/src/testDoubles/Liblsl/FakeLiblsl.ts +2 -2
- package/src/testDoubles/StreamInfo/FakeStreamInfo.ts +6 -6
- package/src/testDoubles/StreamInfo/SpyStreamInfo.ts +0 -4
- package/src/testDoubles/StreamInlet/FakeStreamInlet.ts +6 -3
- package/src/testDoubles/StreamInlet/SpyStreamInlet.ts +2 -6
- package/src/testDoubles/StreamOutlet/FakeStreamOutlet.ts +4 -0
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import LslStreamOutlet from '../impl/LslStreamOutlet.js'
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
|
-
const
|
|
5
|
-
name: '
|
|
6
|
-
type: '
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const outlet = await LslStreamOutlet.Create({
|
|
5
|
+
name: '10 Hz Pulse',
|
|
6
|
+
type: 'HZ',
|
|
7
|
+
sourceId: '10-hz-pulse',
|
|
8
|
+
channelNames: ['Ch1', 'Ch2', 'Ch3'],
|
|
9
9
|
channelFormat: 'float32',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
units: 'microvolt',
|
|
13
|
-
chunkSize: 12,
|
|
10
|
+
sampleRateHz: 10,
|
|
11
|
+
chunkSize: 1,
|
|
14
12
|
})
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
for (let i = 0; i < 100; i++) {
|
|
15
|
+
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
16
|
+
|
|
17
|
+
outlet.pushSample([
|
|
18
|
+
Math.random() * 100,
|
|
19
|
+
Math.random() * 100,
|
|
20
|
+
Math.random() * 100,
|
|
21
|
+
])
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
main().catch((error) => {
|
|
@@ -17,18 +17,16 @@ const outlet = await LslStreamOutlet.Create({
|
|
|
17
17
|
console.log('Creating inlet...')
|
|
18
18
|
|
|
19
19
|
const inletOptions = {
|
|
20
|
-
|
|
21
|
-
type: 'TEST',
|
|
22
|
-
sourceId: 'TestOutletID',
|
|
23
|
-
sampleRateHz: 100,
|
|
24
|
-
channelNames: ['Ch1', 'Ch2', 'Ch3'],
|
|
25
|
-
channelFormat: 'float32' as const,
|
|
20
|
+
info: outlet.info,
|
|
26
21
|
chunkSize: 1,
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
const inlet = LslStreamInlet.Create(
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
const inlet = await LslStreamInlet.Create(
|
|
25
|
+
inletOptions,
|
|
26
|
+
(samples, timestamps) => {
|
|
27
|
+
console.log('Received samples:', samples, 'at timestamps:', timestamps)
|
|
28
|
+
}
|
|
29
|
+
)
|
|
32
30
|
|
|
33
31
|
console.log('Start pulling...')
|
|
34
32
|
inlet.startPulling()
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from 'impl/LiblslAdapter.js'
|
|
22
22
|
|
|
23
23
|
export default class FakeLiblsl implements Liblsl {
|
|
24
|
-
public static
|
|
24
|
+
public static fakeStreamInfoHandles: BoundStreamInfo[] = []
|
|
25
25
|
|
|
26
26
|
public static fakeSamples: Float32Array[] = [
|
|
27
27
|
new Float32Array([1, 2, 3]),
|
|
@@ -90,7 +90,7 @@ export default class FakeLiblsl implements Liblsl {
|
|
|
90
90
|
|
|
91
91
|
public async resolveByProp(options: ResolveByPropOptions) {
|
|
92
92
|
this.lastResolveByPropOptions = options
|
|
93
|
-
return FakeLiblsl.
|
|
93
|
+
return FakeLiblsl.fakeStreamInfoHandles as bigint[]
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
public pushSampleFloatTimestamp(options: PushSampleFloatTimestampOptions) {
|
|
@@ -4,20 +4,20 @@ import { BoundStreamInfo } from 'impl/LiblslAdapter.js'
|
|
|
4
4
|
import { StreamInfo, StreamInfoOptions } from '../../impl/LslStreamInfo.js'
|
|
5
5
|
|
|
6
6
|
export default class FakeStreamInfo implements StreamInfo {
|
|
7
|
-
public static callsToConstructor: StreamInfoOptions[] = []
|
|
7
|
+
public static callsToConstructor: (StreamInfoOptions | undefined)[] = []
|
|
8
8
|
public static numCallsToDestroy = 0
|
|
9
9
|
|
|
10
|
-
public static
|
|
10
|
+
public static boundInfo = {} as BoundStreamInfo
|
|
11
11
|
|
|
12
12
|
public name = generateId()
|
|
13
13
|
public type = generateId()
|
|
14
14
|
public sourceId = generateId()
|
|
15
|
-
public channelNames: string[] = [generateId(), generateId()]
|
|
15
|
+
public channelNames: string[] = [generateId(), generateId(), generateId()]
|
|
16
16
|
public channelFormat = 'float32' as const
|
|
17
17
|
public sampleRateHz = 0
|
|
18
18
|
public units = 'N/A'
|
|
19
19
|
|
|
20
|
-
public constructor(options
|
|
20
|
+
public constructor(options?: StreamInfoOptions) {
|
|
21
21
|
FakeStreamInfo.callsToConstructor.push(options)
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -29,8 +29,8 @@ export default class FakeStreamInfo implements StreamInfo {
|
|
|
29
29
|
return this.channelNames.length
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
public get
|
|
33
|
-
return FakeStreamInfo.
|
|
32
|
+
public get boundInfo() {
|
|
33
|
+
return FakeStreamInfo.boundInfo
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
public static resetTestDouble() {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { StreamInfo } from '../../impl/LslStreamInfo.js'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
StreamInlet,
|
|
4
|
+
StreamInletConstructorOptions,
|
|
5
|
+
} from '../../impl/LslStreamInlet.js'
|
|
3
6
|
|
|
4
7
|
export default class FakeStreamInlet implements StreamInlet {
|
|
5
8
|
public static callsToConstructor: {
|
|
6
9
|
info?: StreamInfo
|
|
7
|
-
options?:
|
|
10
|
+
options?: StreamInletConstructorOptions
|
|
8
11
|
onData?: (samples: Float32Array, timestamps: Float64Array) => void
|
|
9
12
|
}[] = []
|
|
10
13
|
|
|
@@ -19,7 +22,7 @@ export default class FakeStreamInlet implements StreamInlet {
|
|
|
19
22
|
|
|
20
23
|
public constructor(
|
|
21
24
|
info?: StreamInfo,
|
|
22
|
-
options?:
|
|
25
|
+
options?: StreamInletConstructorOptions,
|
|
23
26
|
onData?: (samples: Float32Array, timestamps: Float64Array) => void
|
|
24
27
|
) {
|
|
25
28
|
this.onData = onData ?? (() => {})
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { StreamInfo } from '../../impl/LslStreamInfo.js'
|
|
2
2
|
import LslStreamInlet, {
|
|
3
3
|
OnDataCallback,
|
|
4
|
-
|
|
4
|
+
StreamInletConstructorOptions,
|
|
5
5
|
} from '../../impl/LslStreamInlet.js'
|
|
6
6
|
|
|
7
7
|
export class SpyStreamInlet extends LslStreamInlet {
|
|
8
8
|
public constructor(
|
|
9
9
|
info: StreamInfo,
|
|
10
|
-
options:
|
|
10
|
+
options: StreamInletConstructorOptions,
|
|
11
11
|
onData: OnDataCallback
|
|
12
12
|
) {
|
|
13
13
|
super(info, options, onData)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
public getName() {
|
|
17
|
-
return this.name
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
public getStreamInfo() {
|
|
21
17
|
return this.info
|
|
22
18
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
StreamOutlet,
|
|
8
8
|
StreamOutletOptions,
|
|
9
9
|
} from '../../impl/LslStreamOutlet.js'
|
|
10
|
+
import FakeStreamInfo from '../StreamInfo/FakeStreamInfo.js'
|
|
10
11
|
|
|
11
12
|
export default class FakeStreamOutlet implements StreamOutlet {
|
|
12
13
|
public static callsToConstructor: {
|
|
@@ -17,10 +18,13 @@ export default class FakeStreamOutlet implements StreamOutlet {
|
|
|
17
18
|
public static callsToPushSample: LslSample[] = []
|
|
18
19
|
public static numCallsToDestroy = 0
|
|
19
20
|
|
|
21
|
+
public info: StreamInfo
|
|
20
22
|
public options?: StreamOutletOptions
|
|
21
23
|
|
|
22
24
|
public constructor(info?: StreamInfo, options?: StreamOutletOptions) {
|
|
23
25
|
FakeStreamOutlet.callsToConstructor.push({ info, options })
|
|
26
|
+
|
|
27
|
+
this.info = info ?? new FakeStreamInfo()
|
|
24
28
|
this.options = options
|
|
25
29
|
}
|
|
26
30
|
|