How to use duplexer3 - 5 common examples

To help you get started, we’ve selected a few duplexer3 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 ra-gg / Delir / packages / deream / index.ts View on Github external
'-i',
    'pipe:0',
    '-c:v',
    'png_pipe',
    '-c:v',
    'utvideo',
    '-pix_fmt',
    'rgba',
    // 'yuva420p',
    tmpMovieFilePath,
  ])

  // tslint:disable-next-line:no-console
  sourceFFmpegProcess.stderr.on('data', chunk => console.log('ffmpeg:', chunk.toString()))

  const sourceFFmpegStream = duplexer3(sourceFFmpegProcess.stdin, sourceFFmpegProcess.stdout)

  const pipeline = new Delir.Engine.Engine()
  pipeline.setProject(project)
  pipeline.pluginRegistry = pluginRegistry

  pipeline.setStreamObserver({
    onFrame: (canvas, status) => {
      // toBlob() を使うと 4-10ms くらいで1フレームを書き出せるけど
      // 処理が非同期になってしまってフレーム順序が守れなくなるのであとからいい感じにしたい
      // queue.add(async () => {
      //     const buffer = await new Promise(resolve => {
      //         canvas.toBlob(result => {
      //             const reader = new FileReader()
      //             reader.onload = e => resolve(Buffer.from(reader.result as ArrayBuffer))
      //             reader.readAsArrayBuffer(result)
      //         }, 'image/png')
github ra-gg / Delir / packages / deream / exporter.ts View on Github external
'-i',
    'pipe:0',
    '-c:v',
    'png_pipe',
    ...specificArgs,
    '-pix_fmt',
    'yuva420p',
    '-y',
    _options.dest ? _options.dest : 'pipe:1',
  ]

  const ffmpeg = spawn(_options.ffmpegBin, args)
  // tslint:disable-next-line:no-console
  ffmpeg.stderr.on('data', chunk => console.log(chunk.toString()))

  const ret: any = duplexer(ffmpeg.stdin, ffmpeg.stdout)
  ret.ffmpeg = ffmpeg
  return ret as Duplex & { ffmpeg: ChildProcess }
}
github jamesramsay / hercule / src / transclude-stream.js View on Github external
const tokenizer = regexpTokenizer({ token, separator }, linkRegExp);
  const resolver = new ResolveStream(source, resolverOptions);
  const indenter = new IndentStream();
  const trim = new TrimStream();
  const sourcemap = new SourceMapStream(outputFile);
  const stringify = get('content');

  tokenizer
    .pipe(resolver)
    .pipe(trim)
    .pipe(indenter)
    .pipe(sourcemap)
    .pipe(stringify);

  const transcluder = duplexer(tokenizer, stringify);

  resolver.on('error', (err) => {
    transcluder.emit('error', err);
    resolver.end();
  });

  sourcemap.on('sourcemap', (generatedSourceMap) => {
    sourceMap = generatedSourceMap;
  });

  transcluder.on('end', () => {
    transcluder.emit('sources', sourceMap.sources);
    transcluder.emit('sourcemap', sourceMap);
  });

  return transcluder;
github jamesramsay / hercule / src / hercule.js View on Github external
const trim = new Trim();
  const sourcemap = new Sourcemap(outputFile);
  const stringify = get('content');

  transclude.on('error', () => transclude.end());
  sourcemap.on('sourcemap', generatedSourceMap => {
    sourceMap = generatedSourceMap;
  });

  transclude
    .pipe(trim)
    .pipe(indenter)
    .pipe(sourcemap)
    .pipe(stringify);

  const transcluder = duplexer({ bubbleErrors: false }, transclude, stringify);
  transcluder.on('end', () => transcluder.emit('sourcemap', sourceMap));

  return transcluder;
}
github jamesramsay / hercule / src / resolve-stream.js View on Github external
references: [...references],
          parents: [...parents, url],
        },
      );
    }

    function separator(match) {
      return defaultSeparator(match, { indent, source: url, parents: [...parents] });
    }

    const linkRegExp = _.get(options, 'linkRegExp') || defaultTokenRegExp;
    const tokenizerStream = regexpTokenizer({ token, separator }, linkRegExp);

    tokenizerStream.pipe(resolverStream);

    return duplexer({ objectMode: true }, tokenizerStream, resolverStream);
  }

duplexer3

Modern version of `duplexer2`

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis

Popular duplexer3 functions