UNPKG

1.2 kBTypeScriptView Raw
1import { InjectionToken, FactoryProvider } from 'injection-js';
2import { Transform } from './transform';
3/**
4 * A specialized `FactoryProvider` for a `Transform`.
5 */
6export interface TransformProvider extends FactoryProvider {
7 /**
8 * An injection token for the `Transform` provided by this provider.
9 */
10 provide: InjectionToken<Transform>;
11 /**
12 * A function to invoke to create the `Transform`.
13 *
14 * The factory function is invoked with resolved values of tokens in the `deps` field.
15 */
16 useFactory: (...args: any[]) => Transform;
17}
18/**
19 * Creates a provider for a `Transform`.
20 *
21 * #### Example
22 *
23 * Creating a transformation `fooBar` that is composed of `foo` and `bar` transforms:
24 *
25 * ```ts
26 * const FOO_BAR_TOKEN = new InjectionToken<Transform>('fooBar');
27 *
28 * const FOO_BAR_TRANSFORM = provideTransform({
29 * provide: FOO_BAR_TOKEN,
30 * useFactory: (foo, bar) => {
31 * return pipe(foo, bar);
32 * },
33 * deps: [ FOO_TOKEN, BAR_TOKEN ]
34 * });
35 * ```
36 *
37 * @param module The provider for the transform
38 * @return A (normalized) provider for the transform
39 */
40export declare function provideTransform(module: TransformProvider): TransformProvider;