-->
当前位置:首页 > articles > 正文内容

Luz3个月前 (10-27)articles372

How would I use sort-stream2 to sort a stream in nodeJS

  • T D 问题:
    • const fs = require("node:fs");const ndjson = require("ndjson");const { createReadStream } = require("node:fs");const { filterSpam } = require("./filter-spam");const { checkPositivity } = require("./check-positivity.js");const sort = require("sort-stream2");const ws = fs.createWriteStream("filteredData.ndjson");createReadStream("cellphone.ndjson")  .pipe(ndjson.parse())  .pipe(filterSpam())  .pipe(checkPositivity())  .pipe(    sort(function (a, b) {      return a["AFINN"] - b["AFINN"];    })  )  //write to stream here
    • { reviewText: 'While there was nothing wrong with the adapter, it did not work correctly in my phone. The jack is the right size and should support stereo operations, but I only get mono sound. I went to Radio Shack and for $12 got one the worked correctly.',  overall: 2,  summary: "Don't bother",  category: 'Cell_Phones_and_Accessories',  AFINN: 0}
  • 回答:
返回列表

上一篇:

下一篇:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。