1.0.0 • Published 3 years ago

external-sort v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

external-sort

external sorting

NPM version build status Test coverage David deps Known Vulnerabilities npm download

用法

const input = fs.createReadStream(inputFile); // 输入文件流
const output = fs.createWriteStream(outputFile); // 输出文件流

await externalSort(input, output, {
  maxHeap: 1024 * 1024,
});

支持的参数

  • maxHeap 内存排序的上限,超过需要借助文件,默认值为 1GB
  • tempDir 临时文件目录,默认为 os.tmpdir()
  • serializer 回写文件时处理数据的函数
  • deserializer 处理一行输入的函数
  • comparer 排序的比较函数

Benchmark

npm.io