Skip to content

Commit

Permalink
dependencies and fixes for near constant API breaks from the Deno team
Browse files Browse the repository at this point in the history
  • Loading branch information
j50n committed Jan 15, 2024
1 parent bf2df78 commit bd9dc02
Show file tree
Hide file tree
Showing 31 changed files with 77 additions and 44 deletions.
2 changes: 1 addition & 1 deletion dev/deps.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * as path from "../tests/deps/path.ts";
export * as colors from "https://deno.land/std@0.208.0/fmt/colors.ts";
export * as colors from "https://deno.land/std@0.212.0/fmt/colors.ts";
28 changes: 28 additions & 0 deletions dev/io.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { sleep } from "../mod.ts";

await Promise.all([
(async () => {
const writer = Deno.stdout.writable.getWriter();
console.error("got 1");
try {
for (let i = 0; i < 10; i += 2) {
await writer.write(new TextEncoder().encode(`${i}\n`));
await sleep(1000);
}
} finally {
writer.releaseLock();
}
})(),
(async () => {
const writer = Deno.stdout.writable.getWriter();
console.error("got 2");
try {
for (let i = 1; i < 10; i += 2) {
await writer.write(new TextEncoder().encode(`${i}\n`));
await sleep(1000);
}
} finally {
writer.releaseLock();
}
})(),
]);
2 changes: 1 addition & 1 deletion dev/lines/consume.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { blue } from "https://deno.land/std@0.208.0/fmt/colors.ts";
import { blue } from "https://deno.land/std@0.212.0/fmt/colors.ts";
import { run } from "../../mod.ts";

const produce = import.meta.resolve("./produce.ts");
Expand Down
4 changes: 2 additions & 2 deletions dev/read.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { enumerate } from "https://deno.land/x/[email protected]/mod.ts";

