UNPKG

@eleven-am/transcoder

Version:

High-performance HLS transcoding library with hardware acceleration, intelligent client management, and distributed processing support for Node.js

58 lines 2 kB
"use strict"; /* * @eleven-am/transcoder * Copyright (C) 2025 Roy OSSAI * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ExtendedEventEmitter = void 0; exports.streamToString = streamToString; exports.streamToJson = streamToJson; const events_1 = require("events"); const fp_1 = require("@eleven-am/fp"); function streamToString(stream) { const promise = new Promise((resolve, reject) => { let data = ''; stream.on('data', (chunk) => { data += chunk; }); stream.on('end', () => { resolve(data); }); stream.on('error', (err) => { reject(err); }); }); return fp_1.TaskEither.tryCatch(() => promise, 'Failed to convert stream to string'); } function streamToJson(stream) { const json = (string) => fp_1.Either .tryCatch(() => JSON.parse(string), 'Failed to parse JSON') .toTaskEither(); return streamToString(stream).chain(json); } class ExtendedEventEmitter extends events_1.EventEmitter { emit(event, args) { return super.emit(event, args); } on(event, listener) { return super.on(event, listener); } once(event, listener) { return super.once(event, listener); } } exports.ExtendedEventEmitter = ExtendedEventEmitter; //# sourceMappingURL=utils.js.map