tiny-essentials 1.27.1 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/changelog/1/28/0.md +16 -0
- package/changelog/1/28/1.md +23 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyAnalogClock.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -2
- package/dist/v1/TinyDayNightCycle.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyElementObserver.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -2
- package/dist/v1/TinyGamepad.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyI18.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextDiffer.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -2
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/basics/array.cjs +57 -9
- package/dist/v1/basics/array.d.mts +27 -11
- package/dist/v1/basics/array.mjs +51 -9
- package/dist/v1/basics/clock.cjs +94 -42
- package/dist/v1/basics/clock.d.mts +10 -10
- package/dist/v1/basics/clock.mjs +91 -54
- package/dist/v1/basics/deprecated/html.cjs +246 -0
- package/dist/v1/basics/deprecated/html.d.mts +63 -0
- package/dist/v1/basics/deprecated/html.mjs +190 -0
- package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
- package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
- package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
- package/dist/v1/basics/html.cjs +149 -130
- package/dist/v1/basics/html.d.mts +26 -61
- package/dist/v1/basics/html.mjs +113 -105
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/mediaContent.cjs +51 -9
- package/dist/v1/basics/mediaContent.d.mts +0 -87
- package/dist/v1/basics/mediaContent.mjs +40 -10
- package/dist/v1/basics/objChecker.cjs +7 -5
- package/dist/v1/basics/objChecker.d.mts +3 -2
- package/dist/v1/basics/objChecker.mjs +6 -6
- package/dist/v1/basics/objFilter.cjs +40 -18
- package/dist/v1/basics/objFilter.d.mts +6 -6
- package/dist/v1/basics/objFilter.mjs +32 -17
- package/dist/v1/basics/simpleMath.cjs +81 -25
- package/dist/v1/basics/simpleMath.d.mts +2 -2
- package/dist/v1/basics/simpleMath.mjs +70 -27
- package/dist/v1/basics/text.cjs +76 -31
- package/dist/v1/basics/text.d.mts +69 -7
- package/dist/v1/basics/text.mjs +62 -31
- package/dist/v1/index.cjs +4 -2
- package/dist/v1/index.d.mts +4 -2
- package/dist/v1/index.mjs +4 -4
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +71 -255
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +6 -134
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +69 -228
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
- package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
- package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
- package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
- package/dist/v1/libs/TinyClipboard.cjs +2 -0
- package/dist/v1/libs/TinyClipboard.d.mts +4 -2
- package/dist/v1/libs/TinyClipboard.mjs +2 -0
- package/dist/v1/libs/TinyColorConverter.cjs +1 -0
- package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
- package/dist/v1/libs/TinyColorConverter.mjs +1 -0
- package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
- package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
- package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
- package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
- package/dist/v1/libs/TinyDragger.cjs +46 -19
- package/dist/v1/libs/TinyDragger.mjs +45 -18
- package/dist/v1/libs/TinyElementObserver.cjs +39 -0
- package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
- package/dist/v1/libs/TinyElementObserver.mjs +36 -0
- package/dist/v1/libs/TinyGamepad.cjs +131 -1
- package/dist/v1/libs/TinyGamepad.mjs +129 -1
- package/dist/v1/libs/TinyHtml.cjs +1 -1
- package/dist/v1/libs/TinyHtml.mjs +2 -2
- package/dist/v1/libs/TinyI18.cjs +61 -0
- package/dist/v1/libs/TinyI18.d.mts +14 -0
- package/dist/v1/libs/TinyI18.mjs +55 -0
- package/dist/v1/libs/TinyIframeEvents.cjs +26 -196
- package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
- package/dist/v1/libs/TinyIframeEvents.mjs +26 -171
- package/dist/v1/libs/TinyLocalStorage.cjs +53 -205
- package/dist/v1/libs/TinyLocalStorage.d.mts +6 -127
- package/dist/v1/libs/TinyLocalStorage.mjs +50 -178
- package/dist/v1/libs/TinyMediaPlayer.cjs +74 -2
- package/dist/v1/libs/TinyMediaPlayer.d.mts +12 -2
- package/dist/v1/libs/TinyMediaPlayer.mjs +68 -2
- package/dist/v1/libs/TinyNewWinEvents.cjs +39 -197
- package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -119
- package/dist/v1/libs/TinyNewWinEvents.mjs +36 -172
- package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
- package/dist/v1/libs/TinyRadioFm.cjs +40 -3
- package/dist/v1/libs/TinyRadioFm.d.mts +3 -3
- package/dist/v1/libs/TinyRadioFm.mjs +37 -3
- package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
- package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
- package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
- package/dist/v1/libs/TinySmartScroller.cjs +56 -205
- package/dist/v1/libs/TinySmartScroller.d.mts +19 -152
- package/dist/v1/libs/TinySmartScroller.mjs +55 -181
- package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
- package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
- package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
- package/dist/v1/libs/TinyTextarea.cjs +19 -0
- package/dist/v1/libs/TinyTextarea.d.mts +6 -0
- package/dist/v1/libs/TinyTextarea.mjs +17 -0
- package/dist/v1/libs/TinyTimeout.cjs +11 -1
- package/dist/v1/libs/TinyTimeout.mjs +9 -1
- package/dist/v1/libs/TinyToastNotify.cjs +35 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
- package/dist/v1/libs/TinyToastNotify.mjs +31 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +20 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
- package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
- package/dist/v1/libs/utils.cjs +21 -0
- package/dist/v1/libs/utils.d.mts +2 -0
- package/dist/v1/libs/utils.mjs +16 -0
- package/docs/v1/Exports.md +0 -1
- package/docs/v1/README.md +1 -1
- package/docs/v1/basics/array.md +2 -2
- package/docs/v1/basics/deprecated/html.md +17 -0
- package/docs/v1/basics/fullScreen.md +1 -1
- package/docs/v1/basics/html.md +12 -26
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +1 -1
- package/docs/v1/basics/objFilter.md +1 -1
- package/docs/v1/basics/text.md +2 -2
- package/docs/v1/fileManager/main.md +1 -1
- package/docs/v1/libs/ColorSafeStringify.md +1 -1
- package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
- package/docs/v1/libs/TinyAnalogClock.md +1 -1
- package/docs/v1/libs/TinyArrayComparator.md +1 -1
- package/docs/v1/libs/TinyArrayPaginator.md +1 -1
- package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
- package/docs/v1/libs/TinyClassManager.md +1 -1
- package/docs/v1/libs/TinyClipboard.md +1 -1
- package/docs/v1/libs/TinyCookieConsent.md +1 -1
- package/docs/v1/libs/TinyDomReadyManager.md +1 -1
- package/docs/v1/libs/TinyDragDropDetector.md +1 -1
- package/docs/v1/libs/TinyDragger.md +1 -1
- package/docs/v1/libs/TinyElementObserver.md +1 -1
- package/docs/v1/libs/TinyHtml.md +1 -1
- package/docs/v1/libs/TinyIframeEvents.md +10 -10
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyLoadingScreen.md +1 -1
- package/docs/v1/libs/TinyLocalStorage.md +3 -3
- package/docs/v1/libs/TinyNewWinEvents.md +10 -11
- package/docs/v1/libs/TinyNotifications.md +1 -1
- package/docs/v1/libs/TinyPromiseQueue.md +2 -2
- package/docs/v1/libs/TinyTextDiffer.md +1 -1
- package/docs/v1/libs/TinyTextarea.md +1 -1
- package/package.json +15 -5
- package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
- package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
- package/dist/v1/TinyEvents.min.js +0 -1
- package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
- package/dist/v1/build/TinyEvents.cjs +0 -7
- package/dist/v1/build/TinyEvents.d.mts +0 -3
- package/dist/v1/build/TinyEvents.mjs +0 -2
- package/dist/v1/libs/TinyEvents.cjs +0 -395
- package/dist/v1/libs/TinyEvents.d.mts +0 -164
- package/dist/v1/libs/TinyEvents.mjs +0 -360
- package/docs/v1/libs/TinyEvents.md +0 -187
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(n,t)=>{if(Array.isArray(t))for(var a=0;a<t.length;){var o=t[a++],r=t[a++];e.o(n,o)?0===r&&a++:0===r?Object.defineProperty(n,o,{enumerable:!0,value:t[a++]}):Object.defineProperty(n,o,{enumerable:!0,get:r})}else for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)};let n={};e.d(n,{UltraRandomMsgGen:()=>u});const t=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],a=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],o=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],r=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],i=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],s=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class d{static#e=t;static#n=a;static#t=o;static#a=r;static#o=i;static#r=s;static#i(e,n){if(!Array.isArray(e))throw new TypeError(`${n} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${n} must contain only strings`);if(0===e.length)throw new Error(`${n} cannot be empty`)}static get defaultWords(){return[...this.#e]}static set defaultWords(e){this.#i(e,"defaultWords"),this.#e=[...e]}static get defaultEmojis(){return[...this.#n]}static set defaultEmojis(e){this.#i(e,"defaultEmojis"),this.#n=[...e]}static get defaultNouns(){return[...this.#t]}static set defaultNouns(e){this.#i(e,"defaultNouns"),this.#t=[...e]}static get defaultVerbs(){return[...this.#a]}static set defaultVerbs(e){this.#i(e,"defaultVerbs"),this.#a=[...e]}static get defaultAdjectives(){return[...this.#o]}static set defaultAdjectives(e){this.#i(e,"defaultAdjectives"),this.#o=[...e]}static get defaultTemplates(){return[...this.#r]}static set defaultTemplates(e){this.#i(e,"defaultTemplates"),this.#r=[...e]}config={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};constructor(e={}){this.symbols="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");const{minLength:n,maxLength:t,readable:a,useEmojis:o,includeNumbers:r,includeSymbols:i,allowWeirdSpacing:s,emojiSet:u,wordSet:h,mode:l,grammar:g,repeatWords:m,emojiPlacement:b,paragraphs:c,line:f}=e;if(void 0!==n&&(!Number.isInteger(n)||n<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==n&&void 0!==t&&n>t)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.readable must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==h&&!Array.isArray(h))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==l&&!["mixed","readable","chaotic","natural"].includes(l))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==g){if("object"!=typeof g||null===g)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:n,verbs:t,adjectives:a}=g;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==n&&!Array.isArray(n))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==a&&!Array.isArray(a))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==m&&"boolean"!=typeof m)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==b&&!["inline","end","none"].includes(b))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==c){if("object"!=typeof c)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:n}=c;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==n&&(!Number.isInteger(n)||n<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==n&&e>n)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:n,emojiChance:t}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==n&&(!Number.isInteger(n)||n<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==n&&e>n)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==t&&("number"!=typeof t||t<0||t>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.config.emojiSet=[...d.#n],this.config.wordSet=[...d.#e],this.config.grammar.templates=[...d.#r],this.config.grammar.nouns=[...d.#t],this.config.grammar.verbs=[...d.#a],this.config.grammar.adjectives=[...d.#o],Object.assign(this.config,e)}configure(e={}){return Object.assign(this.config,e),this}setGrammarTemplates(...e){return this.config.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return this.config.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return this.config.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return this.config.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return this.config.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return this.config.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return this.config.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return this.config.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){const n=new Set(e.flat());return this.config.grammar.templates=this.config.grammar.templates.filter(e=>!n.has(e)),this}removeGrammarNouns(...e){const n=new Set(e.flat());return this.config.grammar.nouns=this.config.grammar.nouns.filter(e=>!n.has(e)),this}removeGrammarVerbs(...e){const n=new Set(e.flat());return this.config.grammar.verbs=this.config.grammar.verbs.filter(e=>!n.has(e)),this}removeGrammarAdjectives(...e){const n=new Set(e.flat());return this.config.grammar.adjectives=this.config.grammar.adjectives.filter(e=>!n.has(e)),this}setWords(...e){return this.config.wordSet=e.flat(),this}addWords(...e){return this.config.wordSet.push(...e.flat()),this}removeWords(...e){const n=new Set(e.flat());return this.config.wordSet=this.config.wordSet.filter(e=>!n.has(e)),this}setEmojis(...e){return this.config.emojiSet=e.flat(),this}addEmojis(...e){return this.config.emojiSet.push(...e.flat()),this}removeEmojis(...e){const n=new Set(e.flat());return this.config.emojiSet=this.config.emojiSet.filter(e=>!n.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:n,includeNumbers:t,includeSymbols:a,useEmojis:o,readable:r,mode:i,emojiPlacement:s}=this.config;if("natural"===i)return this._generateNaturalSentence();const d=[];return(r||"readable"===i||"mixed"===i)&&d.push(this._getRandomItem(e)),"chaotic"!==i&&"mixed"!==i||d.push(Math.random().toString(36).slice(2)),t&&d.push(Math.floor(99999*Math.random()).toString()),a&&d.push(this._getRandomItem(this.symbols)),"inline"===s&&o&&n.length&&d.push(this._getRandomItem(n)),this._getRandomItem(d)}_generateNaturalSentence(){const{templates:e,nouns:n,verbs:t,adjectives:a}=this.config.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(n)).replace(/{verb}/g,()=>this._getRandomItem(t)).replace(/{adj}/g,()=>this._getRandomItem(a))}_generateLine(e,n){const{allowWeirdSpacing:t,repeatWords:a,readable:o,emojiSet:r,useEmojis:i,emojiPlacement:s,line:d}=this.config,u=[];for(n??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!a&&n.has(e)||(n.add(e),t&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let h=u.join(o?" ":"");return"end"===s&&i&&r.length&&Math.random()<(d?.emojiChance||0)&&(h+=" "+this._getRandomItem(r)),h}_generateParagraphLines(e){const{line:n}=this.config,t=[],a=new Set;let o=0;for(;o<e;){const r=Math.floor(Math.random()*(n.maxLength-n.minLength+1)+n.minLength),i=Math.min(r,e-o);t.push(this._generateLine(i,a)),o+=i}return t}generate(){const{minLength:e,maxLength:n,paragraphs:t}=this.config,a=Math.floor(Math.random()*(n-e+1))+e;if(t&&"object"==typeof t){const e=Math.floor(Math.random()*(t.max-t.min+1))+t.min,n=Math.floor(a/e),o=[];for(let t=0;t<e;t++){const e=this._generateParagraphLines(n);o.push(e.join("\n"))}return o.join("\n\n")}return this._generateParagraphLines(a).join("\n")}}const u=d;window.UltraRandomMsgGen=n.UltraRandomMsgGen})();
|
|
1
|
+
(()=>{"use strict";const e={d:(n,t)=>{if(Array.isArray(t))for(var a=0;a<t.length;){var o=t[a++],r=t[a++];e.o(n,o)?0===r&&a++:0===r?Object.defineProperty(n,o,{enumerable:!0,value:t[a++]}):Object.defineProperty(n,o,{enumerable:!0,get:r})}else for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)};let n={};e.d(n,{UltraRandomMsgGen:()=>h});const t=e=>{if(e)throw new Error("This UltraRandomMsgGen instance has been destroyed and can no longer be used.")};const a=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],o=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮","🍬","🍓","🍒","🥝","🥑","🍄","🌊","☁️","🌟","🌙","🧚","🐾","🐥","🐼","🐨","🐳","✨","🧁","🌸","🍃","💎","🎐","🎀","🫧","☄️","🛸","🔮"],r=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],i=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],s=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],d=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","In the glow of the {adj} moon, the {noun} began to {verb}.","A sprinkle of {adj} dust made the {noun} {verb} through the air.","The {noun} whispered a {adj} secret that made everyone {verb}.","Everything felt {adj} and {adj}, especially when the {noun} {verb}ed.","The {noun} is {verb}ing! The {noun} is {verb}ing! AAAAA!","Glitch in the {noun}: the {adj} {noun} just {verb}ed out of existence.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class u{static#e=a;static#n=o;static#t=r;static#a=i;static#o=s;static#r=d;static#i(e,n){if(!Array.isArray(e))throw new TypeError(`${n} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${n} must contain only strings`);if(0===e.length)throw new Error(`${n} cannot be empty`)}static get defaultWords(){return[...this.#e]}static set defaultWords(e){this.#i(e,"defaultWords"),this.#e=[...e]}static get defaultEmojis(){return[...this.#n]}static set defaultEmojis(e){this.#i(e,"defaultEmojis"),this.#n=[...e]}static get defaultNouns(){return[...this.#t]}static set defaultNouns(e){this.#i(e,"defaultNouns"),this.#t=[...e]}static get defaultVerbs(){return[...this.#a]}static set defaultVerbs(e){this.#i(e,"defaultVerbs"),this.#a=[...e]}static get defaultAdjectives(){return[...this.#o]}static set defaultAdjectives(e){this.#i(e,"defaultAdjectives"),this.#o=[...e]}static get defaultTemplates(){return[...this.#r]}static set defaultTemplates(e){this.#i(e,"defaultTemplates"),this.#r=[...e]}#s=!1;get destroyed(){return this.#s}#d={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};get config(){return t(this.#s),structuredClone(this.#d)}#u="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");get symbols(){return t(this.#s),structuredClone(this.#u)}constructor(e={}){const{minLength:n,maxLength:t,readable:a,useEmojis:o,includeNumbers:r,includeSymbols:i,allowWeirdSpacing:s,emojiSet:d,wordSet:h,mode:l,grammar:g,repeatWords:m,emojiPlacement:b,paragraphs:c,line:f}=e;if(void 0!==n&&(!Number.isInteger(n)||n<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==n&&void 0!==t&&n>t)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.readable must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==d&&!Array.isArray(d))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==h&&!Array.isArray(h))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==l&&!["mixed","readable","chaotic","natural"].includes(l))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==g){if("object"!=typeof g||null===g)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:n,verbs:t,adjectives:a}=g;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==n&&!Array.isArray(n))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==a&&!Array.isArray(a))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==m&&"boolean"!=typeof m)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==b&&!["inline","end","none"].includes(b))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==c){if("object"!=typeof c)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:n}=c;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==n&&(!Number.isInteger(n)||n<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==n&&e>n)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:n,emojiChance:t}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==n&&(!Number.isInteger(n)||n<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==n&&e>n)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==t&&("number"!=typeof t||t<0||t>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.#d.emojiSet=[...u.#n],this.#d.wordSet=[...u.#e],this.#d.grammar.templates=[...u.#r],this.#d.grammar.nouns=[...u.#t],this.#d.grammar.verbs=[...u.#a],this.#d.grammar.adjectives=[...u.#o],Object.assign(this.#d,e)}configure(e={}){return t(this.#s),Object.assign(this.#d,e),this}setGrammarTemplates(...e){return t(this.#s),this.#d.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return t(this.#s),this.#d.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return t(this.#s),this.#d.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return t(this.#s),this.#d.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return t(this.#s),this.#d.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return t(this.#s),this.#d.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return t(this.#s),this.#d.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return t(this.#s),this.#d.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){t(this.#s);const n=new Set(e.flat());return this.#d.grammar.templates=this.#d.grammar.templates.filter(e=>!n.has(e)),this}removeGrammarNouns(...e){t(this.#s);const n=new Set(e.flat());return this.#d.grammar.nouns=this.#d.grammar.nouns.filter(e=>!n.has(e)),this}removeGrammarVerbs(...e){t(this.#s);const n=new Set(e.flat());return this.#d.grammar.verbs=this.#d.grammar.verbs.filter(e=>!n.has(e)),this}removeGrammarAdjectives(...e){t(this.#s);const n=new Set(e.flat());return this.#d.grammar.adjectives=this.#d.grammar.adjectives.filter(e=>!n.has(e)),this}setWords(...e){return t(this.#s),this.#d.wordSet=e.flat(),this}addWords(...e){return t(this.#s),this.#d.wordSet.push(...e.flat()),this}removeWords(...e){t(this.#s);const n=new Set(e.flat());return this.#d.wordSet=this.#d.wordSet.filter(e=>!n.has(e)),this}setEmojis(...e){return t(this.#s),this.#d.emojiSet=e.flat(),this}addEmojis(...e){return t(this.#s),this.#d.emojiSet.push(...e.flat()),this}removeEmojis(...e){t(this.#s);const n=new Set(e.flat());return this.#d.emojiSet=this.#d.emojiSet.filter(e=>!n.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:n,includeNumbers:t,includeSymbols:a,useEmojis:o,readable:r,mode:i,emojiPlacement:s}=this.#d;if("natural"===i)return this._generateNaturalSentence();const d=[];return(r||"readable"===i||"mixed"===i)&&d.push(this._getRandomItem(e)),"chaotic"!==i&&"mixed"!==i||d.push(Math.random().toString(36).slice(2)),t&&d.push(Math.floor(99999*Math.random()).toString()),a&&d.push(this._getRandomItem(this.#u)),"inline"===s&&o&&n.length&&d.push(this._getRandomItem(n)),this._getRandomItem(d)}_generateNaturalSentence(){const{templates:e,nouns:n,verbs:t,adjectives:a}=this.#d.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(n)).replace(/{verb}/g,()=>this._getRandomItem(t)).replace(/{adj}/g,()=>this._getRandomItem(a))}_generateLine(e,n){const{allowWeirdSpacing:t,repeatWords:a,readable:o,emojiSet:r,useEmojis:i,emojiPlacement:s,line:d}=this.#d,u=[];for(n??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!a&&n.has(e)||(n.add(e),t&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let h=u.join(o?" ":"");return"end"===s&&i&&r.length&&Math.random()<(d?.emojiChance||0)&&(h+=" "+this._getRandomItem(r)),h}_generateParagraphLines(e){const{line:n}=this.#d,t=[],a=new Set;let o=0;for(;o<e;){const r=Math.floor(Math.random()*(n.maxLength-n.minLength+1)+n.minLength),i=Math.min(r,e-o);t.push(this._generateLine(i,a)),o+=i}return t}generate(){t(this.#s);const{minLength:e,maxLength:n,paragraphs:a}=this.#d,o=Math.floor(Math.random()*(n-e+1))+e;if(a&&"object"==typeof a){const e=Math.floor(Math.random()*(a.max-a.min+1))+a.min,n=Math.floor(o/e),t=[];for(let a=0;a<e;a++){const e=this._generateParagraphLines(n);t.push(e.join("\n"))}return t.join("\n\n")}return this._generateParagraphLines(o).join("\n")}destroy(){this.destroyed||(this.#u=[],this.#d.emojiSet=[],this.#d.wordSet=[],this.#d.grammar.templates=[],this.#d.grammar.nouns=[],this.#d.grammar.verbs=[],this.#d.grammar.adjectives=[],this.#s=!0)}}const h=u;window.UltraRandomMsgGen=n.UltraRandomMsgGen})();
|
package/dist/v1/basics/array.cjs
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* @returns {T} The same array instance, now shuffled in place.
|
|
14
14
|
*/
|
|
15
15
|
function shuffleArray(items) {
|
|
16
|
+
if (!Array.isArray(items)) {
|
|
17
|
+
throw new TypeError("Argument 'items' must be an array.");
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
let currentIndex = items.length,
|
|
17
21
|
randomIndex;
|
|
18
22
|
|
|
@@ -32,16 +36,29 @@ function shuffleArray(items) {
|
|
|
32
36
|
/**
|
|
33
37
|
* Generates an array with repeated phases according to counts.
|
|
34
38
|
*
|
|
35
|
-
* @
|
|
39
|
+
* @template {any} BlockValue
|
|
40
|
+
* @param {BlockValue[]} phases - Array of phase names, e.g., ['Full', 'Half1', 'Half2', 'New'].
|
|
36
41
|
* @param {number[]} counts - Array of integers specifying how many times to repeat each phase, e.g., [4,5,5,4].
|
|
37
|
-
* @returns {
|
|
42
|
+
* @returns {BlockValue[]} - Flattened array containing phases repeated according to counts, concatenated in order.
|
|
38
43
|
*/
|
|
39
44
|
function multiplyArrayBlocks(phases, counts) {
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
if (!Array.isArray(phases)) {
|
|
46
|
+
throw new TypeError("Argument 'phases' must be an array.");
|
|
47
|
+
}
|
|
48
|
+
if (!Array.isArray(counts)) {
|
|
49
|
+
throw new TypeError("Argument 'counts' must be an array.");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (phases.length !== counts.length) {
|
|
53
|
+
throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");
|
|
54
|
+
}
|
|
42
55
|
|
|
43
56
|
const result = [];
|
|
44
57
|
for (let i = 0; i < phases.length; i++) {
|
|
58
|
+
if (typeof counts[i] !== 'number' || Number.isNaN(counts[i])) {
|
|
59
|
+
throw new TypeError(`Element at counts[${i}] must be a valid number.`);
|
|
60
|
+
}
|
|
61
|
+
|
|
45
62
|
for (let j = 0; j < counts[i]; j++) {
|
|
46
63
|
result.push(phases[i]);
|
|
47
64
|
}
|
|
@@ -49,12 +66,28 @@ function multiplyArrayBlocks(phases, counts) {
|
|
|
49
66
|
return result;
|
|
50
67
|
}
|
|
51
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @template T
|
|
71
|
+
* @typedef {Object} DiffArrayListData
|
|
72
|
+
* @property {T[]} added - Items that only exist in the new array.
|
|
73
|
+
* @property {T[]} removed - Items that only existed in the old array.
|
|
74
|
+
*/
|
|
75
|
+
|
|
52
76
|
/**
|
|
53
77
|
* Diff two class lists.
|
|
54
|
-
* @
|
|
55
|
-
* @param {
|
|
78
|
+
* @template T
|
|
79
|
+
* @param {T[]} oldItems - The original/old array for comparison.
|
|
80
|
+
* @param {T[]} newItems - The new array for comparison.
|
|
81
|
+
* @returns {DiffArrayListData<T>} An object containing arrays of added and removed items.
|
|
56
82
|
*/
|
|
57
83
|
function diffArrayList(oldItems, newItems) {
|
|
84
|
+
if (!Array.isArray(oldItems)) {
|
|
85
|
+
throw new TypeError("Argument 'oldItems' must be an array.");
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(newItems)) {
|
|
88
|
+
throw new TypeError("Argument 'newItems' must be an array.");
|
|
89
|
+
}
|
|
90
|
+
|
|
58
91
|
const removed = oldItems.filter((c) => !newItems.includes(c));
|
|
59
92
|
const added = newItems.filter((c) => !oldItems.includes(c));
|
|
60
93
|
return { added, removed };
|
|
@@ -63,7 +96,7 @@ function diffArrayList(oldItems, newItems) {
|
|
|
63
96
|
/**
|
|
64
97
|
* Generates a comparator function to sort an array of objects by a given key.
|
|
65
98
|
*
|
|
66
|
-
* @param {string} item - The object key to sort by.
|
|
99
|
+
* @param {string|null} [item] - The object key to sort by.
|
|
67
100
|
* @param {boolean} [isReverse=false] - If `true`, the sorting will be in descending order.
|
|
68
101
|
* @returns {(a: Object<string|number, *>, b: Object<string|number, *>) => number} Comparator function compatible with Array.prototype.sort().
|
|
69
102
|
*
|
|
@@ -76,13 +109,28 @@ function diffArrayList(oldItems, newItems) {
|
|
|
76
109
|
* arr.sort(arraySortPositions('pos', true)); // Descending: [{pos: 3}, {pos: 2}, {pos: 1}]
|
|
77
110
|
*/
|
|
78
111
|
function arraySortPositions(item, isReverse = false) {
|
|
112
|
+
if (item !== undefined && item !== null && typeof item !== 'string') {
|
|
113
|
+
throw new TypeError("Argument 'item' must be a string or null.");
|
|
114
|
+
}
|
|
115
|
+
if (typeof isReverse !== 'boolean') {
|
|
116
|
+
throw new TypeError("Argument 'isReverse' must be a boolean.");
|
|
117
|
+
}
|
|
118
|
+
|
|
79
119
|
if (!isReverse) {
|
|
80
120
|
return function (a, b) {
|
|
81
|
-
return
|
|
121
|
+
return (item ? a[item] : a) < (item ? b[item] : b)
|
|
122
|
+
? -1
|
|
123
|
+
: (item ? a[item] : a) > (item ? b[item] : b)
|
|
124
|
+
? 1
|
|
125
|
+
: 0;
|
|
82
126
|
};
|
|
83
127
|
} else {
|
|
84
128
|
return function (a, b) {
|
|
85
|
-
return
|
|
129
|
+
return (item ? a[item] : a) > (item ? b[item] : b)
|
|
130
|
+
? -1
|
|
131
|
+
: (item ? a[item] : a) < (item ? b[item] : b)
|
|
132
|
+
? 1
|
|
133
|
+
: 0;
|
|
86
134
|
};
|
|
87
135
|
}
|
|
88
136
|
}
|
|
@@ -12,24 +12,30 @@ export function shuffleArray<T extends any[]>(items: T): T;
|
|
|
12
12
|
/**
|
|
13
13
|
* Generates an array with repeated phases according to counts.
|
|
14
14
|
*
|
|
15
|
-
* @
|
|
15
|
+
* @template {any} BlockValue
|
|
16
|
+
* @param {BlockValue[]} phases - Array of phase names, e.g., ['Full', 'Half1', 'Half2', 'New'].
|
|
16
17
|
* @param {number[]} counts - Array of integers specifying how many times to repeat each phase, e.g., [4,5,5,4].
|
|
17
|
-
* @returns {
|
|
18
|
+
* @returns {BlockValue[]} - Flattened array containing phases repeated according to counts, concatenated in order.
|
|
19
|
+
*/
|
|
20
|
+
export function multiplyArrayBlocks<BlockValue extends unknown>(phases: BlockValue[], counts: number[]): BlockValue[];
|
|
21
|
+
/**
|
|
22
|
+
* @template T
|
|
23
|
+
* @typedef {Object} DiffArrayListData
|
|
24
|
+
* @property {T[]} added - Items that only exist in the new array.
|
|
25
|
+
* @property {T[]} removed - Items that only existed in the old array.
|
|
18
26
|
*/
|
|
19
|
-
export function multiplyArrayBlocks(phases: any[], counts: number[]): any[];
|
|
20
27
|
/**
|
|
21
28
|
* Diff two class lists.
|
|
22
|
-
* @
|
|
23
|
-
* @param {
|
|
29
|
+
* @template T
|
|
30
|
+
* @param {T[]} oldItems - The original/old array for comparison.
|
|
31
|
+
* @param {T[]} newItems - The new array for comparison.
|
|
32
|
+
* @returns {DiffArrayListData<T>} An object containing arrays of added and removed items.
|
|
24
33
|
*/
|
|
25
|
-
export function diffArrayList(oldItems:
|
|
26
|
-
added: any[];
|
|
27
|
-
removed: any[];
|
|
28
|
-
};
|
|
34
|
+
export function diffArrayList<T>(oldItems: T[], newItems: T[]): DiffArrayListData<T>;
|
|
29
35
|
/**
|
|
30
36
|
* Generates a comparator function to sort an array of objects by a given key.
|
|
31
37
|
*
|
|
32
|
-
* @param {string} item - The object key to sort by.
|
|
38
|
+
* @param {string|null} [item] - The object key to sort by.
|
|
33
39
|
* @param {boolean} [isReverse=false] - If `true`, the sorting will be in descending order.
|
|
34
40
|
* @returns {(a: Object<string|number, *>, b: Object<string|number, *>) => number} Comparator function compatible with Array.prototype.sort().
|
|
35
41
|
*
|
|
@@ -41,5 +47,15 @@ export function diffArrayList(oldItems: any[], newItems: any[]): {
|
|
|
41
47
|
* const arr = [{ pos: 2 }, { pos: 1 }, { pos: 3 }];
|
|
42
48
|
* arr.sort(arraySortPositions('pos', true)); // Descending: [{pos: 3}, {pos: 2}, {pos: 1}]
|
|
43
49
|
*/
|
|
44
|
-
export function arraySortPositions(item
|
|
50
|
+
export function arraySortPositions(item?: string | null, isReverse?: boolean): (a: any, b: any) => number;
|
|
51
|
+
export type DiffArrayListData<T> = {
|
|
52
|
+
/**
|
|
53
|
+
* - Items that only exist in the new array.
|
|
54
|
+
*/
|
|
55
|
+
added: T[];
|
|
56
|
+
/**
|
|
57
|
+
* - Items that only existed in the old array.
|
|
58
|
+
*/
|
|
59
|
+
removed: T[];
|
|
60
|
+
};
|
|
45
61
|
//# sourceMappingURL=array.d.mts.map
|
package/dist/v1/basics/array.mjs
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* @returns {T} The same array instance, now shuffled in place.
|
|
11
11
|
*/
|
|
12
12
|
export function shuffleArray(items) {
|
|
13
|
+
if (!Array.isArray(items)) {
|
|
14
|
+
throw new TypeError("Argument 'items' must be an array.");
|
|
15
|
+
}
|
|
13
16
|
let currentIndex = items.length, randomIndex;
|
|
14
17
|
// While there remain elements to shuffle...
|
|
15
18
|
while (currentIndex !== 0) {
|
|
@@ -24,27 +27,52 @@ export function shuffleArray(items) {
|
|
|
24
27
|
/**
|
|
25
28
|
* Generates an array with repeated phases according to counts.
|
|
26
29
|
*
|
|
27
|
-
* @
|
|
30
|
+
* @template {any} BlockValue
|
|
31
|
+
* @param {BlockValue[]} phases - Array of phase names, e.g., ['Full', 'Half1', 'Half2', 'New'].
|
|
28
32
|
* @param {number[]} counts - Array of integers specifying how many times to repeat each phase, e.g., [4,5,5,4].
|
|
29
|
-
* @returns {
|
|
33
|
+
* @returns {BlockValue[]} - Flattened array containing phases repeated according to counts, concatenated in order.
|
|
30
34
|
*/
|
|
31
35
|
export function multiplyArrayBlocks(phases, counts) {
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if (!Array.isArray(phases)) {
|
|
37
|
+
throw new TypeError("Argument 'phases' must be an array.");
|
|
38
|
+
}
|
|
39
|
+
if (!Array.isArray(counts)) {
|
|
40
|
+
throw new TypeError("Argument 'counts' must be an array.");
|
|
41
|
+
}
|
|
42
|
+
if (phases.length !== counts.length) {
|
|
43
|
+
throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");
|
|
44
|
+
}
|
|
34
45
|
const result = [];
|
|
35
46
|
for (let i = 0; i < phases.length; i++) {
|
|
47
|
+
if (typeof counts[i] !== 'number' || Number.isNaN(counts[i])) {
|
|
48
|
+
throw new TypeError(`Element at counts[${i}] must be a valid number.`);
|
|
49
|
+
}
|
|
36
50
|
for (let j = 0; j < counts[i]; j++) {
|
|
37
51
|
result.push(phases[i]);
|
|
38
52
|
}
|
|
39
53
|
}
|
|
40
54
|
return result;
|
|
41
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @template T
|
|
58
|
+
* @typedef {Object} DiffArrayListData
|
|
59
|
+
* @property {T[]} added - Items that only exist in the new array.
|
|
60
|
+
* @property {T[]} removed - Items that only existed in the old array.
|
|
61
|
+
*/
|
|
42
62
|
/**
|
|
43
63
|
* Diff two class lists.
|
|
44
|
-
* @
|
|
45
|
-
* @param {
|
|
64
|
+
* @template T
|
|
65
|
+
* @param {T[]} oldItems - The original/old array for comparison.
|
|
66
|
+
* @param {T[]} newItems - The new array for comparison.
|
|
67
|
+
* @returns {DiffArrayListData<T>} An object containing arrays of added and removed items.
|
|
46
68
|
*/
|
|
47
69
|
export function diffArrayList(oldItems, newItems) {
|
|
70
|
+
if (!Array.isArray(oldItems)) {
|
|
71
|
+
throw new TypeError("Argument 'oldItems' must be an array.");
|
|
72
|
+
}
|
|
73
|
+
if (!Array.isArray(newItems)) {
|
|
74
|
+
throw new TypeError("Argument 'newItems' must be an array.");
|
|
75
|
+
}
|
|
48
76
|
const removed = oldItems.filter((c) => !newItems.includes(c));
|
|
49
77
|
const added = newItems.filter((c) => !oldItems.includes(c));
|
|
50
78
|
return { added, removed };
|
|
@@ -52,7 +80,7 @@ export function diffArrayList(oldItems, newItems) {
|
|
|
52
80
|
/**
|
|
53
81
|
* Generates a comparator function to sort an array of objects by a given key.
|
|
54
82
|
*
|
|
55
|
-
* @param {string} item - The object key to sort by.
|
|
83
|
+
* @param {string|null} [item] - The object key to sort by.
|
|
56
84
|
* @param {boolean} [isReverse=false] - If `true`, the sorting will be in descending order.
|
|
57
85
|
* @returns {(a: Object<string|number, *>, b: Object<string|number, *>) => number} Comparator function compatible with Array.prototype.sort().
|
|
58
86
|
*
|
|
@@ -65,14 +93,28 @@ export function diffArrayList(oldItems, newItems) {
|
|
|
65
93
|
* arr.sort(arraySortPositions('pos', true)); // Descending: [{pos: 3}, {pos: 2}, {pos: 1}]
|
|
66
94
|
*/
|
|
67
95
|
export function arraySortPositions(item, isReverse = false) {
|
|
96
|
+
if (item !== undefined && item !== null && typeof item !== 'string') {
|
|
97
|
+
throw new TypeError("Argument 'item' must be a string or null.");
|
|
98
|
+
}
|
|
99
|
+
if (typeof isReverse !== 'boolean') {
|
|
100
|
+
throw new TypeError("Argument 'isReverse' must be a boolean.");
|
|
101
|
+
}
|
|
68
102
|
if (!isReverse) {
|
|
69
103
|
return function (a, b) {
|
|
70
|
-
return
|
|
104
|
+
return (item ? a[item] : a) < (item ? b[item] : b)
|
|
105
|
+
? -1
|
|
106
|
+
: (item ? a[item] : a) > (item ? b[item] : b)
|
|
107
|
+
? 1
|
|
108
|
+
: 0;
|
|
71
109
|
};
|
|
72
110
|
}
|
|
73
111
|
else {
|
|
74
112
|
return function (a, b) {
|
|
75
|
-
return
|
|
113
|
+
return (item ? a[item] : a) > (item ? b[item] : b)
|
|
114
|
+
? -1
|
|
115
|
+
: (item ? a[item] : a) < (item ? b[item] : b)
|
|
116
|
+
? 1
|
|
117
|
+
: 0;
|
|
76
118
|
};
|
|
77
119
|
}
|
|
78
120
|
}
|
package/dist/v1/basics/clock.cjs
CHANGED
|
@@ -4,33 +4,43 @@
|
|
|
4
4
|
* Calculates the time duration between the current time and a given time offset.
|
|
5
5
|
*
|
|
6
6
|
* @param {Date} timeData - The target time as a Date object.
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {'asMilliseconds'|'asSeconds'|'asMinutes'|'asHours'|'asDays'} [durationType='asSeconds'] - The type of duration to return.
|
|
8
8
|
* @param {Date|null} [now=null] - The current time as a Date object. Defaults to the current date and time if not provided.
|
|
9
9
|
* @returns {number|null} The calculated duration in the specified unit, or `null` if `timeData` is not provided.
|
|
10
10
|
*/
|
|
11
11
|
function getTimeDuration(timeData = new Date(), durationType = 'asSeconds', now = null) {
|
|
12
|
-
if (timeData instanceof Date) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case 'asHours':
|
|
25
|
-
return diffMs / (1000 * 60 * 60);
|
|
26
|
-
case 'asDays':
|
|
27
|
-
return diffMs / (1000 * 60 * 60 * 24);
|
|
28
|
-
default:
|
|
29
|
-
return diffMs / 1000; // default to seconds
|
|
30
|
-
}
|
|
12
|
+
if (!(timeData instanceof Date)) {
|
|
13
|
+
throw new TypeError("The 'timeData' argument must be an instance of Date.");
|
|
14
|
+
}
|
|
15
|
+
if (typeof durationType !== 'string') {
|
|
16
|
+
throw new TypeError("The 'durationType' argument must be a string.");
|
|
17
|
+
}
|
|
18
|
+
const validDurationTypes = ['asMilliseconds', 'asSeconds', 'asMinutes', 'asHours', 'asDays'];
|
|
19
|
+
if (!validDurationTypes.includes(durationType)) {
|
|
20
|
+
throw new RangeError(`The 'durationType' must be one of: ${validDurationTypes.join(', ')}.`);
|
|
21
|
+
}
|
|
22
|
+
if (now !== null && !(now instanceof Date)) {
|
|
23
|
+
throw new TypeError("The 'now' argument must be an instance of Date or null.");
|
|
31
24
|
}
|
|
32
25
|
|
|
33
|
-
|
|
26
|
+
const currentTime = now instanceof Date ? now : new Date();
|
|
27
|
+
/** @type {number} */
|
|
28
|
+
const diffMs = timeData.getTime() - currentTime.getTime();
|
|
29
|
+
|
|
30
|
+
switch (durationType) {
|
|
31
|
+
case 'asMilliseconds':
|
|
32
|
+
return diffMs;
|
|
33
|
+
case 'asSeconds':
|
|
34
|
+
return diffMs / 1000;
|
|
35
|
+
case 'asMinutes':
|
|
36
|
+
return diffMs / (1000 * 60);
|
|
37
|
+
case 'asHours':
|
|
38
|
+
return diffMs / (1000 * 60 * 60);
|
|
39
|
+
case 'asDays':
|
|
40
|
+
return diffMs / (1000 * 60 * 60 * 24);
|
|
41
|
+
default:
|
|
42
|
+
return diffMs / 1000; // default to seconds
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
/**
|
|
@@ -43,9 +53,21 @@ function getTimeDuration(timeData = new Date(), durationType = 'asSeconds', now
|
|
|
43
53
|
* @returns {string} The formatted timer string.
|
|
44
54
|
*/
|
|
45
55
|
function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
46
|
-
totalSeconds
|
|
47
|
-
|
|
56
|
+
if (typeof totalSeconds !== 'number' || Number.isNaN(totalSeconds)) {
|
|
57
|
+
throw new TypeError("The 'totalSeconds' argument must be a valid number.");
|
|
58
|
+
}
|
|
59
|
+
if (typeof level !== 'string') {
|
|
60
|
+
throw new TypeError("The 'level' argument must be a string.");
|
|
61
|
+
}
|
|
48
62
|
const levels = ['seconds', 'minutes', 'hours', 'days', 'months', 'years'];
|
|
63
|
+
if (!levels.includes(level)) {
|
|
64
|
+
throw new RangeError(`The 'level' must be one of: ${levels.join(', ')}.`);
|
|
65
|
+
}
|
|
66
|
+
if (typeof format !== 'string') {
|
|
67
|
+
throw new TypeError("The 'format' argument must be a string.");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
totalSeconds = Math.max(0, Math.floor(totalSeconds));
|
|
49
71
|
const index = levels.indexOf(level);
|
|
50
72
|
|
|
51
73
|
const include = {
|
|
@@ -59,13 +81,13 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
59
81
|
|
|
60
82
|
/**
|
|
61
83
|
* @type {{
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
84
|
+
* years: number|NaN,
|
|
85
|
+
* months: number|NaN,
|
|
86
|
+
* days: number|NaN,
|
|
87
|
+
* hours: number|NaN,
|
|
88
|
+
* minutes: number|NaN,
|
|
89
|
+
* seconds: number|NaN,
|
|
90
|
+
* total: number|NaN
|
|
69
91
|
* }}
|
|
70
92
|
*/
|
|
71
93
|
const parts = {
|
|
@@ -144,6 +166,16 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
144
166
|
parts.seconds = remaining;
|
|
145
167
|
}
|
|
146
168
|
|
|
169
|
+
// Calculate total
|
|
170
|
+
/** const totalMap = {
|
|
171
|
+
seconds: include.seconds ? totalSeconds : NaN,
|
|
172
|
+
minutes: include.minutes ? totalSeconds / 60 : NaN,
|
|
173
|
+
hours: include.hours ? totalSeconds / 3600 : NaN,
|
|
174
|
+
days: include.days ? totalSeconds / 86400 : NaN,
|
|
175
|
+
months: include.months ? parts.years * 12 + parts.months + (parts.days || 0) / 30 : NaN,
|
|
176
|
+
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
177
|
+
}; */
|
|
178
|
+
|
|
147
179
|
parts.total = +totalSeconds.toFixed(2).replace(/\.00$/, '');
|
|
148
180
|
|
|
149
181
|
/**
|
|
@@ -186,6 +218,9 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
186
218
|
* @returns {string} The formatted timer string in "HH:MM:SS" format.
|
|
187
219
|
*/
|
|
188
220
|
function formatTimer(seconds) {
|
|
221
|
+
if (typeof seconds !== 'number' || Number.isNaN(seconds)) {
|
|
222
|
+
throw new TypeError("The 'seconds' argument must be a valid number.");
|
|
223
|
+
}
|
|
189
224
|
return formatCustomTimer(seconds, 'hours', '{hours}:{minutes}:{seconds}');
|
|
190
225
|
}
|
|
191
226
|
|
|
@@ -198,6 +233,9 @@ function formatTimer(seconds) {
|
|
|
198
233
|
* @returns {string} The formatted timer string in "Xd HH:MM:SS" format.
|
|
199
234
|
*/
|
|
200
235
|
function formatDayTimer(seconds) {
|
|
236
|
+
if (typeof seconds !== 'number' || Number.isNaN(seconds)) {
|
|
237
|
+
throw new TypeError("The 'seconds' argument must be a valid number.");
|
|
238
|
+
}
|
|
201
239
|
return formatCustomTimer(seconds, 'days', '{days}d {hours}:{minutes}:{seconds}');
|
|
202
240
|
}
|
|
203
241
|
|
|
@@ -207,20 +245,29 @@ function formatDayTimer(seconds) {
|
|
|
207
245
|
* @param {number} totalMs - The total duration in milliseconds.
|
|
208
246
|
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
209
247
|
* @returns {{
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
248
|
+
* years: number|NaN,
|
|
249
|
+
* months: number|NaN,
|
|
250
|
+
* days: number|NaN,
|
|
251
|
+
* hours: number|NaN,
|
|
252
|
+
* minutes: number|NaN,
|
|
253
|
+
* seconds: number|NaN,
|
|
254
|
+
* milliseconds: number|NaN,
|
|
255
|
+
* total: number|NaN
|
|
218
256
|
* }}
|
|
219
257
|
*/
|
|
220
258
|
function breakdownDuration(totalMs, level = 'milliseconds') {
|
|
221
|
-
totalMs
|
|
222
|
-
|
|
259
|
+
if (typeof totalMs !== 'number' || Number.isNaN(totalMs)) {
|
|
260
|
+
throw new TypeError("The 'totalMs' argument must be a valid number.");
|
|
261
|
+
}
|
|
262
|
+
if (typeof level !== 'string') {
|
|
263
|
+
throw new TypeError("The 'level' argument must be a string.");
|
|
264
|
+
}
|
|
223
265
|
const levels = ['milliseconds', 'seconds', 'minutes', 'hours', 'days', 'months', 'years'];
|
|
266
|
+
if (!levels.includes(level)) {
|
|
267
|
+
throw new RangeError(`The 'level' must be one of: ${levels.join(', ')}.`);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
totalMs = Math.max(0, Math.floor(totalMs));
|
|
224
271
|
const index = levels.indexOf(level);
|
|
225
272
|
|
|
226
273
|
const include = {
|
|
@@ -316,10 +363,15 @@ function breakdownDuration(totalMs, level = 'milliseconds') {
|
|
|
316
363
|
}
|
|
317
364
|
|
|
318
365
|
// Totals
|
|
319
|
-
|
|
366
|
+
/** const totalMap = {
|
|
367
|
+
milliseconds: include.milliseconds ? totalMs : NaN,
|
|
368
|
+
seconds: include.seconds ? totalMs / 1000 : NaN,
|
|
369
|
+
minutes: include.minutes ? totalMs / 60000 : NaN,
|
|
370
|
+
hours: include.hours ? totalMs / 3600000 : NaN,
|
|
371
|
+
days: include.days ? totalMs / 86400000 : NaN,
|
|
320
372
|
months: include.months ? parts.years * 12 + parts.months + (parts.days || 0) / 30 : NaN,
|
|
321
373
|
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
322
|
-
}
|
|
374
|
+
}; */
|
|
323
375
|
|
|
324
376
|
parts.total = +totalMs;
|
|
325
377
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Calculates the time duration between the current time and a given time offset.
|
|
3
3
|
*
|
|
4
4
|
* @param {Date} timeData - The target time as a Date object.
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {'asMilliseconds'|'asSeconds'|'asMinutes'|'asHours'|'asDays'} [durationType='asSeconds'] - The type of duration to return.
|
|
6
6
|
* @param {Date|null} [now=null] - The current time as a Date object. Defaults to the current date and time if not provided.
|
|
7
7
|
* @returns {number|null} The calculated duration in the specified unit, or `null` if `timeData` is not provided.
|
|
8
8
|
*/
|
|
9
|
-
export function getTimeDuration(timeData?: Date, durationType?:
|
|
9
|
+
export function getTimeDuration(timeData?: Date, durationType?: "asMilliseconds" | "asSeconds" | "asMinutes" | "asHours" | "asDays", now?: Date | null): number | null;
|
|
10
10
|
/**
|
|
11
11
|
* Formats a custom timer string based on total seconds and a detail level.
|
|
12
12
|
* Includes proper reallocation of lower units into higher ones, ensuring consistent hierarchy.
|
|
@@ -41,14 +41,14 @@ export function formatDayTimer(seconds: number): string;
|
|
|
41
41
|
* @param {number} totalMs - The total duration in milliseconds.
|
|
42
42
|
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
43
43
|
* @returns {{
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
44
|
+
* years: number|NaN,
|
|
45
|
+
* months: number|NaN,
|
|
46
|
+
* days: number|NaN,
|
|
47
|
+
* hours: number|NaN,
|
|
48
|
+
* minutes: number|NaN,
|
|
49
|
+
* seconds: number|NaN,
|
|
50
|
+
* milliseconds: number|NaN,
|
|
51
|
+
* total: number|NaN
|
|
52
52
|
* }}
|
|
53
53
|
*/
|
|
54
54
|
export function breakdownDuration(totalMs: number, level?: "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years"): {
|