Skip to content
Source
Sign inSign up
TanStack/table
Open History to see the last commit

makeData.ts

21 lines525 Bytes

1import { faker } from '@faker-js/faker'
2​
3export type Sale = {
4 category: string
5 item: string
6 amount: number
7 score: number
8}
9​
10const categories = ['Hardware', 'Software', 'Services'] as const
11​
12const newSale = (): Sale => ({
13 category: faker.helpers.arrayElement(categories),
14 item: faker.commerce.productName(),
15 amount: faker.number.int({ min: 25, max: 5_000 }),
16 score: faker.number.int({ min: 60, max: 100 }),
17})
18​
19export function makeData(length: number): Array<Sale> {
20 return Array.from({ length }, newSale)