How to use the @msgpack/msgpack.decodeStream function in @msgpack/msgpack

To help you get started, we’ve selected a few @msgpack/msgpack 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 neovim / node-client / packages / neovim / src / utils / transport.ts View on Github external
attach(
    writer: NodeJS.WritableStream,
    reader: NodeJS.ReadableStream,
    client: any
  ) {
    this.writer = writer;
    this.reader = reader;
    this.client = client;

    this.reader.on('end', () => {
      this.emit('detach');
    });

    const asyncDecodeGenerator = decodeStream(this.reader as any, {
      extensionCodec: this.extensionCodec,
    });

    // naively iterate async generator created via decodeStream.
    // when runtime / polyfill allows replace to `for await (const val of asyncDecodeGenerator)`
    // syntax instead.
    const resolveGeneratorRecursively = (iter: AsyncGenerator) => {
      iter.next().then(resolved => {
        if (!resolved.done) {
          this.parseMessage(resolved.value);
          return resolveGeneratorRecursively(iter);
        }
        return Promise.resolve();
      });
    };

@msgpack/msgpack

MessagePack for ECMA-262/JavaScript/TypeScript

ISC
Latest version published 2 years ago

Package Health Score

60 / 100
Full package analysis