Repository navigation
Bake mixed-scalar JSON tables and destructure unions of arrays and tuples #1455
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
Changes from all commits
3358898
52f9bf2
fe322ae
45431ae
437dc11
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "order": [ | ||
| "<repo>/tests/corpus/6410-json-mixed-scalar-tables/main.ts" | ||
| ], | ||
| "diags": [] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "order": [ | ||
| "<repo>/tests/corpus/6411-union-array-tuple-destructuring.ts" | ||
| ], | ||
| "diags": [] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [["x", 1, "two", 3], [4, "five", null], ["six"], [null]] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // JSON tables whose rows mix strings and numbers, the shape of a | ||
| // character-set table (`[["8140", 12288, 65292], ...]`) and of a | ||
| // code-point range map (`[[[0, 44], "disallowed"], [[65, 65], "mapped", | ||
| // [97]], ...]`). A package requires them at load or inside a function, and | ||
| // an ES module imports one; each row keeps its strings and numbers. | ||
| import { lookup, rowCount } from "code-table"; | ||
| import { mapChars, status } from "range-map"; | ||
| import extra from "./extra.json" with { type: "json" }; | ||
|
|
||
| console.log(lookup("8150"), lookup("a1"), lookup("zzzz"), rowCount()); | ||
| const mapped = mapChars("AB-c9"); | ||
| console.log(mapped.text, mapped.error); | ||
| console.log(JSON.stringify(mapChars("a,b")), JSON.stringify(mapChars("{"))); | ||
| console.log(status(10), status(46), status(66), status(1000)); | ||
|
|
||
| for (const row of extra) { | ||
| const head = row[0]; | ||
| const rest = row.slice(1); | ||
| console.log( | ||
| typeof head, | ||
| head, | ||
| rest.length, | ||
| rest.map((v) => (v === null ? "null" : typeof v === "number" ? v + 1 : v.toUpperCase())).join(","), | ||
| ); | ||
| } | ||
| console.log(JSON.stringify(extra)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.