UNPKG

@egodigital/egoose

Version:

Helper classes and functions for Node.js 10 or later.

43 lines 1.95 kB
"use strict"; /** * This file is part of the @egodigital/egoose distribution. * Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/) * * @egodigital/egoose is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, version 3. * * @egodigital/egoose is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ Object.defineProperty(exports, "__esModule", { value: true }); const assert = require("assert"); const mocha_1 = require("mocha"); const index_1 = require("../index"); const stream = require("stream"); mocha_1.describe('#readAll()', async function () { mocha_1.describe('Buffer', async function () { mocha_1.it('should return same data as input', async function () { for (let i = 0; i < 1000; i++) { const IN_STR = (new Array(i)).map(x => 'TMäöüMK') .join(''); const IN_BUFF = Buffer.from(IN_STR, 'utf8'); const IN_STREAM = new stream.PassThrough(); IN_STREAM.end(IN_BUFF); const OUT_BUFF = await index_1.readAll(IN_STREAM); const OUT_STR = OUT_BUFF.toString('utf8'); assert.ok(Buffer.isBuffer(OUT_BUFF)); assert.equal(OUT_BUFF.length, IN_BUFF.length); assert.strictEqual(OUT_BUFF.length, IN_BUFF.length); assert.equal(OUT_STR, IN_STR); assert.strictEqual(OUT_STR, IN_STR); } }); }); }); //# sourceMappingURL=readAll.js.map