@engine9-io/input-tools 1.3.6

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.
@@ -0,0 +1,25 @@
1
+ const { Readable } = require('node:stream');
2
+
3
+ /*
4
+ A readable that will check data prior to it going into the stream
5
+ */
6
+ class ValidatingReadable extends Readable {
7
+ constructor(options, validator) {
8
+ super(options);
9
+ this.validator = validator || (() => true);
10
+ }
11
+
12
+ // eslint-disable-next-line no-underscore-dangle
13
+ // _read() {super._read(size)}
14
+
15
+ push(chunk) {
16
+ try {
17
+ this.validator(chunk);
18
+ super.push(chunk);
19
+ } catch (e) {
20
+ this.emit('error', e);
21
+ }
22
+ }
23
+ }
24
+
25
+ module.exports = ValidatingReadable;
@@ -0,0 +1,18 @@
1
+ const InputTools = require('./index');
2
+
3
+ (async () => {
4
+ await InputTools.create(
5
+ {
6
+ target: './test/sample/5_message.packet.zip',
7
+ personFiles: ['./test/sample/message/5_fake_people.csv'],
8
+ messageFiles: ['./test/sample/message/message.json5'],
9
+ },
10
+ );
11
+ await InputTools.create(
12
+ {
13
+ target: './test/sample/1000_message.packet.zip',
14
+ personFiles: ['./test/sample/message/1000_fake_people.csv'],
15
+ messageFiles: ['./test/sample/message/message.json5'],
16
+ },
17
+ );
18
+ })();