Skip to main content
Deno 2 is finally here 🎉️
Learn more

Inject values from a parent scope into child scopes in async context.

node:

npm i async-context

deno:

import { context } from "https://deno.land/x/context_inject/src/index.ts";

example

const { inject, access } = context((): string => "nothing injected");
const withString = inject(() => "injected");

const f = () => Promise.resolve(access());

await withString(f)(); // "injected"

await f(); // "nothing injected"