for await (const line of enumerate(Deno.stdin.readable).lines){
console.log(line);
for await (const line of enumerate(Deno.stdin.readable).lines) {
console.log(line);
}

const warandpeace = await Deno.open(
Expand Down
4 changes: 2 additions & 2 deletions legacy/deps-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "https://deno.land/std@0.208.0/testing/asserts.ts";
export * from "https://deno.land/std@0.212.0/testing/asserts.ts";
export * from "https://deno.land/x/[email protected]/mod.ts";
export * from "https://deno.land/std@0.208.0/fmt/colors.ts";
export * from "https://deno.land/std@0.212.0/fmt/colors.ts";
4 changes: 2 additions & 2 deletions legacy/deps.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "https://deno.land/std@0.208.0/async/mod.ts";
export * from "https://deno.land/std@0.208.0/io/mod.ts";
export * from "https://deno.land/std@0.212.0/async/mod.ts";
export * from "https://deno.land/std@0.212.0/io/mod.ts";
2 changes: 1 addition & 1 deletion legacy/examples/pushiterable/example-of-pushiterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Answer, Question } from "./common-json-defs.ts";
import * as proc from "../../mod.ts";
import { WritableIterable } from "../../../mod1.ts";
import { asynciter } from "https://deno.land/x/[email protected]/mod.ts";
import { blue, red } from "https://deno.land/std@0.208.0/fmt/colors.ts";
import { blue, red } from "https://deno.land/std@0.212.0/fmt/colors.ts";

/**
* This demonstrates sending objects to and receiving objects from a child process
Expand Down
11 changes: 5 additions & 6 deletions legacy/runners/closers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Deferred, deferred } from "../deps.ts";
import { GroupImpl } from "./proc-group-impl.ts";
import { RunOptions } from "./proc-group.ts";

Expand All @@ -8,15 +7,15 @@ import { RunOptions } from "./proc-group.ts";
export class MultiCloseReader implements Deno.Reader, Deno.Closer {
private closed = false;

private _done: Deferred<void> = deferred();
private _done = Promise.withResolvers();

constructor(private readonly reader: Deno.Reader & Deno.Closer) {
}

async read(p: Uint8Array): Promise<number | null> {
const data = await this.reader.read(p);
if (data === null) {
this._done.resolve();
this._done.resolve(undefined);
}
return data;
}
Expand All @@ -27,13 +26,13 @@ export class MultiCloseReader implements Deno.Reader, Deno.Closer {
this.closed = true;
this.reader.close();
} finally {
this._done.resolve();
this._done.resolve(undefined);
}
}
}

get done(): Promise<void> {
return this._done;
get done(): Promise<unknown> {
return this._done.promise;
}
}

Expand Down
2 changes: 1 addition & 1 deletion legacy/runners/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isWindows } from "https://deno.land/std@0.208.0/path/_os.ts";
import { isWindows } from "https://deno.land/std@0.212.0/path/_os.ts";

export const LINESEP: string = (() => {
if (isWindows) {
Expand Down
2 changes: 1 addition & 1 deletion legacy/runners/handlers/bytes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.208.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.212.0/testing/asserts.ts";
import * as proc from "../../mod.ts";

Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion legacy/runners/utility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BufReader, BufWriter } from "../deps.ts";
import * as path from "https://deno.land/std@0.208.0/path/mod.ts";
import * as path from "https://deno.land/std@0.212.0/path/mod.ts";

export const DEFAULT_BUFFER_SIZE = 4096;

Expand Down
2 changes: 1 addition & 1 deletion legacy/tests/line-split.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.208.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.212.0/testing/asserts.ts";
import * as proc from "../mod.ts";

Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion legacy/tests/piped.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/std@0.208.0/testing/asserts.ts";
import { assertEquals } from "https://deno.land/std@0.212.0/testing/asserts.ts";
import * as proc from "../mod.ts";

Deno.test({
Expand Down
2 changes: 1 addition & 1 deletion site/scripts/deps/path.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/path/posix.ts";
export * from "https://deno.land/std@0.212.0/path/posix/mod.ts";
10 changes: 7 additions & 3 deletions site/src/io/read.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Reading Data

[`enumerate`]() works with any iterable, including a `ReadableStream` (which is an `AsyncIterable`).
[`enumerate`]() works with any iterable, including a `ReadableStream` (which is
an `AsyncIterable`).

## Reading from `stdin`

Deno provides `Deno.stdin.readable` which gives you a `stdin` as a `ReadableStream<Uint8Array>`. We can
wrap this with `enumerate(...)` to convert to lines of text (strings).
Deno provides `Deno.stdin.readable` which gives you a `stdin` as a
`ReadableStream<Uint8Array>`. We can wrap this with `enumerate(...)` to convert
to lines of text (strings).

Text of `example.ts`:

Expand All @@ -24,3 +26,5 @@ zcat warandpeace.txt.gz | deno run example.ts
```

This operation will consume `stdin` and close it.

## Reading from File
2 changes: 1 addition & 1 deletion src/deps/colors.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/fmt/colors.ts";
export * from "https://deno.land/std@0.212.0/fmt/colors.ts";
2 changes: 1 addition & 1 deletion src/deps/path.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/path/mod.ts";
export * from "https://deno.land/std@0.212.0/path/mod.ts";
2 changes: 1 addition & 1 deletion src/deps/retry.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/async/retry.ts";
export * from "https://deno.land/std@0.212.0/async/retry.ts";
2 changes: 1 addition & 1 deletion src/deps/streams.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/streams/mod.ts";
export * from "https://deno.land/std@0.212.0/streams/mod.ts";
2 changes: 1 addition & 1 deletion src/deps/tee.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/async/tee.ts";
export * from "https://deno.land/std@0.212.0/async/tee.ts";
2 changes: 1 addition & 1 deletion tests/deps/asserts.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/assert/mod.ts";
export * from "https://deno.land/std@0.212.0/assert/mod.ts";
2 changes: 1 addition & 1 deletion tests/deps/colors.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/fmt/colors.ts";
export * from "https://deno.land/std@0.212.0/fmt/colors.ts";
2 changes: 1 addition & 1 deletion tests/deps/path.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/path/mod.ts";
export * from "https://deno.land/std@0.212.0/path/mod.ts";
2 changes: 1 addition & 1 deletion tests/deps/streams.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/streams/mod.ts";
export * from "https://deno.land/std@0.212.0/streams/mod.ts";
2 changes: 1 addition & 1 deletion tools/deps/colors.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/fmt/colors.ts";
export * from "https://deno.land/std@0.212.0/fmt/colors.ts";
2 changes: 1 addition & 1 deletion tools/deps/crypto.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/crypto/mod.ts";
export * from "https://deno.land/std@0.212.0/crypto/mod.ts";
1 change: 1 addition & 0 deletions tools/deps/encode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "https://deno.land/[email protected]/encoding/hex.ts";
2 changes: 1 addition & 1 deletion tools/deps/path.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/path/mod.ts";
export * from "https://deno.land/std@0.212.0/path/mod.ts";
2 changes: 1 addition & 1 deletion tools/deps/retry.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "https://deno.land/std@0.208.0/async/retry.ts";
export * from "https://deno.land/std@0.212.0/async/retry.ts";
13 changes: 7 additions & 6 deletions tools/mdbook-deno-script-preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import { enumerate, isString, toLines } from "./deps/proc.ts";
import { bestTypeNameOf } from "./deps/proc-hidden.ts";
import { resolve, toFileUrl } from "./deps/path.ts";
import { toHashString } from "./deps/crypto.ts";
// import { toHashString } from "./deps/crypto.ts";
import { blue, cyan, red } from "./deps/colors.ts";
import { Command } from "./deps/cliffy.ts";
import { retry } from "./deps/retry.ts";
import config from "../version.json" assert { type: "json" };
import config from "../version.json" with { type: "json" };
import { encodeHex } from "./deps/encode.ts";

interface Chapter {
Chapter: {
Expand Down Expand Up @@ -41,9 +42,9 @@ interface CacheEntry {
}

async function digestMessage(message: string) {
const data = new TextEncoder().encode(message);
const hash = await crypto.subtle.digest("SHA-1", data);
return toHashString(hash, "hex");
return encodeHex(
await crypto.subtle.digest("SHA-1", new TextEncoder().encode(message)),
);
}

if (Deno.args.length >= 2 && Deno.args[Deno.args.length - 2] === "supports") {
Expand Down Expand Up @@ -148,7 +149,7 @@ if (Deno.args.length >= 2 && Deno.args[Deno.args.length - 2] === "supports") {
const now = new Date().getTime();

const useCache = cachedContent?.hash === hash &&
now - cachedContent?.timestamp.getTime() <
now - (cachedContent?.timestamp.getTime() ?? 0) <
cacheTimeout * SECOND;

return {
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"0.21.8"}
{"version":"0.21.9"}

0 comments on commit bd9dc02

Please sign in to comment.