/** * Higher order function that takes a method whose responsibility is to create a * **single** data fixture object and returns a new generator function that * allows you to create 1 or many of those fixtures. Fixture generator function * that's returned supports passing optional `num` and `overrides` params. * * @example * * const generateInvoice = (overrides) => ({ id: uuid(), balance: 15799, classification: "Adult Use", ...overrides}); * const generateInvoices = createFixtureGenerator(generateInvoice); * * generateInvoices() // => Single invoice object * generateInvoices(1) // => Single invoice object * generateInvoices(1, { foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'` * generateInvoices({ foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'` * generateInvoices(10) // => Array of 10 invoice objects * generateInvoices(10, { foo: 'bar' }) // => Array of 10 invoice objects, override `foo` to equal `'bar'` in each * * @param fixtureFn - Method that generates a JSON data fixture. * @returns A fixture generator that return an array of fixture objects or single object if n = 1. */ export default function createFixtureGenerator(fixtureFn: (overrides?: Partial, index?: number) => T): { (): T; (num: TNum, overrides?: Partial): T; (num: Partial): T; (num: TNum, overrides?: Partial): T[]; };