mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 15:24:10 +08:00
fix: encode mixed-format arrays at root level (fixes #202)
This commit is contained in:
@@ -38,6 +38,6 @@
|
||||
"test": "vitest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@toon-format/spec": "^2.0.0"
|
||||
"@toon-format/spec": "^2.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,10 +361,19 @@ function* encodeListItemValueLines(
|
||||
if (isJsonPrimitive(value)) {
|
||||
yield indentedListItem(depth, encodePrimitive(value, options.delimiter), options.indent)
|
||||
}
|
||||
else if (isJsonArray(value) && isArrayOfPrimitives(value)) {
|
||||
else if (isJsonArray(value)) {
|
||||
if (isArrayOfPrimitives(value)) {
|
||||
const arrayLine = encodeInlineArrayLine(value, options.delimiter)
|
||||
yield indentedListItem(depth, arrayLine, options.indent)
|
||||
}
|
||||
else {
|
||||
const header = formatHeader(value.length, { delimiter: options.delimiter })
|
||||
yield indentedListItem(depth, header, options.indent)
|
||||
for (const item of value) {
|
||||
yield* encodeListItemValueLines(item, depth + 1, options)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isJsonObject(value)) {
|
||||
yield* encodeObjectAsListItemLines(value, depth, options)
|
||||
}
|
||||
|
||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -114,8 +114,8 @@ importers:
|
||||
packages/toon:
|
||||
devDependencies:
|
||||
'@toon-format/spec':
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0
|
||||
specifier: ^2.0.1
|
||||
version: 2.0.1
|
||||
|
||||
packages:
|
||||
|
||||
@@ -1149,8 +1149,8 @@ packages:
|
||||
peerDependencies:
|
||||
eslint: '>=9.0.0'
|
||||
|
||||
'@toon-format/spec@2.0.0':
|
||||
resolution: {integrity: sha512-rNM1N74QcbUnI7quWL3RRhAPl/dFzw9RhPxGf8l2ICRvoY76w8wAp2ydE3mq8re1+cy4HAWr5wCRcNrlT8zzRQ==}
|
||||
'@toon-format/spec@2.0.1':
|
||||
resolution: {integrity: sha512-scuKWamwioJKOE+C9KfSBUdxTn92oeBJCW6U5HEUPh+AqJddhB+H2WLSiYWaTLJsiHoq+9oen7jqJwGxwxp7Ig==}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||
@@ -4257,7 +4257,7 @@ snapshots:
|
||||
estraverse: 5.3.0
|
||||
picomatch: 4.0.3
|
||||
|
||||
'@toon-format/spec@2.0.0': {}
|
||||
'@toon-format/spec@2.0.1': {}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user