This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Given the following definition of sleep(), how long will this program take to | |
* run? | |
* | |
* Try it out with: | |
* | |
* ``` | |
* node how-long.js | |
* ``` | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { main } from "npm:[email protected]"; | |
import { useEventStream } from "./use-event-stream.ts"; | |
// consume the server as an interable. | |
await main(function* () { | |
let source = yield* useEventStream<number, string>("http://localhost:8000"); | |
let next = yield* source.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSignal, resource, type Stream } from "./mod.ts"; | |
/** | |
* Consume RAF's as a Stream. | |
* | |
* ## Example | |
* | |
* for (let timestamp of yield* each(requestAnimationFrames)) { | |
* // do work | |
* yield* each.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { run, type Operation } from "effection"; | |
export interface TestScope { | |
/** | |
* Call from your runner's "beforeEach" or equivalent | |
*/ | |
addSetup(op: () => Operation<void>): void; | |
/** | |
* Call from runner's `it()` or equivalent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deno-lint-ignore-file no-explicit-any | |
import { createContext, type Operation } from "./mod.ts"; | |
export interface Console { | |
// Logging | |
assert(condition?: boolean, ...data: any[]): Operation<void>; | |
clear(): Operation<void>; | |
debug(...data: any[]): Operation<void>; | |
error(...data: any[]): Operation<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
createChannel, | |
each, | |
Operation, | |
resource, | |
spawn, | |
Task, | |
} from "effection"; | |
export function useRestartable<TArgs extends unknown[]>( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { call } from "effection"; | |
function* getUser2(id: number) { | |
if (cachedUser) return cachedUser; | |
let response = yield* call(fetch(`/users/${id}`)); | |
return yield* call(response.json()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSignal, call, first, each, spawn, sleep, type Operation } from "effection"; | |
import { render } from "$revolution"; | |
export default function* TimerIsland(): Operation<void> { | |
let reset = createSignal<void>(); | |
let start = createSignal<void>(); | |
let stop = createSignal<void>(); | |
let elapsed = 0; | |
let t0 = performance.now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { describe, it } from "https://deno.land/[email protected]/testing/bdd.ts" | |
import { launch } from "https://deno.land/x/[email protected]/mod.ts"; | |
describe("browser", () => { | |
it("launches, sleeps, and closes", async () => { | |
let browser = await launch(); | |
await new Promise((resolve) => setTimeout(resolve, 2000)); | |
browser.close(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { posixNormalize } from "https://deno.land/[email protected]/path/_normalize.ts"; | |
import { selectAll } from "npm:[email protected]"; | |
import type { Element } from "hastx/jsx-runtime"; | |
/** | |
* Rebase an HTML document at a different URL. This replaces all `<a href>` and | |
* `<img src>` attributes that contain an absolute path. Any path that is | |
* relative or contains a fully qualitfied URL will be left alone. | |
* |
NewerOlder