@neurodevs/node-lsl 17.0.0 → 17.1.1

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 (64) hide show
  1. package/build/__tests__/AbstractPackageTest.d.ts +2 -0
  2. package/build/__tests__/AbstractPackageTest.js +2 -6
  3. package/build/__tests__/AbstractPackageTest.js.map +1 -1
  4. package/build/__tests__/impl/LslStreamInfo.test.d.ts +3 -3
  5. package/build/__tests__/impl/LslStreamInfo.test.js +12 -12
  6. package/build/__tests__/impl/LslStreamInfo.test.js.map +1 -1
  7. package/build/__tests__/impl/LslStreamInlet.test.d.ts +2 -3
  8. package/build/__tests__/impl/LslStreamInlet.test.js +20 -27
  9. package/build/__tests__/impl/LslStreamInlet.test.js.map +1 -1
  10. package/build/__tests__/impl/LslWebSocketBridge.test.js +6 -3
  11. package/build/__tests__/impl/LslWebSocketBridge.test.js.map +1 -1
  12. package/build/impl/LiblslAdapter.d.ts +1 -6
  13. package/build/impl/LiblslAdapter.js +3 -3
  14. package/build/impl/LiblslAdapter.js.map +1 -1
  15. package/build/impl/LslStreamInfo.d.ts +3 -9
  16. package/build/impl/LslStreamInfo.js +6 -16
  17. package/build/impl/LslStreamInfo.js.map +1 -1
  18. package/build/impl/LslStreamInlet.d.ts +7 -5
  19. package/build/impl/LslStreamInlet.js +20 -24
  20. package/build/impl/LslStreamInlet.js.map +1 -1
  21. package/build/impl/LslStreamOutlet.d.ts +3 -3
  22. package/build/impl/LslStreamOutlet.js +5 -8
  23. package/build/impl/LslStreamOutlet.js.map +1 -1
  24. package/build/impl/LslWebSocketBridge.d.ts +2 -1
  25. package/build/impl/LslWebSocketBridge.js +1 -1
  26. package/build/impl/LslWebSocketBridge.js.map +1 -1
  27. package/build/scripts/runLslStreamOutlet.js +15 -10
  28. package/build/scripts/runLslStreamOutlet.js.map +1 -1
  29. package/build/scripts/runOutletToInlet.js +1 -6
  30. package/build/scripts/runOutletToInlet.js.map +1 -1
  31. package/build/testDoubles/Liblsl/FakeLiblsl.d.ts +1 -1
  32. package/build/testDoubles/Liblsl/FakeLiblsl.js +1 -1
  33. package/build/testDoubles/Liblsl/FakeLiblsl.js.map +1 -1
  34. package/build/testDoubles/StreamInfo/FakeStreamInfo.d.ts +4 -4
  35. package/build/testDoubles/StreamInfo/FakeStreamInfo.js +3 -3
  36. package/build/testDoubles/StreamInfo/FakeStreamInfo.js.map +1 -1
  37. package/build/testDoubles/StreamInfo/SpyStreamInfo.d.ts +0 -1
  38. package/build/testDoubles/StreamInfo/SpyStreamInfo.js +0 -3
  39. package/build/testDoubles/StreamInfo/SpyStreamInfo.js.map +1 -1
  40. package/build/testDoubles/StreamInlet/FakeStreamInlet.d.ts +3 -3
  41. package/build/testDoubles/StreamInlet/FakeStreamInlet.js.map +1 -1
  42. package/build/testDoubles/StreamInlet/SpyStreamInlet.d.ts +2 -2
  43. package/build/testDoubles/StreamInlet/SpyStreamInlet.js.map +1 -1
  44. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.d.ts +1 -0
  45. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js +3 -0
  46. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js.map +1 -1
  47. package/package.json +12 -12
  48. package/src/__tests__/AbstractPackageTest.ts +4 -8
  49. package/src/__tests__/impl/LslStreamInfo.test.ts +10 -10
  50. package/src/__tests__/impl/LslStreamInlet.test.ts +26 -36
  51. package/src/__tests__/impl/LslWebSocketBridge.test.ts +7 -5
  52. package/src/impl/LiblslAdapter.ts +4 -9
  53. package/src/impl/LslStreamInfo.ts +13 -27
  54. package/src/impl/LslStreamInlet.ts +35 -39
  55. package/src/impl/LslStreamOutlet.ts +6 -9
  56. package/src/impl/LslWebSocketBridge.ts +4 -4
  57. package/src/scripts/runLslStreamOutlet.ts +16 -10
  58. package/src/scripts/runOutletToInlet.ts +1 -6
  59. package/src/testDoubles/Liblsl/FakeLiblsl.ts +1 -1
  60. package/src/testDoubles/StreamInfo/FakeStreamInfo.ts +5 -5
  61. package/src/testDoubles/StreamInfo/SpyStreamInfo.ts +0 -4
  62. package/src/testDoubles/StreamInlet/FakeStreamInlet.ts +6 -3
  63. package/src/testDoubles/StreamInlet/SpyStreamInlet.ts +2 -2
  64. 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 instance = await LslStreamOutlet.Create({
5
- name: 'Muse S (2nd gen)',
6
- type: 'EEG',
7
- channelNames: ['TP9', 'AF7', 'AF8', 'TP10', 'AUX'],
8
- sampleRateHz: 256,
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
- sourceId: 'muse-s-eeg',
11
- manufacturer: 'Interaxon Inc.',
12
- units: 'microvolt',
13
- chunkSize: 12,
10
+ sampleRateHz: 10,
11
+ chunkSize: 1,
14
12
  })
