mirror of
https://github.com/nushell/nushell.git
synced 2024-11-28 19:33:47 +01:00
2a3805c164
# Description Uses "normal" module `std/<submodule>/mod.nu` instead of renaming the files (as requested in #13842). # User-Facing Changes No user-facing changes other than in `view files` results. Imports remain the same after this PR. # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` Also manually confirmed that it does not interfere with nupm, since we did have a conflict at one point (and it's not possible to test here). # Performance Tests ## Linux ### Nushell Startup - No config ```nu bench --pretty -n 200 { <path_to>/nu -c "exit" } ``` | Release | Startup Time | | --- | --- | | 0.98.0 | 22ms 730µs 768ns +/- 1ms 515µs 942ns | This commit | 9ms 312µs 68ns +/- 709µs 378ns | Yesterday's nightly | 9ms 230µs 953ns +/- 9ms 67µs 689ns ### Nushell Startup - Load full standard library Measures relative impact of a full `use std *`, which isn't recommended, but worth tracking. ```nu bench --pretty -n 200 { <path_to>/nu -c "use std *; exit" } ``` | Release | Startup Time | | --- | --- | | 0.98.0 | 23ms 10µs 636ns +/- 1ms 277µs 854ns | This commit | 26ms 922µs 769ns +/- 562µs 538ns | Yesterday's nightly | 28ms 133µs 95ns +/- 761µs 943ns | `deprecated_dirs` removal PR * | 23ms 610µs 333ns +/- 369µs 436ns \* Current increase is partially due to double-loading `dirs` with removal warning in older version. # After Submitting Still TODO - Update standard library doc
31 lines
836 B
Plaintext
31 lines
836 B
Plaintext
# formats.nu
|
|
#
|
|
# This file contains functions for formatting data in various ways.
|
|
#
|
|
# Usage:
|
|
# use std format *
|
|
# use std format <function name>
|
|
#
|
|
# These functions help `open` the files with unsupported extensions such as ndjson.
|
|
#
|
|
|
|
# Convert from [NDJSON](https://github.com/ndjson/ndjson-spec) to structured data.
|
|
export def "from ndjson" []: string -> any {
|
|
from json --objects
|
|
}
|
|
|
|
# Convert from [JSONL](https://jsonlines.org/) to structured data.
|
|
export def "from jsonl" []: string -> any {
|
|
from json --objects
|
|
}
|
|
|
|
# Convert structured data to [NDJSON](https://github.com/ndjson/ndjson-spec).
|
|
export def "to ndjson" []: any -> string {
|
|
each { to json --raw } | to text
|
|
}
|
|
|
|
# Convert structured data to [JSONL](https://jsonlines.org/).
|
|
export def "to jsonl" []: any -> string {
|
|
each { to json --raw } | to text
|
|
}
|