UNPKG

@mixtape/core

Version:

Supercharged fixture library for organizing and generating test data

55 lines (54 loc) 1.51 kB
import { TypeBuilder } from './builder'; export declare const decorators: unique symbol; /** * Class for bundling builders * Bundle builders in an extension to make it easy to add to a given `Fixture`. */ export declare class Extension { private _builders; private _typeAliases; private _decorators; /** * Create a new `Extension` */ constructor(); /** * All builders added to the extension */ readonly builders: Array<TypeBuilder<any>>; /** * Decorators to apply on every addition of a builder * * Note: Use feature cautiously as one broken decorator can have a large impact */ [decorators]: Array<new (decoratee: TypeBuilder<any>) => TypeBuilder<any>>; /** * Add builder * @param builder - builder to add * @returns `this` * @throws if builder with same type or alias already exists */ add(builder: TypeBuilder<any>): this; /** * Get builder * @param typeOrAlias - type or alias for builder * @returns `object` */ get<T>(typeOrAlias: string): TypeBuilder<T>; /** * Remove builder * @param type - builder with type to remove * @returns `this` */ remove(type: string): this; /** * Merge data from another extension * @param extension - extension to merge to this extension * @returns `this` */ merge(extension: Extension): this; /** * Remove all builders (including aliases) */ clear(): void; }