mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
docs(std): version all imports in README (#7442)
Use $STD_VERSION in std/ README files to automatically display proper version.
This commit is contained in:
parent
ec96323823
commit
3d65177dbc
17 changed files with 101 additions and 68 deletions
|
@ -65,7 +65,7 @@ deno run https://deno.land/std/examples/welcome.ts
|
||||||
Or a more complex one:
|
Or a more complex one:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
import { serve } from "https://deno.land/std@0.69.0/http/server.ts";
|
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||||
const s = serve({ port: 8000 });
|
const s = serve({ port: 8000 });
|
||||||
console.log("http://localhost:8000/");
|
console.log("http://localhost:8000/");
|
||||||
for await (const req of s) {
|
for await (const req of s) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
## Tar
|
## Tar
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Tar } from "https://deno.land/std/archive/tar.ts";
|
import { Tar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
|
||||||
|
|
||||||
const tar = new Tar();
|
const tar = new Tar();
|
||||||
const content = new TextEncoder().encode("Deno.land");
|
const content = new TextEncoder().encode("Deno.land");
|
||||||
|
@ -27,9 +27,9 @@ writer.close();
|
||||||
## Untar
|
## Untar
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Untar } from "https://deno.land/std/archive/tar.ts";
|
import { Untar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
|
||||||
import { ensureFile } from "https://deno.land/std/fs/ensure_file.ts";
|
import { ensureFile } from "https://deno.land/std@$STD_VERSION/fs/ensure_file.ts";
|
||||||
import { ensureDir } from "https://deno.land/std/fs/ensure_dir.ts";
|
import { ensureDir } from "https://deno.land/std@$STD_VERSION/fs/ensure_dir.ts";
|
||||||
|
|
||||||
const reader = await Deno.open("./out.tar", { read: true });
|
const reader = await Deno.open("./out.tar", { read: true });
|
||||||
const untar = new Untar(reader);
|
const untar = new Untar(reader);
|
||||||
|
|
|
@ -11,7 +11,7 @@ All the following functions are exposed in `mod.ts`.
|
||||||
Find first index of binary pattern from given binary array.
|
Find first index of binary pattern from given binary array.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { findIndex } from "https://deno.land/std/bytes/mod.ts";
|
import { findIndex } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
findIndex(
|
findIndex(
|
||||||
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
|
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
|
||||||
|
@ -26,7 +26,7 @@ findIndex(
|
||||||
Find last index of binary pattern from given binary array.
|
Find last index of binary pattern from given binary array.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { findLastIndex } from "https://deno.land/std/bytes/mod.ts";
|
import { findLastIndex } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
findLastIndex(
|
findLastIndex(
|
||||||
new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]),
|
new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]),
|
||||||
|
@ -41,7 +41,7 @@ findLastIndex(
|
||||||
Check whether given binary arrays are equal to each other.
|
Check whether given binary arrays are equal to each other.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { equal } from "https://deno.land/std/bytes/mod.ts";
|
import { equal } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
equal(new Uint8Array([0, 1, 2, 3]), new Uint8Array([0, 1, 2, 3])); // returns true
|
equal(new Uint8Array([0, 1, 2, 3]), new Uint8Array([0, 1, 2, 3])); // returns true
|
||||||
equal(new Uint8Array([0, 1, 2, 3]), new Uint8Array([0, 1, 2, 4])); // returns false
|
equal(new Uint8Array([0, 1, 2, 3]), new Uint8Array([0, 1, 2, 4])); // returns false
|
||||||
|
@ -52,7 +52,7 @@ equal(new Uint8Array([0, 1, 2, 3]), new Uint8Array([0, 1, 2, 4])); // returns fa
|
||||||
Check whether binary array has binary prefix.
|
Check whether binary array has binary prefix.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { hasPrefix } from "https://deno.land/std/bytes/mod.ts";
|
import { hasPrefix } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
hasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([0, 1])); // returns true
|
hasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([0, 1])); // returns true
|
||||||
hasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([1, 2])); // returns false
|
hasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([1, 2])); // returns false
|
||||||
|
@ -63,7 +63,7 @@ hasPrefix(new Uint8Array([0, 1, 2]), new Uint8Array([1, 2])); // returns false
|
||||||
Repeat bytes of given binary array and return new one.
|
Repeat bytes of given binary array and return new one.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { repeat } from "https://deno.land/std/bytes/mod.ts";
|
import { repeat } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
repeat(new Uint8Array([1]), 3); // returns Uint8Array(3) [ 1, 1, 1 ]
|
repeat(new Uint8Array([1]), 3); // returns Uint8Array(3) [ 1, 1, 1 ]
|
||||||
```
|
```
|
||||||
|
@ -73,7 +73,7 @@ repeat(new Uint8Array([1]), 3); // returns Uint8Array(3) [ 1, 1, 1 ]
|
||||||
Concatenate two binary arrays and return new one.
|
Concatenate two binary arrays and return new one.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { concat } from "https://deno.land/std/bytes/mod.ts";
|
import { concat } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
concat(new Uint8Array([1, 2]), new Uint8Array([3, 4])); // returns Uint8Array(4) [ 1, 2, 3, 4 ]
|
concat(new Uint8Array([1, 2]), new Uint8Array([3, 4])); // returns Uint8Array(4) [ 1, 2, 3, 4 ]
|
||||||
```
|
```
|
||||||
|
@ -83,7 +83,7 @@ concat(new Uint8Array([1, 2]), new Uint8Array([3, 4])); // returns Uint8Array(4)
|
||||||
Copy bytes from one binary array to another.
|
Copy bytes from one binary array to another.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { copyBytes } from "https://deno.land/std/bytes/mod.ts";
|
import { copyBytes } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||||
|
|
||||||
const dst = new Uint8Array(4);
|
const dst = new Uint8Array(4);
|
||||||
const src = Uint8Array.of(1, 2, 3, 4);
|
const src = Uint8Array.of(1, 2, 3, 4);
|
||||||
|
|
|
@ -37,7 +37,7 @@ are supported:
|
||||||
Takes an input `string` and a `formatString` to parse to a `date`.
|
Takes an input `string` and a `formatString` to parse to a `date`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { parse } from 'https://deno.land/std/datetime/mod.ts'
|
import { parse } from 'https://deno.land/std@0.69.0/datetime/mod.ts'
|
||||||
|
|
||||||
parse("20-01-2019", "dd-MM-yyyy") // output : new Date(2019, 0, 20)
|
parse("20-01-2019", "dd-MM-yyyy") // output : new Date(2019, 0, 20)
|
||||||
parse("2019-01-20", "yyyy-MM-dd") // output : new Date(2019, 0, 20)
|
parse("2019-01-20", "yyyy-MM-dd") // output : new Date(2019, 0, 20)
|
||||||
|
@ -54,7 +54,7 @@ parse("01-20-2019 16:34:23.123", "MM-dd-yyyy HH:mm:ss.SSS") // output : new Date
|
||||||
Takes an input `date` and a `formatString` to format to a `string`.
|
Takes an input `date` and a `formatString` to format to a `string`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { format } from "https://deno.land/std/datetime/mod.ts";
|
import { format } from "https://deno.land/std@$STD_VERSION/datetime/mod.ts";
|
||||||
|
|
||||||
format(new Date(2019, 0, 20), "dd-MM-yyyy"); // output : "20-01-2019"
|
format(new Date(2019, 0, 20), "dd-MM-yyyy"); // output : "20-01-2019"
|
||||||
format(new Date(2019, 0, 20), "yyyy-MM-dd"); // output : "2019-01-20"
|
format(new Date(2019, 0, 20), "yyyy-MM-dd"); // output : "2019-01-20"
|
||||||
|
@ -71,7 +71,7 @@ format(new Date(2019, 0, 20), "'today:' yyyy-MM-dd"); // output : "today: 2019-0
|
||||||
Returns the number of the day in the year.
|
Returns the number of the day in the year.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { dayOfYear } from "https://deno.land/std/datetime/mod.ts";
|
import { dayOfYear } from "https://deno.land/std@$STD_VERSION/datetime/mod.ts";
|
||||||
|
|
||||||
dayOfYear(new Date("2019-03-11T03:24:00")); // output: 70
|
dayOfYear(new Date("2019-03-11T03:24:00")); // output: 70
|
||||||
```
|
```
|
||||||
|
@ -81,7 +81,7 @@ dayOfYear(new Date("2019-03-11T03:24:00")); // output: 70
|
||||||
Returns the ISO week number of the provided date (1-53).
|
Returns the ISO week number of the provided date (1-53).
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { weekOfYear } from "https://deno.land/std/datetime/mod.ts";
|
import { weekOfYear } from "https://deno.land/std@$STD_VERSION/datetime/mod.ts";
|
||||||
|
|
||||||
weekOfYear(new Date("2020-12-28T03:24:00")); // Returns 53
|
weekOfYear(new Date("2020-12-28T03:24:00")); // Returns 53
|
||||||
```
|
```
|
||||||
|
|
|
@ -82,7 +82,7 @@ function is as follows:
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { parse } from "https://deno.land/std/encoding/csv.ts";
|
import { parse } from "https://deno.land/std@$STD_VERSION/encoding/csv.ts";
|
||||||
const string = "a,b,c\nd,e,f";
|
const string = "a,b,c\nd,e,f";
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -187,7 +187,10 @@ will output:
|
||||||
### Basic usage
|
### Basic usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { parse, stringify } from "https://deno.land/std/encoding/toml.ts";
|
import {
|
||||||
|
parse,
|
||||||
|
stringify,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/encoding/toml.ts";
|
||||||
const obj = {
|
const obj = {
|
||||||
bin: [
|
bin: [
|
||||||
{ name: "deno", path: "cli/main.rs" },
|
{ name: "deno", path: "cli/main.rs" },
|
||||||
|
@ -236,7 +239,10 @@ Heavily inspired from [js-yaml].
|
||||||
string.
|
string.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { parse, stringify } from "https://deno.land/std/encoding/yaml.ts";
|
import {
|
||||||
|
parse,
|
||||||
|
stringify,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/encoding/yaml.ts";
|
||||||
|
|
||||||
const data = parse(`
|
const data = parse(`
|
||||||
foo: bar
|
foo: bar
|
||||||
|
@ -260,7 +266,7 @@ If your YAML contains multiple documents in it, you can use `parseAll` for
|
||||||
handling it.
|
handling it.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { parseAll } from "https://deno.land/std/encoding/yaml.ts";
|
import { parseAll } from "https://deno.land/std@$STD_VERSION/encoding/yaml.ts";
|
||||||
|
|
||||||
const data = parseAll(`
|
const data = parseAll(`
|
||||||
---
|
---
|
||||||
|
@ -312,7 +318,10 @@ for Deno.
|
||||||
decodes the given RFC4648 base32 representation to a `Uint8Array`.
|
decodes the given RFC4648 base32 representation to a `Uint8Array`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { decode, encode } from "https://deno.land/std/encoding/base32.ts";
|
import {
|
||||||
|
decode,
|
||||||
|
encode,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/encoding/base32.ts";
|
||||||
|
|
||||||
const b32Repr = "RC2E6GA=";
|
const b32Repr = "RC2E6GA=";
|
||||||
|
|
||||||
|
@ -334,7 +343,10 @@ Ascii85/base85 encoder and decoder with support for multiple standards.
|
||||||
decodes the given ascii85 representation to a `Uint8Array`.
|
decodes the given ascii85 representation to a `Uint8Array`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { decode, encode } from "https://deno.land/std/encoding/ascii85.ts";
|
import {
|
||||||
|
decode,
|
||||||
|
encode,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/encoding/ascii85.ts";
|
||||||
|
|
||||||
const a85Repr = "LpTqp";
|
const a85Repr = "LpTqp";
|
||||||
|
|
||||||
|
@ -363,7 +375,10 @@ supported by other encodings.)
|
||||||
encoding examples:
|
encoding examples:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { decode, encode } from "https://deno.land/std/encoding/ascii85.ts";
|
import {
|
||||||
|
decode,
|
||||||
|
encode,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/encoding/ascii85.ts";
|
||||||
const binaryData = new Uint8Array([136, 180, 79, 24]);
|
const binaryData = new Uint8Array([136, 180, 79, 24]);
|
||||||
console.log(encode(binaryData));
|
console.log(encode(binaryData));
|
||||||
// => LpTqp
|
// => LpTqp
|
||||||
|
|
|
@ -5,7 +5,7 @@ Command line arguments parser for Deno based on minimist.
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { parse } from "https://deno.land/std/flags/mod.ts";
|
import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts";
|
||||||
|
|
||||||
console.dir(parse(Deno.args));
|
console.dir(parse(Deno.args));
|
||||||
```
|
```
|
||||||
|
@ -56,7 +56,7 @@ options can be:
|
||||||
example:
|
example:
|
||||||
```ts
|
```ts
|
||||||
// $ deno run example.ts -- a arg1
|
// $ deno run example.ts -- a arg1
|
||||||
import { parse } from "https://deno.land/std/flags/mod.ts";
|
import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts";
|
||||||
console.dir(parse(Deno.args, { "--": false }));
|
console.dir(parse(Deno.args, { "--": false }));
|
||||||
// output: { _: [ "a", "arg1" ] }
|
// output: { _: [ "a", "arg1" ] }
|
||||||
console.dir(parse(Deno.args, { "--": true }));
|
console.dir(parse(Deno.args, { "--": true }));
|
||||||
|
|
|
@ -14,7 +14,10 @@ is not empty. If the directory does not exist, it is created. The directory
|
||||||
itself is not deleted.
|
itself is not deleted.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { emptyDir, emptyDirSync } from "https://deno.land/std/fs/mod.ts";
|
import {
|
||||||
|
emptyDir,
|
||||||
|
emptyDirSync,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
emptyDir("./foo"); // returns a promise
|
emptyDir("./foo"); // returns a promise
|
||||||
emptyDirSync("./foo"); // void
|
emptyDirSync("./foo"); // void
|
||||||
|
@ -26,7 +29,10 @@ Ensures that the directory exists. If the directory structure does not exist, it
|
||||||
is created. Like `mkdir -p`.
|
is created. Like `mkdir -p`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { ensureDir, ensureDirSync } from "https://deno.land/std/fs/mod.ts";
|
import {
|
||||||
|
ensureDir,
|
||||||
|
ensureDirSync,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
ensureDir("./bar"); // returns a promise
|
ensureDir("./bar"); // returns a promise
|
||||||
ensureDirSync("./ensureDirSync"); // void
|
ensureDirSync("./ensureDirSync"); // void
|
||||||
|
@ -39,7 +45,10 @@ directories that do not exist, these directories are created. If the file
|
||||||
already exists, it is **NOT MODIFIED**.
|
already exists, it is **NOT MODIFIED**.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { ensureFile, ensureFileSync } from "https://deno.land/std/fs/mod.ts";
|
import {
|
||||||
|
ensureFile,
|
||||||
|
ensureFileSync,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
ensureFile("./folder/targetFile.dat"); // returns promise
|
ensureFile("./folder/targetFile.dat"); // returns promise
|
||||||
ensureFileSync("./folder/targetFile.dat"); // void
|
ensureFileSync("./folder/targetFile.dat"); // void
|
||||||
|
@ -54,7 +63,7 @@ created.
|
||||||
import {
|
import {
|
||||||
ensureSymlink,
|
ensureSymlink,
|
||||||
ensureSymlinkSync,
|
ensureSymlinkSync,
|
||||||
} from "https://deno.land/std/fs/mod.ts";
|
} from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
ensureSymlink("./folder/targetFile.dat", "./folder/targetFile.link.dat"); // returns promise
|
ensureSymlink("./folder/targetFile.dat", "./folder/targetFile.link.dat"); // returns promise
|
||||||
ensureSymlinkSync("./folder/targetFile.dat", "./folder/targetFile.link.dat"); // void
|
ensureSymlinkSync("./folder/targetFile.dat", "./folder/targetFile.link.dat"); // void
|
||||||
|
@ -65,7 +74,7 @@ ensureSymlinkSync("./folder/targetFile.dat", "./folder/targetFile.link.dat"); //
|
||||||
Detects and format the passed string for the targeted End Of Line character.
|
Detects and format the passed string for the targeted End Of Line character.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { format, detect, EOL } from "https://deno.land/std/fs/mod.ts";
|
import { format, detect, EOL } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
const CRLFinput = "deno\r\nis not\r\nnode";
|
const CRLFinput = "deno\r\nis not\r\nnode";
|
||||||
const Mixedinput = "deno\nis not\r\nnode";
|
const Mixedinput = "deno\nis not\r\nnode";
|
||||||
|
@ -86,7 +95,10 @@ format(CRLFinput, EOL.LF); // output "deno\nis not\nnode"
|
||||||
Test whether or not the given path exists by checking with the file system.
|
Test whether or not the given path exists by checking with the file system.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { exists, existsSync } from "https://deno.land/std/fs/mod.ts";
|
import {
|
||||||
|
exists,
|
||||||
|
existsSync,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
exists("./foo"); // returns a Promise<boolean>
|
exists("./foo"); // returns a Promise<boolean>
|
||||||
existsSync("./foo"); // returns boolean
|
existsSync("./foo"); // returns boolean
|
||||||
|
@ -97,7 +109,7 @@ existsSync("./foo"); // returns boolean
|
||||||
Moves a file or directory. Overwrites it if option provided.
|
Moves a file or directory. Overwrites it if option provided.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { move, moveSync } from "https://deno.land/std/fs/mod.ts";
|
import { move, moveSync } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
move("./foo", "./bar"); // returns a promise
|
move("./foo", "./bar"); // returns a promise
|
||||||
moveSync("./foo", "./bar"); // void
|
moveSync("./foo", "./bar"); // void
|
||||||
|
@ -110,7 +122,7 @@ moveSync("./foo", "./existingFolder", { overwrite: true });
|
||||||
copy a file or directory. Overwrites it if option provided.
|
copy a file or directory. Overwrites it if option provided.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { copy, copySync } from "https://deno.land/std/fs/mod.ts";
|
import { copy, copySync } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
copy("./foo", "./bar"); // returns a promise
|
copy("./foo", "./bar"); // returns a promise
|
||||||
copySync("./foo", "./bar"); // void
|
copySync("./foo", "./bar"); // void
|
||||||
|
@ -123,7 +135,7 @@ copySync("./foo", "./existingFolder", { overwrite: true });
|
||||||
Iterate all files in a directory recursively.
|
Iterate all files in a directory recursively.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { walk, walkSync } from "https://deno.land/std/fs/mod.ts";
|
import { walk, walkSync } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
for (const entry of walkSync(".")) {
|
for (const entry of walkSync(".")) {
|
||||||
console.log(entry.path);
|
console.log(entry.path);
|
||||||
|
@ -145,7 +157,7 @@ Expand the glob string from the specified `root` directory and yield each result
|
||||||
as a `WalkEntry` object.
|
as a `WalkEntry` object.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { expandGlob } from "https://deno.land/std/fs/mod.ts";
|
import { expandGlob } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
for await (const file of expandGlob("**/*.ts")) {
|
for await (const file of expandGlob("**/*.ts")) {
|
||||||
console.log(file);
|
console.log(file);
|
||||||
|
@ -157,7 +169,7 @@ for await (const file of expandGlob("**/*.ts")) {
|
||||||
Synchronous version of `expandGlob()`.
|
Synchronous version of `expandGlob()`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { expandGlobSync } from "https://deno.land/std/fs/mod.ts";
|
import { expandGlobSync } from "https://deno.land/std@$STD_VERSION/fs/mod.ts";
|
||||||
|
|
||||||
for (const file of expandGlobSync("**/*.ts")) {
|
for (const file of expandGlobSync("**/*.ts")) {
|
||||||
console.log(file);
|
console.log(file);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
You can create a new Hasher instance by calling `createHash` defined in mod.ts.
|
You can create a new Hasher instance by calling `createHash` defined in mod.ts.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createHash } from "https://deno.land/std/hash/mod.ts";
|
import { createHash } from "https://deno.land/std@$STD_VERSION/hash/mod.ts";
|
||||||
|
|
||||||
const hash = createHash("md5");
|
const hash = createHash("md5");
|
||||||
// ...
|
// ...
|
||||||
|
@ -19,7 +19,7 @@ You can use `update` method to feed data into your hash instance. Call `digest`
|
||||||
method to retrive final hash value in ArrayBuffer.
|
method to retrive final hash value in ArrayBuffer.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createHash } from "https://deno.land/std/hash/mod.ts";
|
import { createHash } from "https://deno.land/std@$STD_VERSION/hash/mod.ts";
|
||||||
|
|
||||||
const hash = createHash("md5");
|
const hash = createHash("md5");
|
||||||
hash.update("Your data here");
|
hash.update("Your data here");
|
||||||
|
@ -30,7 +30,7 @@ Please note that `digest` invalidates the hash instance's internal state.
|
||||||
Calling `digest` more than once will throw an Error.
|
Calling `digest` more than once will throw an Error.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createHash } from "https://deno.land/std/hash/mod.ts";
|
import { createHash } from "https://deno.land/std@$STD_VERSION/hash/mod.ts";
|
||||||
|
|
||||||
const hash = createHash("md5");
|
const hash = createHash("md5");
|
||||||
hash.update("Your data here");
|
hash.update("Your data here");
|
||||||
|
@ -44,7 +44,7 @@ format.
|
||||||
Supported formats are `hex` and `base64` and default format is `hex`.
|
Supported formats are `hex` and `base64` and default format is `hex`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createHash } from "https://deno.land/std/hash/mod.ts";
|
import { createHash } from "https://deno.land/std@$STD_VERSION/hash/mod.ts";
|
||||||
|
|
||||||
const hash = createHash("md5");
|
const hash = createHash("md5");
|
||||||
hash.update("Your data here");
|
hash.update("Your data here");
|
||||||
|
@ -52,7 +52,7 @@ const hashInHex = hash.toString(); // returns 5fe084ee423ff7e0c7709e9437cee89d
|
||||||
```
|
```
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createHash } from "https://deno.land/std/hash/mod.ts";
|
import { createHash } from "https://deno.land/std@$STD_VERSION/hash/mod.ts";
|
||||||
|
|
||||||
const hash = createHash("md5");
|
const hash = createHash("md5");
|
||||||
hash.update("Your data here");
|
hash.update("Your data here");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# http
|
# http
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { serve } from "https://deno.land/std/http/server.ts";
|
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||||
const server = serve({ port: 8000 });
|
const server = serve({ port: 8000 });
|
||||||
console.log("http://localhost:8000/");
|
console.log("http://localhost:8000/");
|
||||||
for await (const req of server) {
|
for await (const req of server) {
|
||||||
|
@ -23,8 +23,8 @@ deno run --allow-net --allow-read https://deno.land/std/http/file_server.ts
|
||||||
Helper to manipulate `Cookie` through `ServerRequest` and `Response`.
|
Helper to manipulate `Cookie` through `ServerRequest` and `Response`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { ServerRequest } from "https://deno.land/std/http/server.ts";
|
import { ServerRequest } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||||
import { getCookies } from "https://deno.land/std/http/cookie.ts";
|
import { getCookies } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
||||||
|
|
||||||
let request = new ServerRequest();
|
let request = new ServerRequest();
|
||||||
request.headers = new Headers();
|
request.headers = new Headers();
|
||||||
|
@ -38,8 +38,11 @@ console.log("cookies:", cookies);
|
||||||
To set a `Cookie` you can add `CookieOptions` to properly set your `Cookie`:
|
To set a `Cookie` you can add `CookieOptions` to properly set your `Cookie`:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Response } from "https://deno.land/std/http/server.ts";
|
import { Response } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||||
import { Cookie, setCookie } from "https://deno.land/std/http/cookie.ts";
|
import {
|
||||||
|
Cookie,
|
||||||
|
setCookie,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
||||||
|
|
||||||
let response: Response = {};
|
let response: Response = {};
|
||||||
const cookie: Cookie = { name: "Space", value: "Cat" };
|
const cookie: Cookie = { name: "Space", value: "Cat" };
|
||||||
|
@ -54,8 +57,8 @@ Deleting a `Cookie` will set its expiration date before now. Forcing the browser
|
||||||
to delete it.
|
to delete it.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Response } from "https://deno.land/std/http/server.ts";
|
import { Response } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||||
import { deleteCookie } from "https://deno.land/std/http/cookie.ts";
|
import { deleteCookie } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
||||||
|
|
||||||
let response: Response = {};
|
let response: Response = {};
|
||||||
deleteCookie(response, "deno");
|
deleteCookie(response, "deno");
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
Read reader[like file], line by line:
|
Read reader[like file], line by line:
|
||||||
|
|
||||||
```ts title="readLines"
|
```ts title="readLines"
|
||||||
import { readLines } from "https://deno.land/std/io/mod.ts";
|
import { readLines } from "https://deno.land/std@$STD_VERSION/io/mod.ts";
|
||||||
import * as path from "https://deno.land/std/path/mod.ts";
|
import * as path from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
||||||
|
|
||||||
const filename = path.join(Deno.cwd(), "std/io/README.md");
|
const filename = path.join(Deno.cwd(), "std/io/README.md");
|
||||||
let fileReader = await Deno.open(filename);
|
let fileReader = await Deno.open(filename);
|
||||||
|
@ -28,7 +28,7 @@ for await (let line of readLines(fileReader)) {
|
||||||
## readLines
|
## readLines
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import * as path from "https://deno.land/std/path/mod.ts";
|
import * as path from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
||||||
|
|
||||||
## Rest of the file
|
## Rest of the file
|
||||||
````
|
````
|
||||||
|
@ -38,8 +38,8 @@ import * as path from "https://deno.land/std/path/mod.ts";
|
||||||
Read reader`[like file]` chunk by chunk, splitting based on delimiter.
|
Read reader`[like file]` chunk by chunk, splitting based on delimiter.
|
||||||
|
|
||||||
```ts title="readStringDelim"
|
```ts title="readStringDelim"
|
||||||
import { readStringDelim } from "https://deno.land/std/io/mod.ts";
|
import { readStringDelim } from "https://deno.land/std@$STD_VERSION/io/mod.ts";
|
||||||
import * as path from "https://deno.land/std/path/mod.ts";
|
import * as path from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
||||||
|
|
||||||
const filename = path.join(Deno.cwd(), "std/io/README.md");
|
const filename = path.join(Deno.cwd(), "std/io/README.md");
|
||||||
let fileReader = await Deno.open(filename);
|
let fileReader = await Deno.open(filename);
|
||||||
|
@ -57,7 +57,7 @@ for await (let line of readStringDelim(fileReader, "\n")) {
|
||||||
## readLines
|
## readLines
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import * as path from "https://deno.land/std/path/mod.ts";
|
import * as path from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
||||||
|
|
||||||
## Rest of the file
|
## Rest of the file
|
||||||
````
|
````
|
||||||
|
@ -69,7 +69,7 @@ import * as path from "https://deno.land/std/path/mod.ts";
|
||||||
Create a `Reader` object for `string`.
|
Create a `Reader` object for `string`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { StringReader } from "https://deno.land/std/io/mod.ts";
|
import { StringReader } from "https://deno.land/std@$STD_VERSION/io/mod.ts";
|
||||||
|
|
||||||
const data = new Uint8Array(6);
|
const data = new Uint8Array(6);
|
||||||
const r = new StringReader("abcdef");
|
const r = new StringReader("abcdef");
|
||||||
|
@ -104,7 +104,7 @@ import {
|
||||||
copyN,
|
copyN,
|
||||||
StringReader,
|
StringReader,
|
||||||
StringWriter,
|
StringWriter,
|
||||||
} from "https://deno.land/std/io/mod.ts";
|
} from "https://deno.land/std@$STD_VERSION/io/mod.ts";
|
||||||
|
|
||||||
const w = new StringWriter("base");
|
const w = new StringWriter("base");
|
||||||
const r = new StringReader("0123456789");
|
const r = new StringReader("0123456789");
|
||||||
|
@ -131,7 +131,7 @@ base0123456789
|
||||||
Creates a `Reader` from a `ReadableStreamDefaultReader`.
|
Creates a `Reader` from a `ReadableStreamDefaultReader`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { fromStreamReader } from "https://deno.land/std/io/mod.ts";
|
import { fromStreamReader } from "https://deno.land/std@$STD_VERSION/io/mod.ts";
|
||||||
const res = await fetch("https://deno.land");
|
const res = await fetch("https://deno.land");
|
||||||
const file = await Deno.open("./deno.land.html", { create: true, write: true });
|
const file = await Deno.open("./deno.land.html", { create: true, write: true });
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ file.close();
|
||||||
Creates a `Writer` from a `WritableStreamDefaultWriter`.
|
Creates a `Writer` from a `WritableStreamDefaultWriter`.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { fromStreamWriter } from "https://deno.land/std/io/mod.ts";
|
import { fromStreamWriter } from "https://deno.land/std@$STD_VERSION/io/mod.ts";
|
||||||
const file = await Deno.open("./deno.land.html", { read: true });
|
const file = await Deno.open("./deno.land.html", { read: true });
|
||||||
|
|
||||||
const writableStream = new WritableStream({
|
const writableStream = new WritableStream({
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import * as log from "https://deno.land/std/log/mod.ts";
|
import * as log from "https://deno.land/std@$STD_VERSION/log/mod.ts";
|
||||||
|
|
||||||
// Simple default logger out of the box. You can customize it
|
// Simple default logger out of the box. You can customize it
|
||||||
// by overriding logger and handler named "default", or providing
|
// by overriding logger and handler named "default", or providing
|
||||||
|
|
|
@ -72,7 +72,7 @@ they are stable:
|
||||||
modules. It also sets supported globals.
|
modules. It also sets supported globals.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { createRequire } from "https://deno.land/std/node/module.ts";
|
import { createRequire } from "https://deno.land/std@$STD_VERSION/node/module.ts";
|
||||||
|
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
// Loads native module polyfill.
|
// Loads native module polyfill.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import * as path from "https://deno.land/std/path/mod.ts";
|
import * as path from "https://deno.land/std@$STD_VERSION/path/mod.ts";
|
||||||
```
|
```
|
||||||
|
|
||||||
### globToRegExp
|
### globToRegExp
|
||||||
|
@ -12,7 +12,7 @@ Generate a regex based on glob pattern and options This was meant to be using
|
||||||
the the `fs.walk` function but can be used anywhere else.
|
the the `fs.walk` function but can be used anywhere else.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { globToRegExp } from "https://deno.land/std/path/glob.ts";
|
import { globToRegExp } from "https://deno.land/std@$STD_VERSION/path/glob.ts";
|
||||||
|
|
||||||
globToRegExp("foo/**/*.json", {
|
globToRegExp("foo/**/*.json", {
|
||||||
flags: "g",
|
flags: "g",
|
||||||
|
|
|
@ -40,7 +40,7 @@ pretty-printed diff of failing assertion.
|
||||||
Basic usage:
|
Basic usage:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
|
import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
||||||
|
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "testing example",
|
name: "testing example",
|
||||||
|
@ -156,7 +156,10 @@ After that simply calling `runBenchmarks()` will benchmark all registered
|
||||||
benchmarks and log the results in the commandline.
|
benchmarks and log the results in the commandline.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { bench, runBenchmarks } from "https://deno.land/std/testing/bench.ts";
|
import {
|
||||||
|
bench,
|
||||||
|
runBenchmarks,
|
||||||
|
} from "https://deno.land/std@$STD_VERSION/testing/bench.ts";
|
||||||
|
|
||||||
bench(function forIncrementX1e9(b): void {
|
bench(function forIncrementX1e9(b): void {
|
||||||
b.start();
|
b.start();
|
||||||
|
|
|
@ -5,7 +5,7 @@ Support for version 1, 4, and 5 UUIDs.
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { v4 } from "https://deno.land/std/uuid/mod.ts";
|
import { v4 } from "https://deno.land/std@$STD_VERSION/uuid/mod.ts";
|
||||||
|
|
||||||
// Generate a v4 uuid.
|
// Generate a v4 uuid.
|
||||||
const myUUID = v4.generate();
|
const myUUID = v4.generate();
|
||||||
|
|
|
@ -55,7 +55,7 @@ This module provides an implementation of the WebAssembly System Interface.
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import Context from "https://deno.land/std/wasi/snapshot_preview1.ts";
|
import Context from "https://deno.land/std@$STD_VERSION/wasi/snapshot_preview1.ts";
|
||||||
|
|
||||||
const context = new Context({
|
const context = new Context({
|
||||||
args: Deno.args,
|
args: Deno.args,
|
||||||
|
|
|
@ -8,13 +8,13 @@ WebSockets, use the
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||||
import { serve } from "https://deno.land/std/http/server.ts";
|
import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||||
import {
|
import {
|
||||||
acceptWebSocket,
|
acceptWebSocket,
|
||||||
isWebSocketCloseEvent,
|
isWebSocketCloseEvent,
|
||||||
isWebSocketPingEvent,
|
isWebSocketPingEvent,
|
||||||
WebSocket,
|
WebSocket,
|
||||||
} from "https://deno.land/std/ws/mod.ts";
|
} from "https://deno.land/std@$STD_VERSION/ws/mod.ts";
|
||||||
|
|
||||||
async function handleWs(sock: WebSocket) {
|
async function handleWs(sock: WebSocket) {
|
||||||
console.log("socket connected!");
|
console.log("socket connected!");
|
||||||
|
|
Loading…
Reference in a new issue