Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

txtgen

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

txtgen

Util for generating random sentences, paragraphs and articles in English

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2K
decreased by-22.64%
Maintainers
1
Weekly downloads
 
Created
Source

txtgen

Lightweight util for generating random sentences, paragraphs and articles in English. Inspired by Sentencer and metaphorpsum.com.

NPM Build Status codecov Dependency Status NSP Status

Demo

See how it works?

Setup

  • Node.js

    npm install txtgen
    
  • CDN

  • Also supports ES6 Module, CommonJS, AMD and UMD style.

Usage

var txtgen = require('txtgen');

let sentence = txtgen.sentence();
console.log(sentence);

let paragraph = txtgen.paragraph();
console.log(paragraph);

let article = txtgen.article();
console.log(article);

APIs

  • .sentence()
  • .paragraph([Number totalSentences])
  • .article([Number totalParagraphs])
  • .addNouns(Array nouns)
  • .addAdjectives(Array adjectives)
  • .addTemplates(Array sentenceTemplates)

Template

If you want to add more kinds of sentence, just use .addTemplates() method. It expects a list of sentence templates. Each of sentence template is an English sentence, with the placeholders that can be replaced with any alternative word.

For example:

import {
  addTemplates
} from 'txtgen';

let templates = [
  '{{a_noun}} is {{a_noun}} from the right perspective',
  'the {{noun}} of {{a_noun}} becomes {{an_adjective}} {{noun}}'
];

addTemplates(templates);

Here are the available placeholders:

  • noun
  • nouns
  • a_noun
  • adjective
  • an_adjective

Test

git clone https://github.com/ndaidong/txtgen.git
cd txtgen
npm install
npm test

License

The MIT License (MIT)

Keywords

FAQs

Package last updated on 07 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc