How to use the readable-stream.pipeline function in readable-stream

To help you get started, we’ve selected a few readable-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-encryption-sdk-javascript / modules / encrypt-node / src / encrypt_stream.ts View on Github external
.then(async (material) => {
      const { dispose, getSigner } = getEncryptHelper(material)

      const { getCipher, messageHeader, rawHeader } = getEncryptionInfo(material, frameLength)

      wrappingStream.emit('MessageHeader', messageHeader)

      const encryptStream = getFramedEncryptStream(getCipher, messageHeader, dispose, plaintextLength)
      const signatureStream = new SignatureStream(getSigner)

      pipeline(encryptStream, signatureStream)

      wrappingStream.setReadable(signatureStream)
      // Flush the rawHeader through the signatureStream
      rawHeader.forEach(buff => signatureStream.write(buff))

      // @ts-ignore until readable-stream exports v3 types...
      wrappingStream.setWritable(encryptStream)
    })
    .catch(err => wrappingStream.emit('error', err))
github nodertc / dtls / src / node_modules / lib / socket.js View on Github external
session.cipherSuites = supportedCiphers;
    }

    session.retransmitter.once('close', () => {
      this.emit('timeout');
    });

    const onerror = err => {
      if (err) {
        this.emit('error', err);
      }
    };
    const isdtls = streamfilter(chunkFilter);

    pipeline(writer, socket, onerror);
    pipeline(socket, isdtls, decoder, reorder, defrag, protocol, onerror);

    this[_session] = session;
    this[_queue] = [];
    this[_protocol] = protocol;
    this[_socket] = socket;
    this[_timeout] = null;

    session.on('data', packet => {
      this[_resetTimer]();
      this.push(packet);
    });

    session.once('handshake:finish', () => {
      process.nextTick(() => this.emit('connect'));
github baptistecdr / aria2-extensions / gulpfile.js View on Github external
function html(directory) {
    return pipeline(gulp.src('src/**/*.html'), htmlMinify(htmlMinifyConfig), gulp.dest(`dist/${directory}`));
}
github cloudoptlab / cloudopt-adblocker / gulpfile.js View on Github external
gulp.task('compress', function () {
  return pipeline(
    gulp.src([
      '**/*.js',
      '!adguard/adguard-content.js',
      '!gulpfile.js',
      '!node_modules/**'
    ]),
    babel({
      presets: [
        '@babel/preset-env'
      ],
      compact: true,
      sourceType: 'script',
    }),
    uglify({
      mangle: true,
    }),
github baptistecdr / aria2-extensions / gulpfile.js View on Github external
function popupJs(directory) {
    return pipeline(gulp.src('src/popup/popup.js'), babel(), webpack(webpackConfig('popup.js')), gulp.dest(`dist/${directory}/popup/`));
}
github pwstegman / bci.js / gulp-tasks / docs-html.js View on Github external
function js(){
	return pipeline(
        gulp.src('website/js/*.js'),
        uglify(),
        gulp.dest('docs/js')
  	);
}
github baptistecdr / aria2-extensions / gulpfile.js View on Github external
function manifest(directory) {
    return pipeline(gulp.src(`src/${directory}/manifest.json`), jsonMinify(), gulp.dest(`dist/${directory}/`));
}
github ravendb / ravendb-nodejs-client / src / Mapping / Json / Streams / Pipelines.ts View on Github external
}
                }
                callback();
            },
            flush(callback) {
                if (!endedArray) {
                    this.push("]");
                }

                this.push("}");
                callback();
            }
        }));

    let first = true;
    const resultsStream = stream.pipeline(
        docsObjectStream,
        new stream.Transform({
            writableObjectMode: true,
            readableObjectMode: false,
            write(chunk, enc, callback) {
                const json = JSON.stringify(chunk["value"]);
                if (first) {
                    first = false;
                    this.push(`{"results":[${json}`);
                } else {
                    this.push(`,${json}`);
                }

                callback();
            },
            flush(callback) {
github baptistecdr / aria2-extensions / gulpfile.js View on Github external
function settingsJs(directory) {
    return pipeline(gulp.src('src/settings/settings.ctrl.js'), babel(), webpack(webpackConfig('settings.ctrl.js')),
        gulp.dest(`dist/${directory}/settings/`));
}
github baptistecdr / aria2-extensions / gulpfile.js View on Github external
function locales(directory) {
    return pipeline(gulp.src('src/_locales/**/*.json'), jsonMinify(), gulp.dest(`dist/${directory}/_locales`));
}