typelorem
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

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: 'irene_perry@example.com',
//       age: 19
//     },
//     {
//       id: '3286946306',
//       name: 'Eva',
//       email: 'osmond_young@example.com',
//       age: '71'
//     }
//   ],
//   Shape: [ { size: 1310 }, { size: 176 } ]
// }

lorem.make("Mixed").then(console.log);
// {
//   id: '7546200767',
//   name: 'Richard',
//   email: 'araceli_diaz@example.com',
//   age: 13
// }

lorem.make("User", 10).then(console.log);
// [
//   {
//     id: '0414618068',
//     name: 'Grant',
//     email: 'calvin_rodriguez@example.com',
//     age: '33'
//   },
//   {
//     id: '5996496097',
//     name: 'Faith',
//     email: 'delaney_bradley@example.com'
//   },
//   {
//     id: '6970826628',
//     name: 'Dakota',
//     email: 'kane_turner@example.com',
//     age: 4
//   },
//   {
//     id: '6120869639',
//     name: 'Liliana',
//     email: 'josephine_fuller@example.com'
//   },
//   {
//     id: '4910676754',
//     name: 'Ethan',
//     email: 'darell_morris@example.com',
//     age: 34
//   },
//   {
//     id: '8567096203',
//     name: 'Kate',
//     email: 'steve_holmes@example.com',
//     age: '5'
//   },
//   { id: '3002696204', name: 'Juliana', email: 'jade_hill@example.com' },
//   {
//     id: '9132274669',
//     name: 'Dylan',
//     email: 'cecil_franklin@example.com'
//   },
//   {
//     id: '1949153302',
//     name: 'Keenan',
//     email: 'kermit_hart@example.com',
//     age: '37'
//   },
//   {
//     id: '1044740351',
//     name: 'Montague',
//     email: 'caesar_hart@example.com'
//   }
// ]

Package Sidebar

Install

npm i typelorem

Weekly Downloads

12

Version

0.0.11

License

MIT

Unpacked Size

15.2 kB

Total Files

11

Last publish

Collaborators

  • kvooak