vegan-ipsum
Version:
Generates passages of vegan-themed placeholder text suitable for use in web pages, graphics, and more. Works in the browser, NodeJS, and React Native.
4 lines • 4.65 kB
JavaScript
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`html`,t=`plain`,n=[e,t],r={POSIX:`
`,WIN32:`\r
`},i={DARWIN:`darwin`,LINUX:`linux`,WIN32:`win32`},a=`words`,o=`sentences`,s=`paragraphs`,c=`ad.adipisicing.aliqua.aliquip.amet.anim.aute.cillum.commodo.consectetur.consequat.culpa.cupidatat.deserunt.do.dolor.dolore.duis.ea.eiusmod.elit.enim.esse.est.et.eu.ex.excepteur.exercitation.fugiat.id.in.incididunt.ipsum.irure.labore.laboris.laborum.Lorem.magna.minim.mollit.nisi.non.nostrud.nulla.occaecat.officia.pariatur.proident.qui.quis.reprehenderit.sint.sit.sunt.tempor.ullamco.ut.velit.veniam.voluptate`.split(`.`),l=`plant.vegan.kindness.crueltyfree.herbivore.compassion.earth.dairyfree.justice.respect.peace.love.greens.fruit.vegetable.freedom.life.rights.sanctuary.nonviolence.care.conscious.ethics.climate.truth.plants.health.wholefood.clean.veggie.legumes.fiber.avocado.soy.tofu.tempeh.lentils.coconut.nutrients.plantpower.choices.saving.sustain.grain.beans.peas.quinoa.broccoli.kale.lettuce.radish.basil.mint.ginger.turmeric.natural.organic.kind`.split(`.`),u=`kindness.compassion.empathy.mercy.respect.gentleness.care.love.peace.justice.fairness.awareness.forgiveness.integrity.nonviolence.harmony.mindfulness.humility.patience.sincerity.tolerance.understanding.altruism.grace.generosity.helpfulness.selflessness.support.comfort.sympathy.warmth.charity.unity.positivity`.split(`.`),d=`tofu.tempeh.soymilk.almondmilk.oatmilk.vegan-burger.vegan-cheese.jackfruit.quinoa.bowl.lentil.soup.smoothie.nut.chia.pudding.granola.plant-based.vegan-yogurt.vegan-pizza.coconut.chickpea.curry.soba.noodles.pancake.avocado.toast.vegetable`.split(`.`),f=`broccoli.kale.spinach.lettuce.cabbage.beetroot.carrot.radish.turnip.cauliflower.zucchini.bell.pepper.cucumber.eggplant.okra.tomato.green.beans.peas.sweet.potato.pumpkin.asparagus.artichoke.brussels.sprouts.chard.fennel.leek.parsnip.celery.shallot.corn.bamboo.shoots.beet.greens.mustard.scallions.radicchio.snow.onion.squash`.split(`.`),p=Array.from(new Set([...c,...l,...u,...d,...f])),m=()=>typeof module<`u`&&!!module.exports,h=()=>{try{return navigator.product===`ReactNative`}catch{return!1}},g=()=>{try{return process.platform===i.WIN32}catch{return!1}},_=e=>{let t=e.trim();return t.charAt(0).toUpperCase()+t.slice(1)},v=(e=0)=>[...Array(e)].map((e,t)=>t),y=(e,t)=>v(e).map(()=>t()),b=class{sentencesPerParagraph;wordsPerSentence;random;words;constructor({sentencesPerParagraph:e={max:7,min:3},wordsPerSentence:t={max:15,min:5},random:n,words:r=p}={}){if(e.min>e.max)throw Error(`Minimum number of sentences per paragraph (${e.min}) cannot exceed maximum (${e.max}).`);if(t.min>t.max)throw Error(`Minimum number of words per sentence (${t.min}) cannot exceed maximum (${t.max}).`);this.sentencesPerParagraph=e,this.words=r,this.wordsPerSentence=t,this.random=n||Math.random}generateRandomInteger(e,t){return Math.floor(this.random()*(t-e+1)+e)}generateRandomWords(e){let{min:t,max:n}=this.wordsPerSentence;return v(e||this.generateRandomInteger(t,n)).reduce(e=>`${this.pluckRandomWord()} ${e}`,``).trim()}generateRandomSentence(e){return`${_(this.generateRandomWords(e))}.`}generateRandomParagraph(e){let{min:t,max:n}=this.sentencesPerParagraph;return v(e||this.generateRandomInteger(t,n)).reduce(e=>`${this.generateRandomSentence()} ${e}`,``).trim()}pluckRandomWord(){let e=this.words.length-1,t=this.generateRandomInteger(0,e);return this.words[t]}},x=class{format;suffix;generator;constructor(e={},r=t,i){if(this.format=r,this.suffix=i,n.indexOf(r.toLowerCase())===-1)throw Error(`${r} is an invalid format. Please use ${n.join(` or `)}.`);this.generator=new b(e),this.suffix=i}getLineEnding(){return this.suffix?this.suffix:!h()&&m()&&g()?r.WIN32:r.POSIX}formatString(e){return this.format===`html`?`<p>${e}</p>`:e}formatStrings(e){return e.map(e=>this.formatString(e))}generateWords(e){return this.formatString(this.generator.generateRandomWords(e))}generateSentences(e){return this.formatString(this.generator.generateRandomParagraph(e))}generateParagraphs(e){let t=this.generator.generateRandomParagraph.bind(this.generator);return this.formatStrings(y(e,t)).join(this.getLineEnding())}},S=({count:e=1,random:n,format:r=t,paragraphLowerBound:i=3,paragraphUpperBound:c=7,sentenceLowerBound:l=5,sentenceUpperBound:u=15,units:d=o,words:f=p,suffix:m=``}={})=>{let h=new x({random:n,sentencesPerParagraph:{max:c,min:i},words:f,wordsPerSentence:{max:u,min:l}},r,m);switch(d){case s:return h.generateParagraphs(e);case o:return h.generateSentences(e);case a:return h.generateWords(e);default:return``}};exports.VeganIpsum=x,exports.veganIpsum=S;
//# sourceMappingURL=index.cjs.map