parseCsv(input: string | BufReader, opt: ParseCsvOptions): Promise<unknown[]>: Read the string/buffer into an
const string = "a,b,c\nd,e,f";
console.log(
await parseCsv(string, {
header: false
})
);
// output:
// [["a", "b", "c"], ["d", "e", "f"]]This module parse TOML files. It follows as much as possible the TOML specs. Be sure to read the supported types as not every specs is supported at the moment and the handling in TypeScript side is a bit different.
- ✔️ Keys
- ❗ String
- ✔️ Multiline String
- ✔️ Literal String
- ❗ Integer
- ✔️ Float
- ✔️ Boolean
- ✔️ Offset Date-time
- ✔️ Local Date-time
- ✔️ Local Date
- ❗ Local Time
- ✔️ Table
- ✔️ Inline Table
- ❗ Array of Tables
❗ Supported with warnings see Warning.
- Regex : Due to the spec, there is no flag to detect regex properly in a TOML declaration. So the regex is stored as string.
For Binary / Octal / Hexadecimal numbers, they are stored as string to be not interpreted as Decimal.
Because local time does not exist in JavaScript, the local time is stored as a string.
Inline tables are supported. See below:
animal = { type = { name = "pug" } }
## Output
animal = { type.name = "pug" }
## Output { animal : { type : { name : "pug" } }
animal.as.leaders = "tosin"
## Output { animal: { as: { leaders: "tosin" } } }
"tosin.abasi" = "guitarist"
## Output
"tosin.abasi" : "guitarist"At the moment only simple declarations like below are supported:
[[bin]]
name = "deno"
path = "cli/main.rs"
[[bin]]
name = "deno_core"
path = "src/foo.rs"
[[nib]]
name = "node"
path = "not_found"will output:
{
"bin": [
{ "name": "deno", "path": "cli/main.rs" },
{ "name": "deno_core", "path": "src/foo.rs" }
],
"nib": [{ "name": "node", "path": "not_found" }]
}import { parse } from "./parser.ts";
import { readFileStrSync } from "../fs/read_file_str.ts";
const tomlObject = parse(readFileStrSync("file.toml"));
const tomlString = 'foo.bar = "Deno"';
const tomlObject22 = parse(tomlString);import { stringify } from "./parser.ts";
const obj = {
bin: [
{ name: "deno", path: "cli/main.rs" },
{ name: "deno_core", path: "src/foo.rs" }
],
nib: [{ name: "node", path: "not_found" }]
};
const tomlString = stringify(obj);YAML parser / dumper for Deno
Heavily inspired from js-yaml
parse parses the yaml string, and stringify dumps the given object to YAML
string.
import { parse, stringify } from "https://deno.land/std/encoding/yaml.ts";
const data = parse(`
foo: bar
baz:
- qux
- quux
`);
console.log(data);
// => { foo: "bar", baz: [ "qux", "quux" ] }
const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] });
console.log(yaml);
// =>
// foo: bar
// baz:
// - qux
// - quuxIf your YAML contains multiple documents in it, you can use parseAll for
handling it.
import { parseAll } from "https://deno.land/std/encoding/yaml.ts";
const data = parseAll(`
---
id: 1
name: Alice
---
id: 2
name: Bob
---
id: 3
name: Eve
`);
console.log(data);
// => [ { id: 1, name: "Alice" }, { id: 2, name: "Bob" }, { id: 3, name: "Eve" } ]Parses the YAML string with a single document.
Parses the YAML string with multiple documents. If the iterator is given, it's applied to every document instead of returning the array of parsed objects.
Serializes object as a YAML document.
binarytype is currently not stablefunction,regexp, andundefinedtype are currently not supported
See ./yaml/example folder and js-yaml repository.
RFC4648 base32 encoder/decoder for Deno
encode encodes a Uint8Array to RFC4648 base32 representation, and decode
decodes the given RFC4648 base32 representation to a Uint8Array.
import { encode, decode } from "https://deno.land/std/encoding/base32.ts";
const b32Repr = "RC2E6GA=";
const binaryData = decode(b32Repr);
console.log(binaryData);
// => Uint8Array [ 136, 180, 79, 24 ]
console.log(encode(binaryData));
// => RC2E6GA=