Handy developer utilities: image generator, lorem text, colorful console
npm install devkit-lite> Handy developer utilities: image generator, lorem text, colorful console
A lightweight TypeScript utility library providing essential developer tools for placeholder images, lorem ipsum text generation, and enhanced console logging.
``bash`
npm install devkit-lite
`bash`
yarn add devkit-lite
`bash`
pnpm add devkit-lite
`typescript
import { generateImg, generateParagraph, Console } from "devkit-lite";
// Generate placeholder image URL
const imageUrl = generateImg(123, 800, 600);
console.log(imageUrl); // https://picsum.photos/id/123/800/600
// Generate lorem ipsum text
const text = generateParagraph(50);
console.log(text); // Lorem ipsum dolor sit amet...
// Enhanced console logging
Console("User logged in successfully", "response");
Console({ userId: 123, name: "John" }, "info");
Console("Database connection failed", "error");
`
Generates a placeholder image URL using Picsum Photos.
Parameters:
- id (number, optional): Image ID. Defaults to a random number between 0-1000width
- (number, optional): Image width in pixels. Defaults to 400height
- (number, optional): Image height in pixels. Defaults to 300
Returns: string - Placeholder image URL
Example:
`typescript
// Random image with default size
const img1 = generateImg();
// Specific image with custom dimensions
const img2 = generateImg(237, 1920, 1080);
`
Generates lorem ipsum placeholder text with the specified word count.
Parameters:
- wordCount (number, optional): Number of words to generate. Defaults to 20
Returns: string - Lorem ipsum text ending with a period
Example:
`typescript
// Generate 20 words (default)
const shortText = generateParagraph();
// Generate 100 words
const longText = generateParagraph(100);
`
Enhanced console logger with color-coded output and icons. Automatically hides logs in production environment.
Parameters:
- message (unknown): The message to log. Can be a string, object, array, or any valuetype
- (LogType, optional): Log type. Defaults to 'debug'
Log Types:
- 'database' - đī¸ Blue for database operations'response'
- - â
Green for successful responses'debug'
- - đ Yellow for debug messages'info'
- - âšī¸ Cyan for informational messages'warn'
- - â ī¸ Magenta for warnings'error'
- - â Red for errors
Returns: void
Note: Logs are automatically suppressed when NODE_ENV === 'production'
Example:
`typescript
// String messages
Console("User created", "response");
Console("Invalid input", "error");
Console("Processing data...", "info");
// Object logging (automatically pretty-printed)
Console({ userId: 123, action: "login" }, "database");
Console([1, 2, 3, 4, 5], "debug");
``
- đŧī¸ Placeholder Images: Quick access to placeholder images via Picsum Photos
- đ Lorem Ipsum Generator: Generate placeholder text of any length
- đ¨ Colorful Console: Enhanced console logging with colors, icons, and type safety
- đĢ Production Safe: Console logs automatically disabled in production
- đĻ TypeScript: Full TypeScript support with type definitions
- đŗ Tree-shakeable: Import only what you need
- ⥠Lightweight: Minimal dependencies
- Node.js 14+ (or any modern JavaScript runtime)
- TypeScript 4.5+ (for TypeScript projects)
MIT Š Saurav Pandey
Saurav Pandey
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
If this project helped you, please give it a â on GitHub!