mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
docs: version all imports in README (denoland/deno#7442)
Use $STD_VERSION in README files to automatically display proper version.
This commit is contained in:
parent
fe5fcfc0d4
commit
8567b960f8
@ -3,7 +3,7 @@
|
||||
## Tar
|
||||
|
||||
```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 content = new TextEncoder().encode("Deno.land");
|
||||
@ -27,9 +27,9 @@ writer.close();
|
||||
## Untar
|
||||
|
||||
```ts
|
||||
import { Untar } from "https://deno.land/std/archive/tar.ts";
|
||||
import { ensureFile } from "https://deno.land/std/fs/ensure_file.ts";
|
||||
import { ensureDir } from "https://deno.land/std/fs/ensure_dir.ts";
|
||||
import { Untar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
|
||||
import { ensureFile } from "https://deno.land/std@$STD_VERSION/fs/ensure_file.ts";
|
||||
import { ensureDir } from "https://deno.land/std@$STD_VERSION/fs/ensure_dir.ts";
|
||||
|
||||
const reader = await Deno.open("./out.tar", { read: true });
|
||||
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.
|
||||
|
||||
```typescript
|
||||
import { findIndex } from "https://deno.land/std/bytes/mod.ts";
|
||||
import { findIndex } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||
|
||||
findIndex(
|
||||
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.
|
||||
|
||||
```typescript
|
||||
import { findLastIndex } from "https://deno.land/std/bytes/mod.ts";
|
||||
import { findLastIndex } from "https://deno.land/std@$STD_VERSION/bytes/mod.ts";
|
||||
|
||||
findLastIndex(
|
||||
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.
|
||||
|
||||
```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, 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.
|
||||
|
||||
```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([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.
|
||||
|
||||
```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 ]
|
||||
```
|
||||
@ -73,7 +73,7 @@ repeat(new Uint8Array([1]), 3); // returns Uint8Array(3) [ 1, 1, 1 ]
|
||||
Concatenate two binary arrays and return new one.
|
||||
|
||||
```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 ]
|
||||
```
|
||||
@ -83,7 +83,7 @@ concat(new Uint8Array([1, 2]), new Uint8Array([3, 4])); // returns Uint8Array(4)
|
||||
Copy bytes from one binary array to another.
|
||||
|
||||
```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 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`.
|
||||
|
||||
```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("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`.
|
||||
|
||||
```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), "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.
|
||||
|
||||
```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
|
||||
```
|
||||
@ -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).
|
||||
|
||||
```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
|
||||
```
|
||||
|
@ -82,7 +82,7 @@ function is as follows:
|
||||
### Usage
|
||||
|
||||
```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";
|
||||
|
||||
console.log(
|
||||
@ -187,7 +187,10 @@ will output:
|
||||
### Basic usage
|
||||
|
||||
```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 = {
|
||||
bin: [
|
||||
{ name: "deno", path: "cli/main.rs" },
|
||||
@ -236,7 +239,10 @@ Heavily inspired from [js-yaml].
|
||||
string.
|
||||
|
||||
```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(`
|
||||
foo: bar
|
||||
@ -260,7 +266,7 @@ If your YAML contains multiple documents in it, you can use `parseAll` for
|
||||
handling it.
|
||||
|
||||
```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(`
|
||||
---
|
||||
@ -312,7 +318,10 @@ for Deno.
|
||||
decodes the given RFC4648 base32 representation to a `Uint8Array`.
|
||||
|
||||
```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=";
|
||||
|
||||
@ -334,7 +343,10 @@ Ascii85/base85 encoder and decoder with support for multiple standards.
|
||||
decodes the given ascii85 representation to a `Uint8Array`.
|
||||
|
||||
```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";
|
||||
|
||||
@ -363,7 +375,10 @@ supported by other encodings.)
|
||||
encoding examples:
|
||||
|
||||
```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]);
|
||||
console.log(encode(binaryData));
|
||||
// => LpTqp
|
||||
|
@ -5,7 +5,7 @@ Command line arguments parser for Deno based on minimist.
|
||||
# Example
|
||||
|
||||
```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));
|
||||
```
|
||||
@ -56,7 +56,7 @@ options can be:
|
||||
example:
|
||||
```ts
|
||||
// $ 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 }));
|
||||
// output: { _: [ "a", "arg1" ] }
|
||||
console.dir(parse(Deno.args, { "--": true }));
|
||||
|
34
fs/README.md
34
fs/README.md
@ -14,7 +14,10 @@ is not empty. If the directory does not exist, it is created. The directory
|
||||
itself is not deleted.
|
||||
|
||||
```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
|
||||
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`.
|
||||
|
||||
```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
|
||||
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**.
|
||||
|
||||
```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
|
||||
ensureFileSync("./folder/targetFile.dat"); // void
|
||||
@ -54,7 +63,7 @@ created.
|
||||
import {
|
||||
ensureSymlink,
|
||||
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
|
||||
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.
|
||||
|
||||
```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 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.
|
||||
|
||||
```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>
|
||||
existsSync("./foo"); // returns boolean
|
||||
@ -97,7 +109,7 @@ existsSync("./foo"); // returns boolean
|
||||
Moves a file or directory. Overwrites it if option provided.
|
||||
|
||||
```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
|
||||
moveSync("./foo", "./bar"); // void
|
||||
@ -110,7 +122,7 @@ moveSync("./foo", "./existingFolder", { overwrite: true });
|
||||
copy a file or directory. Overwrites it if option provided.
|
||||
|
||||
```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
|
||||
copySync("./foo", "./bar"); // void
|
||||
@ -123,7 +135,7 @@ copySync("./foo", "./existingFolder", { overwrite: true });
|
||||
Iterate all files in a directory recursively.
|
||||
|
||||
```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(".")) {
|
||||
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.
|
||||
|
||||
```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")) {
|
||||
console.log(file);
|
||||
@ -157,7 +169,7 @@ for await (const file of expandGlob("**/*.ts")) {
|
||||
Synchronous version of `expandGlob()`.
|
||||
|
||||
```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")) {
|
||||
console.log(file);
|
||||
|
@ -7,7 +7,7 @@
|
||||
You can create a new Hasher instance by calling `createHash` defined in mod.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");
|
||||
// ...
|
||||
@ -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.
|
||||
|
||||
```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");
|
||||
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.
|
||||
|
||||
```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");
|
||||
hash.update("Your data here");
|
||||
@ -44,7 +44,7 @@ format.
|
||||
Supported formats are `hex` and `base64` and default format is `hex`.
|
||||
|
||||
```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");
|
||||
hash.update("Your data here");
|
||||
@ -52,7 +52,7 @@ const hashInHex = hash.toString(); // returns 5fe084ee423ff7e0c7709e9437cee89d
|
||||
```
|
||||
|
||||
```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");
|
||||
hash.update("Your data here");
|
||||
|
@ -1,7 +1,7 @@
|
||||
# http
|
||||
|
||||
```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 });
|
||||
console.log("http://localhost:8000/");
|
||||
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`.
|
||||
|
||||
```ts
|
||||
import { ServerRequest } from "https://deno.land/std/http/server.ts";
|
||||
import { getCookies } from "https://deno.land/std/http/cookie.ts";
|
||||
import { ServerRequest } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||
import { getCookies } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
||||
|
||||
let request = new ServerRequest();
|
||||
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`:
|
||||
|
||||
```ts
|
||||
import { Response } from "https://deno.land/std/http/server.ts";
|
||||
import { Cookie, setCookie } from "https://deno.land/std/http/cookie.ts";
|
||||
import { Response } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||
import {
|
||||
Cookie,
|
||||
setCookie,
|
||||
} from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
||||
|
||||
let response: Response = {};
|
||||
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.
|
||||
|
||||
```ts
|
||||
import { Response } from "https://deno.land/std/http/server.ts";
|
||||
import { deleteCookie } from "https://deno.land/std/http/cookie.ts";
|
||||
import { Response } from "https://deno.land/std@$STD_VERSION/http/server.ts";
|
||||
import { deleteCookie } from "https://deno.land/std@$STD_VERSION/http/cookie.ts";
|
||||
|
||||
let response: Response = {};
|
||||
deleteCookie(response, "deno");
|
||||
|
20
io/README.md
20
io/README.md
@ -9,8 +9,8 @@
|
||||
Read reader[like file], line by line:
|
||||
|
||||
```ts title="readLines"
|
||||
import { readLines } from "https://deno.land/std/io/mod.ts";
|
||||
import * as path from "https://deno.land/std/path/mod.ts";
|
||||
import { readLines } from "https://deno.land/std@$STD_VERSION/io/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");
|
||||
let fileReader = await Deno.open(filename);
|
||||
@ -28,7 +28,7 @@ for await (let line of readLines(fileReader)) {
|
||||
## readLines
|
||||
|
||||
```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
|
||||
````
|
||||
@ -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.
|
||||
|
||||
```ts title="readStringDelim"
|
||||
import { readStringDelim } from "https://deno.land/std/io/mod.ts";
|
||||
import * as path from "https://deno.land/std/path/mod.ts";
|
||||
import { readStringDelim } from "https://deno.land/std@$STD_VERSION/io/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");
|
||||
let fileReader = await Deno.open(filename);
|
||||
@ -57,7 +57,7 @@ for await (let line of readStringDelim(fileReader, "\n")) {
|
||||
## readLines
|
||||
|
||||
```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
|
||||
````
|
||||
@ -69,7 +69,7 @@ import * as path from "https://deno.land/std/path/mod.ts";
|
||||
Create a `Reader` object for `string`.
|
||||
|
||||
```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 r = new StringReader("abcdef");
|
||||
@ -104,7 +104,7 @@ import {
|
||||
copyN,
|
||||
StringReader,
|
||||
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 r = new StringReader("0123456789");
|
||||
@ -131,7 +131,7 @@ base0123456789
|
||||
Creates a `Reader` from a `ReadableStreamDefaultReader`.
|
||||
|
||||
```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 file = await Deno.open("./deno.land.html", { create: true, write: true });
|
||||
|
||||
@ -145,7 +145,7 @@ file.close();
|
||||
Creates a `Writer` from a `WritableStreamDefaultWriter`.
|
||||
|
||||
```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 writableStream = new WritableStream({
|
||||
|
@ -3,7 +3,7 @@
|
||||
## Usage
|
||||
|
||||
```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
|
||||
// by overriding logger and handler named "default", or providing
|
||||
|
@ -72,7 +72,7 @@ they are stable:
|
||||
modules. It also sets supported globals.
|
||||
|
||||
```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);
|
||||
// Loads native module polyfill.
|
||||
|
@ -3,7 +3,7 @@
|
||||
Usage:
|
||||
|
||||
```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
|
||||
@ -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.
|
||||
|
||||
```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", {
|
||||
flags: "g",
|
||||
|
@ -40,7 +40,7 @@ pretty-printed diff of failing assertion.
|
||||
Basic usage:
|
||||
|
||||
```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({
|
||||
name: "testing example",
|
||||
@ -156,7 +156,10 @@ After that simply calling `runBenchmarks()` will benchmark all registered
|
||||
benchmarks and log the results in the commandline.
|
||||
|
||||
```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 {
|
||||
b.start();
|
||||
|
@ -5,7 +5,7 @@ Support for version 1, 4, and 5 UUIDs.
|
||||
## Usage
|
||||
|
||||
```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.
|
||||
const myUUID = v4.generate();
|
||||
|
@ -55,7 +55,7 @@ This module provides an implementation of the WebAssembly System Interface.
|
||||
## Usage
|
||||
|
||||
```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({
|
||||
args: Deno.args,
|
||||
|
@ -8,13 +8,13 @@ WebSockets, use the
|
||||
|
||||
```ts
|
||||
// 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 {
|
||||
acceptWebSocket,
|
||||
isWebSocketCloseEvent,
|
||||
isWebSocketPingEvent,
|
||||
WebSocket,
|
||||
} from "https://deno.land/std/ws/mod.ts";
|
||||
} from "https://deno.land/std@$STD_VERSION/ws/mod.ts";
|
||||
|
||||
async function handleWs(sock: WebSocket) {
|
||||
console.log("socket connected!");
|
||||
|
Loading…
Reference in New Issue
Block a user