@yarkivaev/source-to-sink 1.1.0 → 1.2.2
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/.github/workflows/ci.yml +1 -1
- package/eslint.config.js +176 -0
- package/index.js +1 -0
- package/package.json +11 -5
- package/src/batch.js +2 -2
- package/src/lokiSource.js +3 -3
- package/src/modbusSource.js +52 -9
- package/src/mqttSource.js +5 -5
- package/src/pollingSource.js +4 -3
- package/src/postgresSink.js +7 -7
- package/src/sqliteSink.js +55 -0
- package/src/stompSource.js +20 -11
- package/src/timedBatch.js +4 -4
- package/test/integration_clickhouseSink.js +5 -5
- package/test/integration_lokiSource.js +13 -13
- package/test/integration_mqttSink.js +12 -12
- package/test/integration_mqttSource.js +19 -19
- package/test/test_batch.js +21 -35
- package/test/test_circuit.js +12 -12
- package/test/test_clickhouseSink.js +8 -8
- package/test/test_lokiSource.js +12 -12
- package/test/test_modbusSource.js +37 -14
- package/test/test_mqttSink.js +6 -6
- package/test/test_mqttSource.js +8 -8
- package/test/test_pollingSource.js +23 -23
- package/test/test_postgresSink.js +12 -12
- package/test/test_sqliteSink.js +176 -0
- package/test/test_stompSource.js +8 -8
- package/test/test_timedBatch.js +13 -13
package/test/test_timedBatch.js
CHANGED
|
@@ -6,7 +6,7 @@ describe('timedBatch', () => {
|
|
|
6
6
|
it('flushes after interval expires', async () => {
|
|
7
7
|
const received = [];
|
|
8
8
|
const origin = {
|
|
9
|
-
accept: (record) => received.push(record),
|
|
9
|
+
accept: (record) => {return received.push(record)},
|
|
10
10
|
flush: () => {},
|
|
11
11
|
stop: () => {}
|
|
12
12
|
};
|
|
@@ -15,7 +15,7 @@ describe('timedBatch', () => {
|
|
|
15
15
|
const interval = 0.05;
|
|
16
16
|
const timed = timedBatch(origin, interval);
|
|
17
17
|
timed.accept({ data: `\u0410\u0411\u0412${Math.random()}` });
|
|
18
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
18
|
+
await new Promise(resolve => { setTimeout(resolve, 100); });
|
|
19
19
|
timed.stop();
|
|
20
20
|
assert.strictEqual(flushed, true, 'Should flush after interval');
|
|
21
21
|
});
|
|
@@ -23,7 +23,7 @@ describe('timedBatch', () => {
|
|
|
23
23
|
it('delegates accept to origin', () => {
|
|
24
24
|
const received = [];
|
|
25
25
|
const origin = {
|
|
26
|
-
accept: (record) => received.push(record),
|
|
26
|
+
accept: (record) => {return received.push(record)},
|
|
27
27
|
flush: () => {},
|
|
28
28
|
stop: () => {}
|
|
29
29
|
};
|
|
@@ -65,14 +65,14 @@ describe('timedBatch', () => {
|
|
|
65
65
|
let count = 0;
|
|
66
66
|
const origin = {
|
|
67
67
|
accept: () => {},
|
|
68
|
-
flush: () => { count
|
|
68
|
+
flush: () => { count += 1; },
|
|
69
69
|
stop: () => {}
|
|
70
70
|
};
|
|
71
71
|
const interval = 0.05;
|
|
72
72
|
const timed = timedBatch(origin, interval);
|
|
73
73
|
timed.accept({ z: Math.random() });
|
|
74
74
|
timed.flush();
|
|
75
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
75
|
+
await new Promise(resolve => { setTimeout(resolve, 100); });
|
|
76
76
|
timed.stop();
|
|
77
77
|
assert.strictEqual(count, 1, 'Should not flush twice after manual flush');
|
|
78
78
|
});
|
|
@@ -80,8 +80,8 @@ describe('timedBatch', () => {
|
|
|
80
80
|
it('throws on missing accept method', () => {
|
|
81
81
|
const origin = { flush: () => {}, stop: () => {} };
|
|
82
82
|
assert.throws(
|
|
83
|
-
() => timedBatch(origin, 1),
|
|
84
|
-
/Origin must have an accept\(\) method
|
|
83
|
+
() => {return timedBatch(origin, 1)},
|
|
84
|
+
/Origin must have an accept\(\) method/u,
|
|
85
85
|
'Should reject origin without accept'
|
|
86
86
|
);
|
|
87
87
|
});
|
|
@@ -89,8 +89,8 @@ describe('timedBatch', () => {
|
|
|
89
89
|
it('throws on missing flush method', () => {
|
|
90
90
|
const origin = { accept: () => {}, stop: () => {} };
|
|
91
91
|
assert.throws(
|
|
92
|
-
() => timedBatch(origin, 1),
|
|
93
|
-
/Origin must have a flush\(\) method
|
|
92
|
+
() => {return timedBatch(origin, 1)},
|
|
93
|
+
/Origin must have a flush\(\) method/u,
|
|
94
94
|
'Should reject origin without flush'
|
|
95
95
|
);
|
|
96
96
|
});
|
|
@@ -98,8 +98,8 @@ describe('timedBatch', () => {
|
|
|
98
98
|
it('throws on missing stop method', () => {
|
|
99
99
|
const origin = { accept: () => {}, flush: () => {} };
|
|
100
100
|
assert.throws(
|
|
101
|
-
() => timedBatch(origin, 1),
|
|
102
|
-
/Origin must have a stop\(\) method
|
|
101
|
+
() => {return timedBatch(origin, 1)},
|
|
102
|
+
/Origin must have a stop\(\) method/u,
|
|
103
103
|
'Should reject origin without stop'
|
|
104
104
|
);
|
|
105
105
|
});
|
|
@@ -108,8 +108,8 @@ describe('timedBatch', () => {
|
|
|
108
108
|
const origin = { accept: () => {}, flush: () => {}, stop: () => {} };
|
|
109
109
|
const invalid = -Math.random() * 10;
|
|
110
110
|
assert.throws(
|
|
111
|
-
() => timedBatch(origin, invalid),
|
|
112
|
-
/Interval must be a positive number
|
|
111
|
+
() => {return timedBatch(origin, invalid)},
|
|
112
|
+
/Interval must be a positive number/u,
|
|
113
113
|
'Should reject invalid interval'
|
|
114
114
|
);
|
|
115
115
|
});
|