import * as JsArray from "./JsArray.js"; import * as JsFunction from "./JsFunction.js"; export { Injector as t }; declare const inject: unique symbol; /** * Represents a function that has been marked for dependency injection. */ export type InjectableFunction = Func & { [inject]: Tags; }; export type Tag = { _tag: "Injector.Tag"; }; /** * Represents an injectable dependency. The tag can be used to add or retrieve * a dependency from the container. * * @example * * type Session = { clientId: string; } * const Session = Injector.Tag(); */ export declare const Tag: () => Tag; /** * Given a list of tags, produce a list of values held by those tags. */ export type Values = Tags extends readonly [ Tag, ...infer Tail ] ? Values : Acc; /** * An object encapsulating a dependency container. Values may be added or read * from the container using tags. */ declare class Injector { #private; /** * Adds a value to the container using a tag. * * @example * * type Session = { clientId: string; } * const Session = Injector.Tag(); * const injector = Injector.empty(); * injector.add(Session, { clientId: "Client:1" }) */ add(tag: Tag, value: Value): Injector; /** * Gets a value from the container using a tag. * * @example * * injector.get(Session); // { clientId: "Client:1" } */ get(tag: Tag): unknown; } /** * Creates a new empty `Injector`. */ export declare const empty: () => Injector; /** * Returns a list of tags from a marked function. If the function is not marked * the list will be empty. */ export declare function getTags(func: JsFunction.t): Tag[]; /** * Returns a new function that is marked for dependency injection. The call * signature of the new function will omit any injected dependencies. * * @example * * type Session = { clientId: string; } * const Session = Injector.Tag(); * const wrappedFunc = Injector.provide([Session], (session: Session) => {}) */ export declare function provide[], const Args extends [...Values, ...unknown[]], const Return>(tags: Tags, func: (...args: Args) => Return): (...args: JsArray.DropFirst>) => Return; //# sourceMappingURL=Injector.d.ts.map