typelorem
v0.0.11
Published
Lorem Ipsum generator for Typescript types
Downloads
19
Maintainers
Keywords
Readme
TypeLorem uses TypeScript types as schemas to mass generate placeholder data for your application.
For most popular types such as id | username | email | age | firstName | lastName | fullName | address, the meaning of generated content will be inferred realistically.
Import:
import TypeLorem from "typelorem";
const lorem = new TypeLorem();
Usage:
const users = await lorem.make("User", 10); // create 10 users of type User;
const mixed = await lorem.make("Mixed"); // create a single object of type Mixed;
const { User, Shape } = await lorem.schema("User", "Shape").make(2);
Examples:
interface Shape {
size: number;
}
type User = {
id: number;
name: string;
email: string;
age?: number | string;
};
type Mixed = User | Shape;
lorem.schema("User", "Shape").make(2).then(console.log);
// {
// User: [
// {
// id: '0120834595',
// name: 'Oscar',
// email: '[email protected]',
// age: 19
// },
// {
// id: '3286946306',
// name: 'Eva',
// email: '[email protected]',
// age: '71'
// }
// ],
// Shape: [ { size: 1310 }, { size: 176 } ]
// }
lorem.make("Mixed").then(console.log);
// {
// id: '7546200767',
// name: 'Richard',
// email: '[email protected]',
// age: 13
// }
lorem.make("User", 10).then(console.log);
// [
// {
// id: '0414618068',
// name: 'Grant',
// email: '[email protected]',
// age: '33'
// },
// {
// id: '5996496097',
// name: 'Faith',
// email: '[email protected]'
// },
// {
// id: '6970826628',
// name: 'Dakota',
// email: '[email protected]',
// age: 4
// },
// {
// id: '6120869639',
// name: 'Liliana',
// email: '[email protected]'
// },
// {
// id: '4910676754',
// name: 'Ethan',
// email: '[email protected]',
// age: 34
// },
// {
// id: '8567096203',
// name: 'Kate',
// email: '[email protected]',
// age: '5'
// },
// { id: '3002696204', name: 'Juliana', email: '[email protected]' },
// {
// id: '9132274669',
// name: 'Dylan',
// email: '[email protected]'
// },
// {
// id: '1949153302',
// name: 'Keenan',
// email: '[email protected]',
// age: '37'
// },
// {
// id: '1044740351',
// name: 'Montague',
// email: '[email protected]'
// }
// ]