@neurodevs/node-lsl 0.0.1 → 1.0.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/package.json
CHANGED
package/src/LslOutlet.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SchemaError, assertOptions } from '@sprucelabs/schema'
|
|
2
2
|
import LiblslImpl, { LslSample } from './Liblsl'
|
|
3
3
|
|
|
4
|
-
export default class LslOutlet {
|
|
4
|
+
export default class LslOutletImpl implements LslOutlet {
|
|
5
5
|
private outletOptions: LslOutletOptions
|
|
6
|
-
public
|
|
6
|
+
public static Class?: new (options: LslOutletOptions) => LslOutlet
|
|
7
|
+
|
|
8
|
+
protected constructor(options: LslOutletOptions) {
|
|
7
9
|
const { channelCount, sampleRate, channelFormat, chunkSize, maxBuffered } =
|
|
8
10
|
assertOptions(options, [
|
|
9
11
|
'name',
|
|
@@ -27,6 +29,10 @@ export default class LslOutlet {
|
|
|
27
29
|
this.outletOptions = options
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
public static Outlet(options: LslOutletOptions) {
|
|
33
|
+
return new (this.Class ?? this)(options)
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
private assertValidMaxBufferred(maxBuffered: number) {
|
|
31
37
|
if (!this.isPositiveIntegerOrZero(maxBuffered)) {
|
|
32
38
|
throw new SchemaError({
|
|
@@ -141,3 +147,7 @@ export interface LslOutletOptions {
|
|
|
141
147
|
chunkSize: number
|
|
142
148
|
maxBuffered: number
|
|
143
149
|
}
|
|
150
|
+
|
|
151
|
+
export interface LslOutlet {
|
|
152
|
+
pushSample(sample: LslSample): void
|
|
153
|
+
}
|
|
@@ -151,6 +151,13 @@ export default class LslOutletTest extends AbstractSpruceTest {
|
|
|
151
151
|
})
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
@test()
|
|
155
|
+
protected static async canOverrideClasInstantiatedInFactory() {
|
|
156
|
+
LslOutlet.Class = CheckingOutlet
|
|
157
|
+
const instance = this.Outlet()
|
|
158
|
+
assert.isInstanceOf(instance, CheckingOutlet)
|
|
159
|
+
}
|
|
160
|
+
|
|
154
161
|
private static pushSample(sample: LslSample) {
|
|
155
162
|
const outlet = this.Outlet()
|
|
156
163
|
outlet.pushSample(sample)
|
|
@@ -185,7 +192,7 @@ export default class LslOutletTest extends AbstractSpruceTest {
|
|
|
185
192
|
}
|
|
186
193
|
|
|
187
194
|
private static Outlet(options?: Partial<LslOutletOptions>) {
|
|
188
|
-
return
|
|
195
|
+
return LslOutlet.Outlet({
|
|
189
196
|
...this.randomOutletOptions,
|
|
190
197
|
...options,
|
|
191
198
|
})
|
|
@@ -215,3 +222,9 @@ class SpyLiblsl implements Liblsl {
|
|
|
215
222
|
this.lastPushedSample = sample
|
|
216
223
|
}
|
|
217
224
|
}
|
|
225
|
+
|
|
226
|
+
class CheckingOutlet extends LslOutlet {
|
|
227
|
+
public constructor(options: LslOutletOptions) {
|
|
228
|
+
super(options)
|
|
229
|
+
}
|
|
230
|
+
}
|