Skip to content
0

katanakit-js / useFakeList

Function: useFakeList() ​

ts
function useFakeList<T>(factory, count): Promise<T[]>;

Defined in: src/core/services/faker.service.ts:266

Builds an array of fake items from a factory (sync or async).

Type Parameters ​

Type ParameterDescription
TItem type produced by the factory.

Parameters ​

ParameterTypeDescription
factory(index) => T | Promise<T>Called once per item; receives the zero-based index.
countnumberNumber of items to generate (non-negative integer).

Returns ​

Promise<T[]>

A promise resolving to the generated array.

Example ​

ts
const vehicles = await useFakeList(() => useFakeVehicle(), 5);
const relations = await useFakeList((index) => ({ user: users[index % users.length] }), 10);

Released under the MIT License.