Proposal: built-in YAML support, public API and placement
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- javascript, node.js, yaml
- Domaine
- api
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- JavaScript
- Étoiles
- 124k
- Forks
- 38k
- Merge moyen
- 4 j 2 h
- PR mergées (30 j)
- 266
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nodejs/node
-
Difficulté 2/5 1-3 heures Accessibilité débutants 69/100
Les mainteneurs répondent en général sous 1 jour
-
fs: document readStream.start and readStream.endPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertedoc
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
nodejs/node#67848 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
doc: document the Buffer.prototype.*Slice() methodsPeut-être pris @AyushCipher l’a pris aujourd’hui. Ouvertedoc
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
nodejs/node#67847 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
`styleText` fast path bypasses `options` and `options.validateStream` validationPeut-être pris @GBra-4-669 l’a pris il y a 8 jours. Ouverteutil
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
riscv64
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
nodejs/node#67655 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nodejs/node
Issues similaires
-
bug triage needed
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
[Resource]: PersephoneOuverteresource-submission validation-passed
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
hesreallyhim/awesome-claude-code#3773 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 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 statusPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour