txtgen
Util for generating random sentences, phrases and articles in English. Inspired by Sentencer and metaphorpsum.com.
Just available on Node.js v6.0.0 or newer and the browsers with ES6 support.
View DEMO.
Setup
Node.js
npm install txtgen --save
SystemJS
System.config({
baseUrl: '/path/to/js/folder',
map: {
txtgen: 'txtgen.min'
}
});
System.import('txtgen').then((txtgen) => {
// use txtgen here
});
RequireJS
require.config({
baseUrl: '/path/to/js/folder',
paths: {
txtgen: 'txtgen.min'
}
});
requirejs('txtgen', (txtgen) => {
// use txtgen here
});
CDN
<script type="text/javascript" src="https://cdn.rawgit.com/ndaidong/txtgen/master/dist/txtgen.min.js"></script>
Usage
var txtgen = require('txtgen');
let sentence = txtgen.sentence();
console.log(sentence);
let phrase = txtgen.phrase();
console.log(phrase);
let article = txtgen.article();
console.log(article);
APIs
- .sentence()
- .phrase([Number totalSentences])
- .article([Number totalPhrases])
Test
git clone https://github.com/ndaidong/txtgen.git
cd txtgen
npm install
npm test
License
The MIT License (MIT)