How to use the stream-json/Assembler.connectTo function in stream-json

To help you get started, we’ve selected a few stream-json 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 embark-framework / embark / src / lib / modules / blockchain_process / proxy.js View on Github external
const server = http.createServer((req, res) => {
      if (req.method === 'POST') {
        // messages TO the target
        Asm.connectTo(
          pump(req, jsonParser())
        ).on('done', ({current: object}) => {
          this.trackRequest(object);
        });
      }

      if (!ws) {
        proxy.web(req, res);
      }
    });
github embark-framework / embark / packages / embark-proxy / src / old_proxy.js View on Github external
const server = http.createServer((req, res) => {
      if (req.method === 'POST') {
        // messages TO the target
        Asm.connectTo(
          pump(req, jsonParser())
        ).on('done', ({current: object}) => {
          this.trackRequest({ ws: false, data: object});
        });
      }

      if (!ws) {
        proxy.web(req, res);
      }
    });
github embark-framework / embark / packages / embark-blockchain-process / src / proxy.js View on Github external
const server = http.createServer((req, res) => {
      if (req.method === 'POST') {
        // messages TO the target
        Asm.connectTo(
          pump(req, jsonParser())
        ).on('done', ({current: object}) => {
          this.trackRequest({ ws: false, data: object});
        });
      }

      if (!ws) {
        proxy.web(req, res);
      }
    });
github ravendb / ravendb-nodejs-client / perf / loadPipeline.js View on Github external
dataStream,
        parser({
            packKeys: true,
            packStrings: true,
            packValues: true,
            packNumbers: true,
            streamNumbers: false,
            streamValues: false,
            streamKeys: false,
            streamStrings: false
        }),
        new TransformKeysJsonStream({
            getCurrentTransform: buildEntityKeysTransform("camel")
        })
    ];
    const asm = Asm.connectTo(streams[streams.length - 1]);
    const donePromise = new Promise(resolve => {
        asm.on('done', asm => {
            resolve(asm.current);
        });
    });
    await StreamUtil.pipelineAsync(streams);
    const result = await donePromise;
}
github ravendb / ravendb-nodejs-client / perf / loadPipeline.js View on Github external
async function rawStreamJson() {
    const dataStream = fs.createReadStream("./data/load_data.json");
    const parserStream = parser();
    const asm = Asm.connectTo(parserStream);
    const donePromise = new Promise(resolve => {
        asm.on('done', asm => {
            resolve();
        });
    });
    await StreamUtil.pipelineAsync([
        dataStream,
        parserStream,
        ignore({ filter: "asasas" })
    ]);
    await donePromise;
}

stream-json

stream-json is the micro-library of Node.js stream components for creating custom JSON processing pipelines with a minimal memory footprint. It can parse JSON files far exceeding available memory streaming individual primitives using a SAX-inspired API. I

BSD-3-Clause
Latest version published 9 days ago

Package Health Score

80 / 100
Full package analysis