Repository navigation
perf: replace js-yaml with tinyaml #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
05d923c
ef8a51f
ba06567
10d48c3
237f314
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,16 @@ function isValidComponentName(name: string): boolean { | |
| return RE_COMPONENT_NAME.test(name) | ||
| } | ||
|
|
||
| /** | ||
| * JSON has no Infinity or NaN, so `JSON.stringify` would turn YAML's `.inf` | ||
| * and `.nan` into `null`. Keep them as the YAML strings js-yaml returned. | ||
| */ | ||
| function yamlNonFiniteToString(value: unknown): unknown { | ||
| if (typeof value !== 'number' || Number.isFinite(value)) return value | ||
| if (Number.isNaN(value)) return '.nan' | ||
| return value > 0 ? '.inf' : '-.inf' | ||
| } | ||
|
|
||
| const blockYamlLines: Record<string, string> = { | ||
| '---': '---', | ||
| '```yaml [props]': '```', | ||
|
|
@@ -312,10 +322,14 @@ const markdownItComarkBlock: PluginSimple = (md) => { | |
| // bindings with a JSON-string payload. Framework renderers (and | ||
| // resolveAttributes with parseJson) restore native types; quoted YAML | ||
| // strings stay unprefixed and remain strings (#364). | ||
| if (typeof value === 'string') { | ||
| token.attrSet(key, value) | ||
| const prop = yamlNonFiniteToString(value) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convert When component YAML contains
|
||
| if (typeof prop === 'string') { | ||
| token.attrSet(key, prop) | ||
| } else { | ||
| token.attrSet(`:${key}`, JSON.stringify(value)) | ||
| token.attrSet( | ||
| `:${key}`, | ||
| JSON.stringify(prop, (_, nested) => yamlNonFiniteToString(nested)) | ||
| ) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: comarkdown/comark
Length of output: 845
Declare or document the Node.js floor that
tinyamlintroduces.tinyaml@0.1.0declaresengines: {node: '>=22.12.0'}in the lockfile.comarkadds it as a runtime dependency, and the package declares noenginesfield or other Node.js floor. Consumers on Node.js below 22.12 can see an engine mismatch warning on install. With strict engine checks, the install can fail. If your supported range includes those versions, use atinyamlversion that supports them or confirm the new minimum. Then declare it inpackages/comark/package.jsonand document it.