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 - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

dist/txtgen.js

22

dist/txtgen.min.js

@@ -1,20 +0,2 @@

/**
* txtgen
* v1.0.7
* built: Tue, 04 Oct 2016 03:29:32 GMT
* git: https://github.com/ndaidong/txtgen
* author: @ndaidong
* License: MIT
**/
;var $jscomp={scope:{},checkStringArgs:function(a,d,b){if(null==a)throw new TypeError("The 'this' value for String.prototype."+b+" must not be null or undefined");if(d instanceof RegExp)throw new TypeError("First argument to String.prototype."+b+" must not be a regular expression");return a+""}};
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,d,b){if(b.get||b.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[d]=b.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,d,b,e){if(d){b=$jscomp.global;a=a.split(".");for(e=0;e<a.length-1;e++){var f=a[e];f in b||(b[f]={});b=b[f]}a=a[a.length-1];e=b[a];d=d(e);d!=e&&null!=d&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:d})}};
$jscomp.polyfill("String.prototype.endsWith",function(a){return a?a:function(a,b){var d=$jscomp.checkStringArgs(this,a,"endsWith");a+="";void 0===b&&(b=d.length);b=Math.max(0,Math.min(b|0,d.length));for(var f=a.length;0<f&&0<b;)if(d[--b]!=a[--f])return!1;return 0>=f}},"es6-impl","es3");$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,b){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,b||0)}},"es6-impl","es3");
(function(a,d){if("undefined"!==typeof module&&module.exports)module.exports=d();else{var b=window||{};b.define&&b.define.amd?b.define([],d):b.exports?b.exports=d():b[a]=d()}})("txtgen",function(){var a="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(" "),
d="adaptable adventurous affable affectionate agreeable alert alluring ambitious ambitious amiable amicable amused amusing boundless brave brave bright bright broad-minded calm calm capable careful charming charming cheerful coherent comfortable communicative compassionate confident conscientious considerate convivial cooperative courageous courageous courteous creative credible cultured dashing dazzling debonair decisive decisive decorous delightful detailed determined determined diligent diligent diplomatic discreet discreet dynamic dynamic eager easygoing efficient elated eminent emotional enchanting encouraging endurable energetic energetic entertaining enthusiastic enthusiastic excellent excited exclusive exuberant exuberant fabulous fair fair-minded faithful faithful fantastic fearless fearless fine forceful frank frank friendly friendly funny funny generous generous gentle gentle glorious good good gregarious happy hard-working harmonious helpful helpful hilarious honest honorable humorous imaginative impartial impartial independent industrious instinctive intellectual intelligent intuitive inventive jolly joyous kind kind kind-hearted knowledgeable level likeable lively lovely loving loving loyal lucky mature modern modest neat nice nice obedient optimistic painstaking passionate patient peaceful perfect persistent philosophical pioneering placid placid plausible pleasant plucky plucky polite powerful practical pro-active productive protective proud punctual quick-witted quiet quiet rational receptive reflective reliable relieved reserved resolute resourceful responsible rhetorical righteous romantic romantic sedate seemly selective self-assured self-confident self-disciplined sensible sensitive sensitive shrewd shy silly sincere sincere skillful smiling sociable splendid steadfast stimulating straightforward successful succinct sympathetic talented thoughtful thoughtful thrifty tidy tough tough trustworthy unassuming unbiased understanding unusual upbeat versatile vigorous vivacious warm warmhearted willing willing wise witty witty wonderful".split(" "),
b="aeiouy".split(""),e="the {{noun}} is {{a_noun}};{{a_noun}} is {{an_adjective}} {{noun}};the first {{adjective}} {{noun}} is, in its own way, {{a_noun}};their {{noun}} was, in this moment, {{an_adjective}} {{noun}};{{a_noun}} is {{a_noun}} from the right perspective;the literature would have us believe that {{an_adjective}} {{noun}} is not but {{a_noun}};{{an_adjective}} {{noun}} is {{a_noun}} of the mind;the {{adjective}} {{noun}} reveals itself as {{an_adjective}} {{noun}} to those who look;authors often misinterpret the {{noun}} as {{an_adjective}} {{noun}}, when in actuality it feels more like {{an_adjective}} {{noun}};we can assume that any instance of {{a_noun}} can be construed as {{an_adjective}} {{noun}};they were lost without the {{adjective}} {{noun}} that composed their {{noun}};the {{adjective}} {{noun}} comes from {{an_adjective}} {{noun}};{{a_noun}} can hardly be considered {{an_adjective}} {{noun}} without also being {{a_noun}};few can name {{an_adjective}} {{noun}} that isn't {{an_adjective}} {{noun}};some posit the {{adjective}} {{noun}} to be less than {{adjective}};{{a_noun}} of the {{noun}} is assumed to be {{an_adjective}} {{noun}};{{a_noun}} sees {{a_noun}} as {{an_adjective}} {{noun}};the {{noun}} of {{a_noun}} becomes {{an_adjective}} {{noun}};{{a_noun}} is {{a_noun}}'s {{noun}};{{a_noun}} is the {{noun}} of {{a_noun}};{{an_adjective}} {{noun}}'s {{noun}} comes with it the thought that the {{adjective}} {{noun}} is {{a_noun}};{{nouns}} are {{adjective}} {{nouns}};{{adjective}} {{nouns}} show us how {{nouns}} can be {{nouns}};before {{nouns}}, {{nouns}} were only {{nouns}};those {{nouns}} are nothing more than {{nouns}};some {{adjective}} {{nouns}} are thought of simply as {{nouns}};one cannot separate {{nouns}} from {{adjective}} {{nouns}};the {{nouns}} could be said to resemble {{adjective}} {{nouns}};{{an_adjective}} {{noun}} without {{nouns}} is truly a {{noun}} of {{adjective}} {{nouns}}".split(";"),
f="to be more specific, {in recent years, {however, {by the way{of course, {some assert that {if this was somewhat unclear, {unfortunately, that is wrong; on the contrary, {it's very tricky, if not impossible, {this could be, or perhaps {this is not to discredit the idea that {we know that {it's an undeniable fact, really; {framed in a different way, {what we don't know for sure is whether or not {as far as we can estimate, {as far as he is concerned, {the zeitgeist contends that {though we assume the latter, {far from the truth, {extending this logic, {nowhere is it disputed that {in modern times {in ancient times {recent controversy aside, {washing and polishing the car,{having been a gymnast, {after a long day at school and work, {waking to the buzz of the alarm clock, {draped neatly on a hanger, {shouting with happiness, ".split("{"),
h=function(c){for(var a=[],b=0;b<c.length;b++)-1===a.indexOf(c[b])&&a.push(c[b]);return a},g=function(c){for(var a;!a;)a=c[Math.floor(Math.random()*(c.length-1-0+1))+0];return a},k=function(c){var a="a";c.match(/^(a|e|i|o)/)&&(a="an");return a+" "+c},n=["noun","a_noun","nouns","adjective","an_adjective"],p={noun:function(){return g(a)},a_noun:function(){return k(g(a))},nouns:function(){var c;c=g(a);c.endsWith("s")||(c.match(/(ss|ish|ch|x|us)$/)?c+="e":c.endsWith("y")&&!b.includes(c.charAt(c.length-
2))&&(c=c.slice(0,c.length-1),c+="ie"),c+="s");return c},adjective:function(){return g(d)},an_adjective:function(){return k(g(d))}},l=function(){var c;c=.33>Math.random()?g(f):"";var a=g(e),b=a;if((a=a.match(/\{\{(.+?)\}\}/g))&&a.length)for(var d=0;d<a.length;d++){var h=a[d].replace("{{","").replace("}}","").replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").replace(/\r?\n|\r/g," ").replace(/\s\s+|\r/g," "),k=void 0;n.includes(h)&&(k=p[h]());b=b.replace(a[d],k)}c+=b;c=c.charAt(0).toUpperCase()+c.slice(1);b=g(".......!?!?;...".split(""));
return c+b},m=function(a){(a=void 0===a?0:a)||(a=Math.floor(8*Math.random())+3);a=Math.min(a,15);for(var c=[];c.length<a;){var b=l();c.push(b)}return c.join(" ")};return{sentence:l,paragraph:m,article:function(a){(a=void 0===a?0:a)||(a=Math.floor(8*Math.random())+3);a=Math.min(a,15);for(var c=[];c.length<a;){var b=m();c.push(b)}return c.join("\n\n")},addNouns:function(c){c=void 0===c?[]:c;c=a.concat(c);a=h(c);return a.length},addAdjectives:function(a){a=d.concat(a);d=h(a);return d.length},addTemplates:function(a){a=
e.concat(a);e=h(a);return e.length}}});
// txtgen@1.0.8, by @ndaidong - built on Sun, 20 Nov 2016 12:53:47 GMT - published under MIT license
;(function(name,factory){if(typeof module!=="undefined"&&module.exports){module.exports=factory()}else{var root=window||{};if(root.define&&root.define.amd){root.define([],factory)}else if(root.exports){root.exports=factory()}else{root[name]=factory()}}}("txtgen",function(){var _nouns=["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"];var adjectives=["adaptable","adventurous","affable","affectionate","agreeable","alert","alluring","ambitious","ambitious","amiable","amicable","amused","amusing","boundless","brave","brave","bright","bright","broad-minded","calm","calm","capable","careful","charming","charming","cheerful","coherent","comfortable","communicative","compassionate","confident","conscientious","considerate","convivial","cooperative","courageous","courageous","courteous","creative","credible","cultured","dashing","dazzling","debonair","decisive","decisive","decorous","delightful","detailed","determined","determined","diligent","diligent","diplomatic","discreet","discreet","dynamic","dynamic","eager","easygoing","efficient","elated","eminent","emotional","enchanting","encouraging","endurable","energetic","energetic","entertaining","enthusiastic","enthusiastic","excellent","excited","exclusive","exuberant","exuberant","fabulous","fair","fair-minded","faithful","faithful","fantastic","fearless","fearless","fine","forceful","frank","frank","friendly","friendly","funny","funny","generous","generous","gentle","gentle","glorious","good","good","gregarious","happy","hard-working","harmonious","helpful","helpful","hilarious","honest","honorable","humorous","imaginative","impartial","impartial","independent","industrious","instinctive","intellectual","intelligent","intuitive","inventive","jolly","joyous","kind","kind","kind-hearted","knowledgeable","level","likeable","lively","lovely","loving","loving","loyal","lucky","mature","modern","modest","neat","nice","nice","obedient","optimistic","painstaking","passionate","patient","peaceful","perfect","persistent","philosophical","pioneering","placid","placid","plausible","pleasant","plucky","plucky","polite","powerful","practical","pro-active","productive","protective","proud","punctual","quick-witted","quiet","quiet","rational","receptive","reflective","reliable","relieved","reserved","resolute","resourceful","responsible","rhetorical","righteous","romantic","romantic","sedate","seemly","selective","self-assured","self-confident","self-disciplined","sensible","sensitive","sensitive","shrewd","shy","silly","sincere","sincere","skillful","smiling","sociable","splendid","steadfast","stimulating","straightforward","successful","succinct","sympathetic","talented","thoughtful","thoughtful","thrifty","tidy","tough","tough","trustworthy","unassuming","unbiased","understanding","unusual","upbeat","versatile","vigorous","vivacious","warm","warmhearted","willing","willing","wise","witty","witty","wonderful"];var vowels=["a","e","i","o","u","y"];var sentenceTemplates=["the {{noun}} is {{a_noun}}","{{a_noun}} is {{an_adjective}} {{noun}}","the first {{adjective}} {{noun}} is, in its own way, {{a_noun}}","their {{noun}} was, in this moment, {{an_adjective}} {{noun}}","{{a_noun}} is {{a_noun}} from the right perspective","the literature would have us believe that {{an_adjective}} {{noun}} is not but {{a_noun}}","{{an_adjective}} {{noun}} is {{a_noun}} of the mind","the {{adjective}} {{noun}} reveals itself as {{an_adjective}} {{noun}} to those who look","authors often misinterpret the {{noun}} as {{an_adjective}} {{noun}}, when in actuality it feels more like {{an_adjective}} {{noun}}","we can assume that any instance of {{a_noun}} can be construed as {{an_adjective}} {{noun}}","they were lost without the {{adjective}} {{noun}} that composed their {{noun}}","the {{adjective}} {{noun}} comes from {{an_adjective}} {{noun}}","{{a_noun}} can hardly be considered {{an_adjective}} {{noun}} without also being {{a_noun}}","few can name {{an_adjective}} {{noun}} that isn't {{an_adjective}} {{noun}}","some posit the {{adjective}} {{noun}} to be less than {{adjective}}","{{a_noun}} of the {{noun}} is assumed to be {{an_adjective}} {{noun}}","{{a_noun}} sees {{a_noun}} as {{an_adjective}} {{noun}}","the {{noun}} of {{a_noun}} becomes {{an_adjective}} {{noun}}","{{a_noun}} is {{a_noun}}'s {{noun}}","{{a_noun}} is the {{noun}} of {{a_noun}}","{{an_adjective}} {{noun}}'s {{noun}} comes with it the thought that the {{adjective}} {{noun}} is {{a_noun}}","{{nouns}} are {{adjective}} {{nouns}}","{{adjective}} {{nouns}} show us how {{nouns}} can be {{nouns}}","before {{nouns}}, {{nouns}} were only {{nouns}}","those {{nouns}} are nothing more than {{nouns}}","some {{adjective}} {{nouns}} are thought of simply as {{nouns}}","one cannot separate {{nouns}} from {{adjective}} {{nouns}}","the {{nouns}} could be said to resemble {{adjective}} {{nouns}}","{{an_adjective}} {{noun}} without {{nouns}} is truly a {{noun}} of {{adjective}} {{nouns}}"];var phrases=["to be more specific, ","in recent years, ","however, ","by the way","of course, ","some assert that ","if this was somewhat unclear, ","unfortunately, that is wrong; on the contrary, ","it's very tricky, if not impossible, ","this could be, or perhaps ","this is not to discredit the idea that ","we know that ","it's an undeniable fact, really; ","framed in a different way, ","what we don't know for sure is whether or not ","as far as we can estimate, ","as far as he is concerned, ","the zeitgeist contends that ","though we assume the latter, ","far from the truth, ","extending this logic, ","nowhere is it disputed that ","in modern times ","in ancient times ","recent controversy aside, ","washing and polishing the car,","having been a gymnast, ","after a long day at school and work, ","waking to the buzz of the alarm clock, ","draped neatly on a hanger, ","shouting with happiness, "];var unique=function unique(a){var r=[];for(var i=0;i<a.length;i++){if(r.indexOf(a[i])===-1){r.push(a[i])}}return r};var addNouns=function addNouns(){var ls=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var a=_nouns.concat(ls);_nouns=unique(a);return _nouns.length};var addAdjectives=function addAdjectives(ls){var a=adjectives.concat(ls);adjectives=unique(a);return adjectives.length};var addTemplates=function addTemplates(ls){var a=sentenceTemplates.concat(ls);sentenceTemplates=unique(a);return sentenceTemplates.length};var random=function random(min,max){var offset=min;var range=max-min+1;var rd=Math.floor(Math.random()*range)+offset;return rd};var rand=function rand(a){var w=void 0;while(!w){w=a[random(0,a.length-1)]}return w};var pickLastPunc=function pickLastPunc(){var a=".......!?!?;...".split("");return rand(a)};var pluralize=function pluralize(word){if(word.endsWith("s")){return word}if(word.match(/(ss|ish|ch|x|us)$/)){word+="e"}else if(word.endsWith("y")&&!vowels.includes(word.charAt(word.length-2))){word=word.slice(0,word.length-1);word+="ie"}return word+"s"};var normalize=function normalize(word){var a="a";if(word.match(/^(a|e|i|o)/)){a="an"}return a+" "+word};var actions=["noun","a_noun","nouns","adjective","an_adjective"];var generator={noun:function noun(){return rand(_nouns)},a_noun:function a_noun(){return normalize(rand(_nouns))},nouns:function nouns(){return pluralize(rand(_nouns))},adjective:function adjective(){return rand(adjectives)},an_adjective:function an_adjective(){return normalize(rand(adjectives))}};var trim=function trim(s){return s.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").replace(/\r?\n|\r/g," ").replace(/\s\s+|\r/g," ")};var make=function make(template){var sentence=template;var occurrences=template.match(/\{\{(.+?)\}\}/g);if(occurrences&&occurrences.length){for(var i=0;i<occurrences.length;i++){var action=trim(occurrences[i].replace("{{","").replace("}}",""));var result=void 0;if(actions.includes(action)){result=generator[action]()}sentence=sentence.replace(occurrences[i],result)}}return sentence};var randomStartingPhrase=function randomStartingPhrase(){if(Math.random()<.33){return rand(phrases)}return""};var makeSentenceFromTemplate=function makeSentenceFromTemplate(){return make(rand(sentenceTemplates))};var makeSentence=function makeSentence(){var phrase=randomStartingPhrase();var s=phrase+makeSentenceFromTemplate();s=s.charAt(0).toUpperCase()+s.slice(1);s+=pickLastPunc();return s};var makeParagraph=function makeParagraph(){var len=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;if(!len){len=random(3,10)}var t=Math.min(len,15);var a=[];while(a.length<t){var s=makeSentence();a.push(s)}return a.join(" ")};var makeArticle=function makeArticle(){var len=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;if(!len){len=random(3,10)}var t=Math.min(len,15);var a=[];while(a.length<t){var s=makeParagraph();a.push(s)}return a.join("\n\n")};return{sentence:makeSentence,paragraph:makeParagraph,article:makeArticle,addNouns:addNouns,addAdjectives:addAdjectives,addTemplates:addTemplates}}));
{
"version": "1.0.7",
"version": "1.0.8",
"name": "txtgen",

@@ -25,3 +25,3 @@ "description": "Util for generating random sentences, paragraphs and articles in English",

"coveralls": "npm test && cat ./coverage/lcov.info | coveralls",
"build": "gccmin src dist"
"build": "gccmin"
},

@@ -40,2 +40,8 @@ "devDependencies": {

},
"gccmin": {
"source": "src",
"target": "dist",
"filename": "txtgen",
"globalVar": "txtgen"
},
"keywords": [

@@ -42,0 +48,0 @@ "text",

@@ -26,7 +26,5 @@ # txtgen

[txtgen.min.js](https://cdn.rawgit.com/ndaidong/txtgen/master/dist/txtgen.min.js)
- [txtgen.js](https://cdn.rawgit.com/ndaidong/txtgen/master/dist/txtgen.js)
- [txtgen.min.js](https://cdn.rawgit.com/ndaidong/txtgen/master/dist/txtgen.min.js)
```
<script type="text/javascript" src="https://cdn.rawgit.com/ndaidong/txtgen/master/dist/txtgen.min.js"></script>
```

@@ -33,0 +31,0 @@ - This library also supports ES6 Module, AMD and UMD style.

@@ -6,259 +6,245 @@ /**

((name, factory) => {
if (typeof module !== 'undefined' && module.exports) {
module.exports = factory();
} else {
let root = window || {};
if (root.define && root.define.amd) {
root.define([], factory);
} else if (root.exports) {
root.exports = factory();
} else {
root[name] = factory();
}
}
})('txtgen', () => { // eslint-disable-line no-invalid-this
/* eslint-disable */
var nouns = [ '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' ];
var adjectives = [ 'adaptable', 'adventurous', 'affable', 'affectionate', 'agreeable', 'alert', 'alluring', 'ambitious', 'ambitious', 'amiable', 'amicable', 'amused', 'amusing', 'boundless', 'brave', 'brave', 'bright', 'bright', 'broad-minded', 'calm', 'calm', 'capable', 'careful', 'charming', 'charming', 'cheerful', 'coherent', 'comfortable', 'communicative', 'compassionate', 'confident', 'conscientious', 'considerate', 'convivial', 'cooperative', 'courageous', 'courageous', 'courteous', 'creative', 'credible', 'cultured', 'dashing', 'dazzling', 'debonair', 'decisive', 'decisive', 'decorous', 'delightful', 'detailed', 'determined', 'determined', 'diligent', 'diligent', 'diplomatic', 'discreet', 'discreet', 'dynamic', 'dynamic', 'eager', 'easygoing', 'efficient', 'elated', 'eminent', 'emotional', 'enchanting', 'encouraging', 'endurable', 'energetic', 'energetic', 'entertaining', 'enthusiastic', 'enthusiastic', 'excellent', 'excited', 'exclusive', 'exuberant', 'exuberant', 'fabulous', 'fair', 'fair-minded', 'faithful', 'faithful', 'fantastic', 'fearless', 'fearless', 'fine', 'forceful', 'frank', 'frank', 'friendly', 'friendly', 'funny', 'funny', 'generous', 'generous', 'gentle', 'gentle', 'glorious', 'good', 'good', 'gregarious', 'happy', 'hard-working', 'harmonious', 'helpful', 'helpful', 'hilarious', 'honest', 'honorable', 'humorous', 'imaginative', 'impartial', 'impartial', 'independent', 'industrious', 'instinctive', 'intellectual', 'intelligent', 'intuitive', 'inventive', 'jolly', 'joyous', 'kind', 'kind', 'kind-hearted', 'knowledgeable', 'level', 'likeable', 'lively', 'lovely', 'loving', 'loving', 'loyal', 'lucky', 'mature', 'modern', 'modest', 'neat', 'nice', 'nice', 'obedient', 'optimistic', 'painstaking', 'passionate', 'patient', 'peaceful', 'perfect', 'persistent', 'philosophical', 'pioneering', 'placid', 'placid', 'plausible', 'pleasant', 'plucky', 'plucky', 'polite', 'powerful', 'practical', 'pro-active', 'productive', 'protective', 'proud', 'punctual', 'quick-witted', 'quiet', 'quiet', 'rational', 'receptive', 'reflective', 'reliable', 'relieved', 'reserved', 'resolute', 'resourceful', 'responsible', 'rhetorical', 'righteous', 'romantic', 'romantic', 'sedate', 'seemly', 'selective', 'self-assured', 'self-confident', 'self-disciplined', 'sensible', 'sensitive', 'sensitive', 'shrewd', 'shy', 'silly', 'sincere', 'sincere', 'skillful', 'smiling', 'sociable', 'splendid', 'steadfast', 'stimulating', 'straightforward', 'successful', 'succinct', 'sympathetic', 'talented', 'thoughtful', 'thoughtful', 'thrifty', 'tidy', 'tough', 'tough', 'trustworthy', 'unassuming', 'unbiased', 'understanding', 'unusual', 'upbeat', 'versatile', 'vigorous', 'vivacious', 'warm', 'warmhearted', 'willing', 'willing', 'wise', 'witty', 'witty', 'wonderful' ];
/* eslint-disable */
var nouns = [ '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' ];
var adjectives = [ 'adaptable', 'adventurous', 'affable', 'affectionate', 'agreeable', 'alert', 'alluring', 'ambitious', 'ambitious', 'amiable', 'amicable', 'amused', 'amusing', 'boundless', 'brave', 'brave', 'bright', 'bright', 'broad-minded', 'calm', 'calm', 'capable', 'careful', 'charming', 'charming', 'cheerful', 'coherent', 'comfortable', 'communicative', 'compassionate', 'confident', 'conscientious', 'considerate', 'convivial', 'cooperative', 'courageous', 'courageous', 'courteous', 'creative', 'credible', 'cultured', 'dashing', 'dazzling', 'debonair', 'decisive', 'decisive', 'decorous', 'delightful', 'detailed', 'determined', 'determined', 'diligent', 'diligent', 'diplomatic', 'discreet', 'discreet', 'dynamic', 'dynamic', 'eager', 'easygoing', 'efficient', 'elated', 'eminent', 'emotional', 'enchanting', 'encouraging', 'endurable', 'energetic', 'energetic', 'entertaining', 'enthusiastic', 'enthusiastic', 'excellent', 'excited', 'exclusive', 'exuberant', 'exuberant', 'fabulous', 'fair', 'fair-minded', 'faithful', 'faithful', 'fantastic', 'fearless', 'fearless', 'fine', 'forceful', 'frank', 'frank', 'friendly', 'friendly', 'funny', 'funny', 'generous', 'generous', 'gentle', 'gentle', 'glorious', 'good', 'good', 'gregarious', 'happy', 'hard-working', 'harmonious', 'helpful', 'helpful', 'hilarious', 'honest', 'honorable', 'humorous', 'imaginative', 'impartial', 'impartial', 'independent', 'industrious', 'instinctive', 'intellectual', 'intelligent', 'intuitive', 'inventive', 'jolly', 'joyous', 'kind', 'kind', 'kind-hearted', 'knowledgeable', 'level', 'likeable', 'lively', 'lovely', 'loving', 'loving', 'loyal', 'lucky', 'mature', 'modern', 'modest', 'neat', 'nice', 'nice', 'obedient', 'optimistic', 'painstaking', 'passionate', 'patient', 'peaceful', 'perfect', 'persistent', 'philosophical', 'pioneering', 'placid', 'placid', 'plausible', 'pleasant', 'plucky', 'plucky', 'polite', 'powerful', 'practical', 'pro-active', 'productive', 'protective', 'proud', 'punctual', 'quick-witted', 'quiet', 'quiet', 'rational', 'receptive', 'reflective', 'reliable', 'relieved', 'reserved', 'resolute', 'resourceful', 'responsible', 'rhetorical', 'righteous', 'romantic', 'romantic', 'sedate', 'seemly', 'selective', 'self-assured', 'self-confident', 'self-disciplined', 'sensible', 'sensitive', 'sensitive', 'shrewd', 'shy', 'silly', 'sincere', 'sincere', 'skillful', 'smiling', 'sociable', 'splendid', 'steadfast', 'stimulating', 'straightforward', 'successful', 'succinct', 'sympathetic', 'talented', 'thoughtful', 'thoughtful', 'thrifty', 'tidy', 'tough', 'tough', 'trustworthy', 'unassuming', 'unbiased', 'understanding', 'unusual', 'upbeat', 'versatile', 'vigorous', 'vivacious', 'warm', 'warmhearted', 'willing', 'willing', 'wise', 'witty', 'witty', 'wonderful' ];
var vowels = [
'a', 'e', 'i', 'o', 'u', 'y'
];
var vowels = [
'a', 'e', 'i', 'o', 'u', 'y'
];
var sentenceTemplates = [
'the {{noun}} is {{a_noun}}',
'{{a_noun}} is {{an_adjective}} {{noun}}',
'the first {{adjective}} {{noun}} is, in its own way, {{a_noun}}',
'their {{noun}} was, in this moment, {{an_adjective}} {{noun}}',
'{{a_noun}} is {{a_noun}} from the right perspective',
'the literature would have us believe that {{an_adjective}} {{noun}} is not but {{a_noun}}',
'{{an_adjective}} {{noun}} is {{a_noun}} of the mind',
'the {{adjective}} {{noun}} reveals itself as {{an_adjective}} {{noun}} to those who look',
'authors often misinterpret the {{noun}} as {{an_adjective}} {{noun}}, when in actuality it feels more like {{an_adjective}} {{noun}}',
'we can assume that any instance of {{a_noun}} can be construed as {{an_adjective}} {{noun}}',
'they were lost without the {{adjective}} {{noun}} that composed their {{noun}}',
'the {{adjective}} {{noun}} comes from {{an_adjective}} {{noun}}',
'{{a_noun}} can hardly be considered {{an_adjective}} {{noun}} without also being {{a_noun}}',
'few can name {{an_adjective}} {{noun}} that isn\'t {{an_adjective}} {{noun}}',
'some posit the {{adjective}} {{noun}} to be less than {{adjective}}',
'{{a_noun}} of the {{noun}} is assumed to be {{an_adjective}} {{noun}}',
'{{a_noun}} sees {{a_noun}} as {{an_adjective}} {{noun}}',
'the {{noun}} of {{a_noun}} becomes {{an_adjective}} {{noun}}',
'{{a_noun}} is {{a_noun}}\'s {{noun}}',
'{{a_noun}} is the {{noun}} of {{a_noun}}',
'{{an_adjective}} {{noun}}\'s {{noun}} comes with it the thought that the {{adjective}} {{noun}} is {{a_noun}}',
'{{nouns}} are {{adjective}} {{nouns}}',
'{{adjective}} {{nouns}} show us how {{nouns}} can be {{nouns}}',
'before {{nouns}}, {{nouns}} were only {{nouns}}',
'those {{nouns}} are nothing more than {{nouns}}',
'some {{adjective}} {{nouns}} are thought of simply as {{nouns}}',
'one cannot separate {{nouns}} from {{adjective}} {{nouns}}',
'the {{nouns}} could be said to resemble {{adjective}} {{nouns}}',
'{{an_adjective}} {{noun}} without {{nouns}} is truly a {{noun}} of {{adjective}} {{nouns}}'
];
var sentenceTemplates = [
'the {{noun}} is {{a_noun}}',
'{{a_noun}} is {{an_adjective}} {{noun}}',
'the first {{adjective}} {{noun}} is, in its own way, {{a_noun}}',
'their {{noun}} was, in this moment, {{an_adjective}} {{noun}}',
'{{a_noun}} is {{a_noun}} from the right perspective',
'the literature would have us believe that {{an_adjective}} {{noun}} is not but {{a_noun}}',
'{{an_adjective}} {{noun}} is {{a_noun}} of the mind',
'the {{adjective}} {{noun}} reveals itself as {{an_adjective}} {{noun}} to those who look',
'authors often misinterpret the {{noun}} as {{an_adjective}} {{noun}}, when in actuality it feels more like {{an_adjective}} {{noun}}',
'we can assume that any instance of {{a_noun}} can be construed as {{an_adjective}} {{noun}}',
'they were lost without the {{adjective}} {{noun}} that composed their {{noun}}',
'the {{adjective}} {{noun}} comes from {{an_adjective}} {{noun}}',
'{{a_noun}} can hardly be considered {{an_adjective}} {{noun}} without also being {{a_noun}}',
'few can name {{an_adjective}} {{noun}} that isn\'t {{an_adjective}} {{noun}}',
'some posit the {{adjective}} {{noun}} to be less than {{adjective}}',
'{{a_noun}} of the {{noun}} is assumed to be {{an_adjective}} {{noun}}',
'{{a_noun}} sees {{a_noun}} as {{an_adjective}} {{noun}}',
'the {{noun}} of {{a_noun}} becomes {{an_adjective}} {{noun}}',
'{{a_noun}} is {{a_noun}}\'s {{noun}}',
'{{a_noun}} is the {{noun}} of {{a_noun}}',
'{{an_adjective}} {{noun}}\'s {{noun}} comes with it the thought that the {{adjective}} {{noun}} is {{a_noun}}',
'{{nouns}} are {{adjective}} {{nouns}}',
'{{adjective}} {{nouns}} show us how {{nouns}} can be {{nouns}}',
'before {{nouns}}, {{nouns}} were only {{nouns}}',
'those {{nouns}} are nothing more than {{nouns}}',
'some {{adjective}} {{nouns}} are thought of simply as {{nouns}}',
'one cannot separate {{nouns}} from {{adjective}} {{nouns}}',
'the {{nouns}} could be said to resemble {{adjective}} {{nouns}}',
'{{an_adjective}} {{noun}} without {{nouns}} is truly a {{noun}} of {{adjective}} {{nouns}}'
];
var phrases = [
'to be more specific, ',
'in recent years, ',
'however, ',
'by the way',
'of course, ',
'some assert that ',
'if this was somewhat unclear, ',
'unfortunately, that is wrong; on the contrary, ',
'it\'s very tricky, if not impossible, ',
'this could be, or perhaps ',
'this is not to discredit the idea that ',
'we know that ',
'it\'s an undeniable fact, really; ',
'framed in a different way, ',
'what we don\'t know for sure is whether or not ',
'as far as we can estimate, ',
'as far as he is concerned, ',
'the zeitgeist contends that ',
'though we assume the latter, ',
'far from the truth, ',
'extending this logic, ',
'nowhere is it disputed that ',
'in modern times ',
'in ancient times ',
'recent controversy aside, ',
'washing and polishing the car,',
'having been a gymnast, ',
'after a long day at school and work, ',
'waking to the buzz of the alarm clock, ',
'draped neatly on a hanger, ',
'shouting with happiness, '
];
/* eslint-enable */
var phrases = [
'to be more specific, ',
'in recent years, ',
'however, ',
'by the way',
'of course, ',
'some assert that ',
'if this was somewhat unclear, ',
'unfortunately, that is wrong; on the contrary, ',
'it\'s very tricky, if not impossible, ',
'this could be, or perhaps ',
'this is not to discredit the idea that ',
'we know that ',
'it\'s an undeniable fact, really; ',
'framed in a different way, ',
'what we don\'t know for sure is whether or not ',
'as far as we can estimate, ',
'as far as he is concerned, ',
'the zeitgeist contends that ',
'though we assume the latter, ',
'far from the truth, ',
'extending this logic, ',
'nowhere is it disputed that ',
'in modern times ',
'in ancient times ',
'recent controversy aside, ',
'washing and polishing the car,',
'having been a gymnast, ',
'after a long day at school and work, ',
'waking to the buzz of the alarm clock, ',
'draped neatly on a hanger, ',
'shouting with happiness, '
];
/* eslint-enable */
var unique = (a) => {
let r = [];
for (let i = 0; i < a.length; i++) {
if (r.indexOf(a[i]) === -1) {
r.push(a[i]);
}
var unique = (a) => {
let r = [];
for (let i = 0; i < a.length; i++) {
if (r.indexOf(a[i]) === -1) {
r.push(a[i]);
}
return r;
};
}
return r;
};
var addNouns = (ls = []) => {
let a = nouns.concat(ls);
nouns = unique(a);
return nouns.length;
};
var addNouns = (ls = []) => {
let a = nouns.concat(ls);
nouns = unique(a);
return nouns.length;
};
var addAdjectives = (ls) => {
let a = adjectives.concat(ls);
adjectives = unique(a);
return adjectives.length;
};
var addAdjectives = (ls) => {
let a = adjectives.concat(ls);
adjectives = unique(a);
return adjectives.length;
};
var addTemplates = (ls) => {
let a = sentenceTemplates.concat(ls);
sentenceTemplates = unique(a);
return sentenceTemplates.length;
};
var addTemplates = (ls) => {
let a = sentenceTemplates.concat(ls);
sentenceTemplates = unique(a);
return sentenceTemplates.length;
};
var random = (min, max) => {
let offset = min;
let range = max - min + 1;
let rd = Math.floor(Math.random() * range) + offset;
return rd;
};
var random = (min, max) => {
let offset = min;
let range = max - min + 1;
let rd = Math.floor(Math.random() * range) + offset;
return rd;
};
var rand = (a) => {
let w;
while (!w) {
w = a[random(0, a.length - 1)];
}
return w;
};
var rand = (a) => {
let w;
while (!w) {
w = a[random(0, a.length - 1)];
}
return w;
};
var pickLastPunc = () => {
let a = '.......!?!?;...'.split('');
return rand(a);
};
var pickLastPunc = () => {
let a = '.......!?!?;...'.split('');
return rand(a);
};
var pluralize = (word) => {
if (word.endsWith('s')) {
return word;
}
if (word.match(/(ss|ish|ch|x|us)$/)) {
word += 'e';
} else if (word.endsWith('y') && !vowels.includes(word.charAt(word.length - 2))) {
word = word.slice(0, word.length - 1);
word += 'ie';
}
return word + 's';
};
var pluralize = (word) => {
if (word.endsWith('s')) {
return word;
}
if (word.match(/(ss|ish|ch|x|us)$/)) {
word += 'e';
} else if (word.endsWith('y') && !vowels.includes(word.charAt(word.length - 2))) {
word = word.slice(0, word.length - 1);
word += 'ie';
}
return word + 's';
};
var normalize = (word) => {
let a = 'a';
if (word.match(/^(a|e|i|o)/)) {
a = 'an';
}
return `${a} ${word}`;
};
var normalize = (word) => {
let a = 'a';
if (word.match(/^(a|e|i|o)/)) {
a = 'an';
}
return `${a} ${word}`;
};
var actions = [
'noun', 'a_noun', 'nouns',
'adjective', 'an_adjective'
];
var actions = [
'noun', 'a_noun', 'nouns',
'adjective', 'an_adjective'
];
var generator = {
noun: () => {
return rand(nouns);
},
a_noun: () => { // eslint-disable-line camelcase
return normalize(rand(nouns));
},
nouns: () => {
return pluralize(rand(nouns));
},
adjective: () => {
return rand(adjectives);
},
an_adjective: () => { // eslint-disable-line camelcase
return normalize(rand(adjectives));
}
};
var generator = {
noun: () => {
return rand(nouns);
},
a_noun: () => { // eslint-disable-line camelcase
return normalize(rand(nouns));
},
nouns: () => {
return pluralize(rand(nouns));
},
adjective: () => {
return rand(adjectives);
},
an_adjective: () => { // eslint-disable-line camelcase
return normalize(rand(adjectives));
}
};
var trim = (s) => {
let x = s.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
return x.replace(/\r?\n|\r/g, ' ').replace(/\s\s+|\r/g, ' ');
};
var trim = (s) => {
return s.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '')
.replace(/\r?\n|\r/g, ' ')
.replace(/\s\s+|\r/g, ' ');
};
var make = (template) => {
let sentence = template;
let occurrences = template.match(/\{\{(.+?)\}\}/g);
var make = (template) => {
let sentence = template;
let occurrences = template.match(/\{\{(.+?)\}\}/g);
if (occurrences && occurrences.length) {
for (let i = 0; i < occurrences.length; i++) {
let action = trim(occurrences[i].replace('{{', '').replace('}}', ''));
let result;
if (actions.includes(action)) {
result = generator[action]();
}
sentence = sentence.replace(occurrences[i], result);
if (occurrences && occurrences.length) {
for (let i = 0; i < occurrences.length; i++) {
let action = trim(occurrences[i].replace('{{', '').replace('}}', ''));
let result;
if (actions.includes(action)) {
result = generator[action]();
}
sentence = sentence.replace(occurrences[i], result);
}
return sentence;
};
}
return sentence;
};
var randomStartingPhrase = () => {
if (Math.random() < 0.33) {
return rand(phrases);
}
return '';
};
var randomStartingPhrase = () => {
if (Math.random() < 0.33) {
return rand(phrases);
}
return '';
};
var makeSentenceFromTemplate = () => {
return make(rand(sentenceTemplates));
};
var makeSentenceFromTemplate = () => {
return make(rand(sentenceTemplates));
};
var makeSentence = () => {
let phrase = randomStartingPhrase();
let s = phrase + makeSentenceFromTemplate();
s = s.charAt(0).toUpperCase() + s.slice(1);
s += pickLastPunc();
return s;
};
var makeSentence = () => {
let phrase = randomStartingPhrase();
let s = phrase + makeSentenceFromTemplate();
s = s.charAt(0).toUpperCase() + s.slice(1);
s += pickLastPunc();
return s;
};
var makeParagraph = (len = 0) => {
if (!len) {
len = random(3, 10);
}
let t = Math.min(len, 15);
let a = [];
while (a.length < t) {
let s = makeSentence();
a.push(s);
}
return a.join(' ');
};
var makeParagraph = (len = 0) => {
if (!len) {
len = random(3, 10);
}
let t = Math.min(len, 15);
let a = [];
while (a.length < t) {
let s = makeSentence();
a.push(s);
}
return a.join(' ');
};
var makeArticle = (len = 0) => {
if (!len) {
len = random(3, 10);
}
let t = Math.min(len, 15);
let a = [];
while (a.length < t) {
let s = makeParagraph();
a.push(s);
}
return a.join('\n\n');
};
var makeArticle = (len = 0) => {
if (!len) {
len = random(3, 10);
}
let t = Math.min(len, 15);
let a = [];
while (a.length < t) {
let s = makeParagraph();
a.push(s);
}
return a.join('\n\n');
};
return {
sentence: makeSentence,
paragraph: makeParagraph,
article: makeArticle,
addNouns,
addAdjectives,
addTemplates
};
});
module.exports = {
sentence: makeSentence,
paragraph: makeParagraph,
article: makeArticle,
addNouns,
addAdjectives,
addTemplates
};
/**
* Check built-file to ensure it has been regenated
* Check built-files to ensure they have been regenated correctly
* @ndaidong

@@ -10,6 +10,6 @@ */

var pkgFake = require('../../package.json');
var proFile = './dist/txtgen.min.js';
var proFile = './dist/txtgen.js';
var devFile = './dist/txtgen.min.js';
test('Testing minified result', (assert) => {
test('Validate production output', (assert) => {
assert.ok(fs.existsSync(proFile), 'Production file must be generated');

@@ -30,1 +30,18 @@

});
test('Validate development output', (assert) => {
assert.ok(fs.existsSync(devFile), 'Development file must be generated');
let s = fs.readFileSync(devFile, 'utf8');
let a = s.split('\n');
assert.ok(s.length > 0 && a.length > 1, 'Development file must be not empty');
let cmt = a[0];
let pack = `${pkgFake.name}@${pkgFake.version}`;
assert.ok(cmt.includes(pack), 'Package must be presented with name and version');
let author = `${pkgFake.author}`;
assert.ok(cmt.includes(author), 'Package author must be correct');
let license = `${pkgFake.license}`;
assert.ok(cmt.includes(license), 'Package license must be correct');
assert.end();
});

@@ -13,2 +13,8 @@ /**

const LIMIT = 30;
var hasContent = (s) => {
return bella.isString(s) && s.length > 0;
};
var hasMethods = (o) => {

@@ -37,4 +43,6 @@ var structure = [

test('txtgen.sentence():', (assert) => {
let sentence = txtgen.sentence();
assert.ok(bella.isString(sentence) && sentence.length > 0, 'A sentence must be created');
for (let i = 0; i < LIMIT; i++) {
let sentence = txtgen.sentence();
assert.ok(hasContent(sentence), 'A sentence must be created');
}
assert.end();

@@ -44,4 +52,6 @@ });

test('txtgen.paragraph():', (assert) => {
let paragraph = txtgen.paragraph();
assert.ok(bella.isString(paragraph) && paragraph.length > 0, 'A paragraph must be created');
for (let i = 0; i < LIMIT; i++) {
let paragraph = txtgen.paragraph();
assert.ok(hasContent(paragraph), 'A paragraph must be created');
}
assert.end();

@@ -51,4 +61,6 @@ });

test('txtgen.article():', (assert) => {
let article = txtgen.article();
assert.ok(bella.isString(article) && article.length > 0, 'An article must be created');
for (let i = 0; i < LIMIT; i++) {
let article = txtgen.article();
assert.ok(hasContent(article), 'An article must be created');
}
assert.end();

@@ -64,5 +76,8 @@ });

'class',
'family'
'family',
'profile',
'glass',
'smile'
]);
assert.equals(count, 88, 'After adding 6 items => 88 nouns');
assert.equals(count, 91, 'After adding 9 items => 91 nouns');
assert.end();

@@ -69,0 +84,0 @@ });

Sorry, the diff of this file is not supported yet

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