Comparing version 0.0.42 to 0.0.51
@@ -7,2 +7,2 @@ (function(e,d){if("undefined"!==typeof module&&module.exports)module.exports=d();else{var c=window||{};c.define&&c.define.amd?c.define([],d):c.exports?c.exports=d():c[e]=d()}})("txtgen",function(){var e="alligator ant bear bee bird camel cat cheetah chicken chimpanzee cow crocodile deer dog dolphin duck eagle elephant fish fly fox frog giraffe goat goldfish hamster hippopotamus horse kangaroo kitten lion lobster monkey octopus owl panda pig puppy rabbit rat scorpion seal shark sheep snail snake spider squirrel tiger turtle wolf zebra apple apricot banana blackberry blueberry cherry cranberry currant fig grape grapefruit grapes kiwi kumquat lemon lime melon nectarine orange peach pear persimmon pineapple plum pomegranate prune raspberry strawberry tangerine watermelon".split(" "), | ||
an_adjective:function(){return h(f(d))}},k=function(){var a;a=.33>Math.random()?f(n):"";var b=f(m),g=b;if((b=b.match(/\{\{(.+?)\}\}/g))&&b.length)for(var c=0;c<b.length;c++){var d=b[c].replace("{{","").replace("}}","").replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").replace(/\r?\n|\r/g," ").replace(/\s\s+|\r/g," "),e=void 0;p.includes(d)&&(e=q[d]());g=g.replace(b[c],e)}a+=g;a=a.charAt(0).toUpperCase()+a.slice(1);g=f(".......!?!?;...".split(""));return a+g},l=function(a){(a=void 0===a?0:a)||(a=Math.floor(8*Math.random())+ | ||
3);a=Math.min(a,15);for(var b=[];b.length<a;){var c=k();b.push(c)}return b.join(" ")};return{sentence:k,phrase:l,article:function(a){(a=void 0===a?0:a)||(a=Math.floor(8*Math.random())+3);a=Math.min(a,15);for(var b=[];b.length<a;){var c=l();b.push(c)}return b.join("\n\n")}}}); | ||
3);a=Math.min(a,15);for(var b=[];b.length<a;){var c=k();b.push(c)}return b.join(" ")};return{sentence:k,paragraph:l,article:function(a){(a=void 0===a?0:a)||(a=Math.floor(8*Math.random())+3);a=Math.min(a,15);for(var b=[];b.length<a;){var c=l();b.push(c)}return b.join("\n\n")}}}); |
{ | ||
"version": "0.0.42", | ||
"version": "0.0.51", | ||
"name": "txtgen", | ||
@@ -34,3 +34,3 @@ "description": "Text generator. Small tool for generating funny sentences in English", | ||
"sentence", | ||
"phrase", | ||
"paragraph", | ||
"article", | ||
@@ -37,0 +37,0 @@ "generator", |
# txtgen | ||
Util for generating random sentences, phrases and articles in English. Inspired by [Sentencer](https://github.com/kylestetz/Sentencer) and [metaphorpsum.com](http://metaphorpsum.com/). | ||
Just available on Node.js v6.0.0 or newer and the browsers with ES6 support. | ||
This lib is created to use as a new content generator in [FastTyping](https://goo.gl/EFGMsd). It's very lightweight to embed into client side (Just 159B gzip or 6.9KB minified!). Note that, it's available only in Node.js v6.0.0 or newer and the browsers with ES6 support. | ||
@@ -68,4 +68,4 @@ [View DEMO](http://ndaidong.github.io/txtgen/). | ||
let phrase = txtgen.phrase(); | ||
console.log(phrase); | ||
let paragraph = txtgen.paragraph(); | ||
console.log(paragraph); | ||
@@ -79,4 +79,4 @@ let article = txtgen.article(); | ||
- .sentence() | ||
- .phrase([Number totalSentences]) | ||
- .article([Number totalPhrases]) | ||
- .paragraph([Number totalSentences]) | ||
- .article([Number totalParagraphs]) | ||
@@ -83,0 +83,0 @@ # Test |
@@ -197,3 +197,3 @@ /** | ||
var makePhrase = (len = 0) => { | ||
var makeParagraph = (len = 0) => { | ||
if (!len) { | ||
@@ -218,3 +218,3 @@ len = random(3, 10); | ||
while (a.length < t) { | ||
let s = makePhrase(); | ||
let s = makeParagraph(); | ||
a.push(s); | ||
@@ -227,5 +227,5 @@ } | ||
sentence: makeSentence, | ||
phrase: makePhrase, | ||
paragraph: makeParagraph, | ||
article: makeArticle | ||
}; | ||
}); |
@@ -21,3 +21,3 @@ /** | ||
'sentence', | ||
'phrase', | ||
'paragraph', | ||
'article' | ||
@@ -44,5 +44,5 @@ ]; | ||
test('txtgen.phrase():', (assert) => { | ||
let phrase = txtgen.phrase(); | ||
assert.ok(bella.isString(phrase) && phrase.length > 0, 'A phrase must be created'); | ||
test('txtgen.paragraph():', (assert) => { | ||
let paragraph = txtgen.paragraph(); | ||
assert.ok(bella.isString(paragraph) && paragraph.length > 0, 'A paragraph must be created'); | ||
assert.end(); | ||
@@ -49,0 +49,0 @@ }); |
@@ -15,3 +15,3 @@ /** | ||
'sentence', | ||
'phrase', | ||
'paragraph', | ||
'article' | ||
@@ -49,6 +49,6 @@ ]; | ||
describe('txtgen.phrase()', () => { | ||
describe('txtgen.paragraph()', () => { | ||
let d = txtgen.phrase(); | ||
it('A phrase must be created', () => { | ||
let d = txtgen.paragraph(); | ||
it('A paragraph must be created', () => { | ||
expect(d).toBeDefined(); | ||
@@ -55,0 +55,0 @@ expect(d.length).toBeGreaterThan(0); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194236