npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

flex-lorem

v1.1.1

Published

A flexible Lorem Ipsum generator for developers - generate placeholder text by words, characters, paragraphs, or lists

Readme

flex-lorem

A flexible Lorem Ipsum generator for developers. Generate placeholder text by words, characters, paragraphs, or lists with simple, intuitive functions.

Installation

npm install flex-lorem

Usage

Basic Usage

const lorem = require('flex-lorem');

// Generate 10 words (default)
console.log(lorem.words());
// "Lorem ipsum dolor sit amet consectetur adipiscing elit sed do."

// Generate 5 words
console.log(lorem.words(5));
// "Lorem ipsum dolor sit amet."

// Generate 50 characters (approximate)
console.log(lorem.characters(50));
// "Lorem ipsum dolor sit amet consectetur."

ES6 Imports

import lorem from 'flex-lorem';
// or
import { words, characters, paragraphs } from 'flex-lorem';

console.log(words(8));
console.log(characters(100));

API Reference

words(count, startWithLorem)

Generate text by word count.

  • count (number, default: 10) - Number of words to generate
  • startWithLorem (boolean, default: true) - Whether to start with "Lorem ipsum"
lorem.words(15);
lorem.words(20, false); // Don't start with "Lorem ipsum"

characters(count, startWithLorem)

Generate text by approximate character count.

  • count (number, required) - Approximate number of characters
  • startWithLorem (boolean, default: true) - Whether to start with "Lorem ipsum"
lorem.characters(100);
lorem.characters(200, false);

paragraphs(count, sentencesPerParagraph, startWithLorem)

Generate multiple paragraphs.

  • count (number, default: 1) - Number of paragraphs
  • sentencesPerParagraph (number, default: random 3-6) - Sentences per paragraph
  • startWithLorem (boolean, default: true) - Whether to start with "Lorem ipsum"
lorem.paragraphs(3);
lorem.paragraphs(2, 4); // 2 paragraphs, 4 sentences each
lorem.paragraphs(3, 5, false);

sentence(wordCount, startWithLorem)

Generate a single sentence.

  • wordCount (number, default: random 8-20) - Number of words in the sentence
  • startWithLorem (boolean, default: true) - Whether to start with "Lorem ipsum"
lorem.sentence();
lorem.sentence(12);
lorem.sentence(15, false);

list(itemCount, format)

Generate list items.

  • itemCount (number, default: 5) - Number of list items
  • format (string, default: 'array') - Format: 'array', 'numbered', or 'bulleted'
lorem.list(3);                    // Returns array: ['Lorem ipsum dolor', 'sit amet consectetur', 'adipiscing elit sed']
lorem.list(3, 'numbered');        // Returns string: "1. Lorem ipsum dolor\n2. sit amet consectetur\n3. adipiscing elit sed"
lorem.list(3, 'bulleted');        // Returns string: "• Lorem ipsum dolor\n• sit amet consectetur\n• adipiscing elit sed"

Short Aliases

For convenience, short aliases are available:

lorem.w(10);        // same as lorem.words(10)
lorem.c(100);       // same as lorem.characters(100)
lorem.p(2);         // same as lorem.paragraphs(2)
lorem.s();          // same as lorem.sentence()
lorem.l(5);         // same as lorem.list(5)

Common Use Cases

React Components

import { words, paragraphs } from 'flex-lorem';

function BlogPost() {
  return (
    <div>
      <h1>{words(4, false)}</h1>
      <p>{paragraphs(3)}</p>
    </div>
  );
}

Testing

const lorem = require('flex-lorem');

// Generate test data
const testUser = {
  name: lorem.words(2, false),
  bio: lorem.characters(150),
  posts: Array.from({length: 5}, () => ({
    title: lorem.words(6, false),
    content: lorem.paragraphs(2)
  }))
};

Form Placeholders

<input type="text" placeholder="<%= lorem.words(3, false) %>">
<textarea placeholder="<%= lorem.sentence(12, false) %>"></textarea>

API Responses

// Generate mock API response
const mockPosts = Array.from({length: 10}, (_, i) => ({
  id: i + 1,
  title: lorem.words(5, false),
  excerpt: lorem.sentence(15, false),
  content: lorem.paragraphs(3),
  tags: lorem.list(3, 'array')
}));

Features

  • 🎯 Flexible: Generate by words, characters, paragraphs, sentences, or lists
  • 📦 Zero dependencies: Lightweight and fast
  • 🔧 TypeScript support: Full TypeScript definitions included
  • 🚀 Easy to use: Simple API with sensible defaults
  • 🔀 Randomized: Different output each time
  • 📝 Proper formatting: Capitalization and punctuation handled automatically

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please feel free to submit a Pull Request.