API/api.medcify.app/node_modules/lazy/test/join.js

27 lines
518 B
JavaScript
Raw Permalink Normal View History

2022-09-26 06:11:44 +00:00
var assert = require('assert');
var Lazy = require('..');
var expresso = expresso;
function range(i, j) {
var r = [];
for (;i<j;i++) r.push(i);
return r;
}
exports['join'] = function () {
var lazy = new Lazy;
var data = [];
var executed = false;
lazy.take(10).join(function (xs) {
assert.deepEqual(xs, range(0,10));
executed = true;
});
range(0,20).forEach(function (x) {
lazy.emit('data', x);
});
assert.ok(executed, 'join didn\'t execute');
}