Adding fileStream information to documentation

未关闭
#6 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
48/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
领域
documentation

调研方向

找到描述 stringifier 和传输流的文档,然后将其与 issue 中的文件流示例进行比较。更新文档,使读者了解如何将数据通过管道传输到 fs.createWriteStream,以及是否需要调用 fileStream.end();当文件流工作流程和流关闭行为都清晰时即完成。

由索引模型根据 Issue 内容生成。

描述

enhancement help wanted

It might be helpful to include some documentation for people who are unfamiliar with transfer streams (like I was until I asked chatGPT). The docs mention that the stringifier writes to a transfer stream, but this is a subtle, and many people are likely to miss that detail or read through it because they don't know what it means.

Here is the code I wrote that can handle file streams:

import jsonlines from "jsonlines"
import fs from "fs"
import path from 'path'

export default function example () {

  // I created a folder in my repo caled "files", and the stringifier will write to it (only locally, don't try this on something like Heroku)
  const outputFilePath = path.join('files', 'jsonl-testing.jsonl')
  const fileStream = fs.createWriteStream(outputFilePath)

  const stringifier = jsonlines.stringify()
  stringifier.pipe(fileStream)
  stringifier.write({
    "prompt": "Question: What is the meaning of life?\n\n###\n\n",
    "completion": "Answer: 42.\n\nEND"
  })
  stringifier.write({
    "prompt": "Question: What is not the meaning of life?\n\n###\n\n",
    "completion": "Answer: not 42.\n\nEND"
  })
  stringifier.end()
  fileStream.end() // do we need to do this? Docs do not specifiy
}
主要语言
JavaScript
星标
25
派生
2
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

LinusU/node-jsonlines 的其他 Issue

查看 LinusU/node-jsonlines 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。