15
13
 
16
- instance.pushSample([1, 2, 3, 4, 5])
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,12 +17,7 @@ const outlet = await LslStreamOutlet.Create({
17
17
  console.log('Creating inlet...')
18
18
 
19
19
  const inletOptions = {
20
- name: 'TestOutlet',
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
 
@@ -56,8 +56,8 @@ export default class FakeLiblsl implements Liblsl {
56
56
  public lastCreateOutletOptions?: CreateOutletOptions
57
57
  public lastPushSampleFloatTimestampOptions?: PushSampleFloatTimestampOptions
58
58
  public lastPushSampleStringTimestampOptions?: PushSampleStringTimestampOptions
59
- public lastCreateInletOptions?: CreateInletOptions
60
59
  public lastDestroyOutletOptions?: DestroyOutletOptions
60
+ public lastCreateInletOptions?: CreateInletOptions
61
61
  public lastPullSampleOptions?: PullSampleOptions
62
62
  public lastPullChunkOptions?: PullChunkOptions
63
63
  public lastFlushInletOptions?: FlushInletOptions
@@ -4,10 +4,10 @@ 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 boundStreamInfo = {} as BoundStreamInfo
10
+ public static boundInfo = {} as BoundStreamInfo
11
11
 
12
12
  public name = generateId()
13
13
  public type = generateId()
@@ -17,7 +17,7 @@ export default class FakeStreamInfo implements StreamInfo {
17
17
  public sampleRateHz = 0
18
18
  public units = 'N/A'
19
19
 
20
- public constructor(options: StreamInfoOptions) {
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 boundStreamInfo() {
33
- return FakeStreamInfo.boundStreamInfo
32
+ public get boundInfo() {
33
+ return FakeStreamInfo.boundInfo
34
34
  }
35
35
 
36
36
  public static resetTestDouble() {
@@ -8,10 +8,6 @@ export default class SpyStreamInfo extends LslStreamInfo {
8
8
  SpyStreamInfo.numCallsToConstructor++
9
9
  }
10
10
 
11
- public getBoundInfo() {
12
- return this.boundInfo
13
- }
14
-
15
11
  public getName() {
16
12
  return this.name
17
13
  }
@@ -1,10 +1,13 @@
1
1
  import { StreamInfo } from '../../impl/LslStreamInfo.js'
2
- import { StreamInlet, StreamInletOptions } from '../../impl/LslStreamInlet.js'
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?: StreamInletOptions
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?: StreamInletOptions,
25
+ options?: StreamInletConstructorOptions,
23
26
  onData?: (samples: Float32Array, timestamps: Float64Array) => void
24
27
  ) {
25
28
  this.onData = onData ?? (() => {})
@@ -1,13 +1,13 @@
1
1
  import { StreamInfo } from '../../impl/LslStreamInfo.js'
2
2
  import LslStreamInlet, {
3
3
  OnDataCallback,
4
- StreamInletOptions,
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: StreamInletOptions,
10
+ options: StreamInletConstructorOptions,
11
11
  onData: OnDataCallback
12
12
  ) {
13
13
  super(info, options, onData)
@@ -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