Comparing version 0.1.7 to 0.1.9
{ | ||
"name": "streamops", | ||
"version": "0.1.7", | ||
"main": "./index.js", | ||
"version": "0.1.9", | ||
"main": "./src/main.js", | ||
"scripts": { | ||
"test": "NODE_ENV=test jest" | ||
}, | ||
"exports": { | ||
".": "./src/main.js", | ||
"./simple": "./src/simple.js" | ||
}, | ||
"devDependencies": { | ||
@@ -9,0 +13,0 @@ "jest": "^29.7.0" |
@@ -1,2 +0,2 @@ | ||
const createStreamOps = require('../index.js'); | ||
const createStreamOps = require('../src/createStreamOps.js'); | ||
@@ -3,0 +3,0 @@ jest.setTimeout(10000); // Increase Jest's default timeout |
@@ -1,2 +0,2 @@ | ||
const streaming = require('../index.js')({ timeout: 30000, bufferSize: 1000, logLevel: 'info' }); | ||
const streaming = require('../src/createStreamOps.js')({ timeout: 30000, bufferSize: 1000, logLevel: 'info' }); | ||
@@ -3,0 +3,0 @@ describe('Generator objects and async operations', () => { |
@@ -1,2 +0,2 @@ | ||
const streaming = require('../index.js')({ | ||
const streaming = require('../src/createStreamOps.js')({ | ||
timeout: 30000, | ||
@@ -3,0 +3,0 @@ bufferSize: 1000, |
@@ -1,2 +0,2 @@ | ||
const createStreamer = require('../index'); | ||
const createStreamer = require('../src/createStreamOps'); | ||
const EventEmitter = require('events'); | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
const streaming = require('../index.js')({ | ||
const streaming = require('../src/createStreamOps.js')({ | ||
timeout: 30000, | ||
@@ -14,6 +14,6 @@ bufferSize: 1000, | ||
[ | ||
([x]) => x * 2, | ||
([x]) => x * 3 | ||
(x) => x * 2, | ||
(x) => x * 3 | ||
], | ||
([x]) => x + 100 | ||
(x) => x + 100 | ||
] | ||
@@ -65,4 +65,4 @@ ]; | ||
[ | ||
[([x]) => x * 2, ([x]) => x * 3], | ||
([x]) => x + 1 | ||
[(x) => x * 2, (x) => x * 3], | ||
(x) => x + 1 | ||
] | ||
@@ -69,0 +69,0 @@ ]; |
@@ -1,2 +0,2 @@ | ||
const streaming = require('../index.js')({ | ||
const streaming = require('../src/createStreamOps.js')({ | ||
timeout: 30000, | ||
@@ -3,0 +3,0 @@ bufferSize: 1000, |
@@ -1,2 +0,2 @@ | ||
const streaming = require('../index.js')({ | ||
const streaming = require('../src/createStreamOps.js')({ | ||
timeout: 30000, | ||
@@ -3,0 +3,0 @@ bufferSize: 1000, |
@@ -1,2 +0,2 @@ | ||
const streaming = require('../index.js')({ | ||
const streaming = require('../src/createStreamOps.js')({ | ||
timeout: 30000, | ||
@@ -50,3 +50,3 @@ bufferSize: 1000, | ||
}, | ||
(numbers) => numbers.reduce((sum, num) => sum + num, 0) | ||
streaming.reduce((sum, num) => sum + num, 0) | ||
]; | ||
@@ -59,3 +59,4 @@ const results = []; | ||
// Check if aggregation works correctly | ||
expect(results.reduce((sum, num) => sum + num, 0)).toEqual(6); | ||
// Note that a 'streaming reduce' results in 10 (cumulative) | ||
expect(results.reduce((sum, num) => sum + num, 0)).toEqual(10); | ||
}); | ||
@@ -163,2 +164,39 @@ | ||
test('basic sequence of yields', async () => { | ||
const pipeline = [ | ||
function*() { | ||
yield 1; | ||
yield 2; | ||
}, | ||
function*(n) { | ||
yield n; | ||
yield 3; | ||
yield 4; | ||
}, | ||
function*(n) { | ||
yield n; | ||
yield 5; | ||
yield 6; | ||
} | ||
]; | ||
const results = []; | ||
for await (const item of streaming(pipeline)) { | ||
results.push(item); | ||
} | ||
// Remember, it's a stream, so the end yields are the end-results | ||
// And the amount of total yields will be | ||
// {first step yields} * {middle step yields} * {end step yields} | ||
// 2 * 3 * 3 = 18 | ||
expect(results).toEqual([ | ||
// end results: | ||
1, 5, 6, | ||
3, 5, 6, | ||
4, 5, 6, | ||
2, 5, 6, | ||
3, 5, 6, | ||
4, 5, 6 | ||
]); | ||
}); | ||
test('pipeline with error handling', async () => { | ||
@@ -248,6 +286,6 @@ const pipeline = [ | ||
() => ({count: 1}), | ||
([{count}]) => { | ||
({count}) => { | ||
return {count: count + 1}; | ||
}, | ||
([{count}]) => `Final count: ${count}` | ||
({count}) => `Final count: ${count}` | ||
]; | ||
@@ -266,3 +304,3 @@ const results = []; | ||
async () => await fetchData(), | ||
async ([data]) => await processData(data) | ||
async (data) => await processData(data) | ||
]; | ||
@@ -345,5 +383,3 @@ const results = []; | ||
}, | ||
function all(all) { | ||
return all.map(_ => _ + this.something); | ||
} | ||
streaming.map(function(_) { console.log('this99', this); return _ + this.something; }) | ||
]; | ||
@@ -350,0 +386,0 @@ |
@@ -1,2 +0,2 @@ | ||
const createStreamOps = require('../index.js'); | ||
const createStreamOps = require('../src/createStreamOps.js'); | ||
@@ -3,0 +3,0 @@ describe('YieldTimeout Tests', () => { |
68286
20
2363
1
10