Proposal: built-in YAML support, public API and placement
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, yaml
- 領域
- api
調査の方向性
Read the proposal and linked #67157, which contains the implementation and measurements; this issue focuses on deciding the public API and module placement. Review the proposed parsing behavior and alternatives, then check the discussion for an agreed direction. Done means the API and placement proposal has a decision; the issue leaves several follow-up questions open.
索引モデルが issue の本文から書いたものです。
説明
What is the problem this feature will solve?
An application that reads a YAML config file needs a third-party parser. Should Node provide one directly? If so, should it live in its own module?
YAML also came up in #53787, the discussion about Node's own configuration file.
What is the feature you are proposing to solve the problem?
#67157 proposes one function behind --experimental-yaml:
import { parse } from 'node:yaml';
parse('port: 8080'); // { port: 8080 }
Whether the parser is written in JS, vendored from yaml or js-yaml, or built in C++ or wasm is discussed in the PR, with measurements; the API is the same in every case. This issue is about the API.
parse(input[, options])accepts a string or UTF-8 bytes in anArrayBuffer,SharedArrayBuffer, typed array orDataView.- One document returns its value, multiple documents return an array, and an empty stream returns
null. - Invalid YAML throws a
SyntaxErrorwith codeERR_INVALID_YAMLand a line and column. WiththrowIfInvalid: false, it returnsundefinedinstead. - The parser uses the YAML 1.2 core schema:
yesandnoare strings, and0777is decimal. It doesn't convert timestamps to dates, expand merge keys or decode!!binary. - Mappings become plain objects. Even
__proto__is an own property. Duplicate keys are errors. Aliases to a collection refer to the same object, so the result can contain cycles.
Possible follow-ups:
stringify(value[, replacer[, space]]), with arguments likeJSON.stringify().- A
versionoption. Should we reserve it now with'1.2'as the only supported value, or wait until there's a second version to choose from? - A
reviveroption to transform parsed values. We'd need to define how it visits shared references and cycles. - A file or stream API that can parse large inputs without keeping the whole source in memory.
I'd favor node:yaml if we expect to offer both parsing and stringifying. It keeps those operations together. One concern raised in review is whether that sets a precedent for a module per format. I'd judge TOML, XML and other formats on their own use cases.
What alternatives have you considered?
- Add
util.parseYAML()alongsideutil.parseEnv(). This seems like a good fit if parsing is all we want. - Use a shared module such as
node:serdes, withserdes.yaml.parse(). Other formats could use it later, but we'd be designing the shared API with only one format in mind. - Keep YAML internal if Node adopts it for a feature such as config files or
import config from './config.yaml' with { type: 'yaml' }. Applications would still choose their own parser. - Leave YAML to packages such as
yamlandjs-yaml. Users can already choose between them, and core wouldn't take on another parser to maintain.
- 主要言語
- JavaScript
- スター
- 124k
- フォーク
- 38k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 266
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nodejs/node のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信
-
fs: document readStream.start and readStream.end対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンdoc
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
nodejs/node#67848 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
doc: document the Buffer.prototype.*Slice() methods対応中かも @AyushCipher が今日担当しました。 オープンdoc
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
nodejs/node#67847 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`styleText` fast path bypasses `options` and `options.validateStream` validation対応中かも @GBra-4-669 が 8 日前に担当しました。 オープンutil
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
riscv64
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nodejs/node#67655 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug triage needed
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
resource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
hesreallyhim/awesome-claude-code#3773 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the status対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信