ÿØÿàJFIFÿÛ„ ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /proc/self/root/proc/self/cwd/usr/lib/node_modules/forever/node_modules/lazy/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/self/cwd/usr/lib/node_modules/forever/node_modules/lazy/test/lines.js
var assert = require('assert');
var Lazy = require('..');
var EventEmitter = require('events').EventEmitter;

exports['buffered lines'] = function () {
    var lazy = Lazy();
    var joined = false;
    lazy.lines
        .forEach(function (line) {
            assert.ok(line instanceof Buffer);
            assert.ok(!line.toString().match(/\n/));
            assert.ok(line.length > 0);
        })
        .join(function (lines) {
            assert.deepEqual(
                lines.map(function (x) { return x.toString() }),
                'foo bar baz quux moo'.split(' ')
            );
            joined = true;
        });
    ;
    
    setTimeout(function () {
        lazy.push(new Buffer('foo\nbar'));
        lazy.push(new Buffer('\nbaz\nquux\nmoo'));
        lazy.push(new Buffer(''));
        lazy.push(new Buffer('\ndoom'));
        lazy.end();
        assert.ok(joined);
    }, 50);
};

exports['string lines'] = function () {
    var lazy = Lazy();
    var joined = false;
    lazy.lines
        .forEach(function (line) {
            assert.ok(line instanceof Buffer);
            assert.ok(!line.toString().match(/\n/));
            assert.ok(line.length > 0);
        })
        .join(function (lines) {
            assert.deepEqual(
                lines.map(function (x) { return x.toString() }),
                'foo bar baz quux moo'.split(' ')
            );
            joined = true;
        });
    ;
    
    setTimeout(function () {
        lazy.push('foo\nbar');
        lazy.push('\nbaz\nquux\nmoo');
        lazy.push('');
        lazy.push('\ndoom');
        lazy.end();
        assert.ok(joined);
    }, 50);
};

exports.endStream = function () {
    var to = setTimeout(function () {
        assert.fail('never finished');
    }, 2500);
    
    var em = new EventEmitter;
    var i = 0;
    var lines = [];
    Lazy(em).lines.forEach(function (line) {
        i ++;
        lines.push(line);
        if (i == 2) {
            clearTimeout(to);
            assert.eql(lines.map(String), [ 'foo', 'bar' ]);
        }
    });
    
    setTimeout(function () {
        em.emit('data', 'fo');
    }, 100);
    
    setTimeout(function () {
        em.emit('data', 'o\nbar');
    }, 150);
    
    setTimeout(function () {
        em.emit('end');
    }, 200);
};

ZeroDay Forums Mini