Skip to content

Instantly share code, notes, and snippets.

@benjamingr
Created June 14, 2022 19:04
Show Gist options
  • Save benjamingr/456e7283411df0d75cad66e6d50282db to your computer and use it in GitHub Desktop.
Save benjamingr/456e7283411df0d75cad66e6d50282db to your computer and use it in GitHub Desktop.

Revisions

  1. benjamingr created this gist Jun 14, 2022.
    10 changes: 10 additions & 0 deletions parse-json-stream-modern.mjs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    import { default as parser } from 'stream-json';
    import { Readable } from 'stream';

    const parkingViolations = await fetch('https://s3.amazonaws.com/philadelphia-parking-violations-raw-data/parking_violations_2017.json');
    await Readable.fromWeb(parkingViolations.body)
    .pipe(parser())
    .filter(violation => violation.name === 'stringChunk')
    .map(x => x.value)
    .take(5)
    .forEach(v => console.log(v));