diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:23:31 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:23:31 +0000 |
commit | 455e0f5882615111849ab934fdb6ebfdaea1ad2c (patch) | |
tree | 99024a2bbbd3b3b16d007ab57ebf8052f0d49956 /util/featureWriterStream.js | |
parent | b90502f6b7b8f045e38dfb88bf23bf26f7a7a072 (diff) | |
parent | f0df97945b4fdddd066170b120f192941b8d7fbf (diff) | |
download | timezone-boundary-builder-android13-mainline-os-statsd-release.tar.gz |
Snap for 8564071 from f0df97945b4fdddd066170b120f192941b8d7fbf to mainline-os-statsd-releaseaml_sta_341710000aml_sta_341615000aml_sta_341511040aml_sta_341410000aml_sta_341311010aml_sta_341114000aml_sta_341111000aml_sta_341010020aml_sta_340912000aml_sta_340911000aml_sta_331910000aml_sta_331811000aml_sta_331711010aml_sta_331610000aml_sta_331511000aml_sta_331410000aml_sta_331311000aml_sta_331010010aml_sta_330910000aml_net_341111030android14-mainline-os-statsd-releaseandroid13-mainline-os-statsd-release
Change-Id: I5713aa596c36ea10726c60b0fc74716c6ab7cd06
Diffstat (limited to 'util/featureWriterStream.js')
-rw-r--r-- | util/featureWriterStream.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util/featureWriterStream.js b/util/featureWriterStream.js new file mode 100644 index 0000000..7f0e7b8 --- /dev/null +++ b/util/featureWriterStream.js @@ -0,0 +1,25 @@ +const fs = require('fs') + +class FeatureWriterStream { + constructor (file) { + this.file = file + this.stream = fs.createWriteStream(file) + this.stream.write('{"type":"FeatureCollection","features":[') + this.numFeatures = 0 + } + + add (stringifiedFeature) { + if (this.numFeatures > 0) { + this.stream.write(',') + } + this.stream.write(stringifiedFeature) + this.numFeatures++ + } + + end (cb) { + console.log(`Closing out file ${this.file}`) + this.stream.end(']}', cb) + } +} + +module.exports = FeatureWriterStream |