Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 4x 66x 66x 71x 66x 4x | import type { DefaultRegistry, Methods, Registry } from "../registry";
import type { shim } from "./mixin";
export type Base<T> = T extends { [shim]: { value: infer U } }
? { readonly value: U }
: {
readonly value: T;
};
export type Fluent<
T,
Reg extends Registry = DefaultRegistry,
> = Base<T> & Methods<T, Reg>;
export function makeFluent<const Reg extends Registry>(
registry: Reg,
) {
const fluent = <const T>(value: T) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const f = { value } as never as Fluent<T, Reg>;
for (const mixin of registry) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
mixin.fn(value, f, fluent as (value: unknown) => never);
}
return f;
};
return fluent;
}
|