From bad6f2b224a92e3bf5cdaf5f8cbc700cb0f9de04 Mon Sep 17 00:00:00 2001 From: Ch3ri0ur <22932267+Ch3ri0ur@users.noreply.github.com> Date: Tue, 9 Jun 2020 21:08:38 +0200 Subject: [PATCH] Readme cleanup in encoding and ws (#6209) --- std/encoding/README.md | 45 +++++++++++++++++++++++++++--------------- std/ws/README.md | 4 ++-- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/std/encoding/README.md b/std/encoding/README.md index 50db5364f9..15c8c40bf5 100644 --- a/std/encoding/README.md +++ b/std/encoding/README.md @@ -77,6 +77,7 @@ function is as follows: ### Usage ```ts +import { parse } from "https://deno.land/std/encoding/csv.ts"; const string = "a,b,c\nd,e,f"; console.log( @@ -182,24 +183,10 @@ will output: } ``` -### Usage - -#### Parse +### Basic usage ```ts -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); -``` - -#### Stringify - -```ts -import { stringify } from "./parser.ts"; +import { parse, stringify } from "https://deno.land/std/encoding/toml.ts"; const obj = { bin: [ { name: "deno", path: "cli/main.rs" }, @@ -208,6 +195,32 @@ const obj = { nib: [{ name: "node", path: "not_found" }], }; const tomlString = stringify(obj); +console.log(tomlString); + +// => +// [[bin]] +// name = "deno" +// path = "cli/main.rs" + +// [[bin]] +// name = "deno_core" +// path = "src/foo.rs" + +// [[nib]] +// name = "node" +// path = "not_found" + +const tomlObject = parse(tomlString); +console.log(tomlObject); + +// => +// { +// bin: [ +// { name: "deno", path: "cli/main.rs" }, +// { name: "deno_core", path: "src/foo.rs" } +// ], +// nib: [ { name: "node", path: "not_found" } ] +// } ``` ## YAML diff --git a/std/ws/README.md b/std/ws/README.md index 0c3b7a2a27..d719f22a9a 100644 --- a/std/ws/README.md +++ b/std/ws/README.md @@ -8,13 +8,13 @@ ws module is made to provide helpers to create WebSocket client/server. ```ts // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { serve } from "../../http/server.ts"; +import { serve } from "https://deno.land/std/http/server.ts"; import { acceptWebSocket, isWebSocketCloseEvent, isWebSocketPingEvent, WebSocket, -} from "../../ws/mod.ts"; +} from "https://deno.land/std/ws/mod.ts"; async function handleWs(sock: WebSocket) { console.log("socket connected!");