Last active
June 13, 2020 14:58
-
-
Save fliptopbox/d89e34d5a7d7a908f0b2beb899f1f814 to your computer and use it in GitHub Desktop.
Revisions
-
fliptopbox revised this gist
Jun 13, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ function getRandomPayload() { return { ts: new Date().valueOf(), date: { -
fliptopbox created this gist
Jun 13, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ export default function getRandomPayload() { return { ts: new Date().valueOf(), date: { epoc: new Date().valueOf(), iso: new Date().toISOString(), local: new Date().toString(), utc: new Date().toUTCString() }, float: Math.random(), integer: (Math.random() * 10) >> 0, array: [Math.random(), Math.random(), Math.random()], dictionary: { x: Math.random(), y: Math.random(), z: Math.random(), a: Math.random() }, word: words(1), sentence: words(r(8, 3)), paragraph: `${words(r(8, 3))} ${words(r(16))} ${words(r(24))}` }; } function words(count = 3) { let glossary = ` I you me my mine yours an a am can but it is not with in out here there where everybody nobody somebody anybody chastity temperance charity diligence patience gratitude humility greed pride sloth wrath lust gluttony envy alpha beta charlie delta echo foxtrot golf hotel indigo juliet kilo lima mama november oscar papa quebec romeo sierra tango uniform vienna whiskey xray yanky zero one two three four five six seven eight nine ten ` .trim() .replace(/[\n\s]+/g, " ") .split(/\s+/); glossary = [...glossary, ...glossary]; count = Math.min(glossary.length, count); count = count || 1; glossary = glossary.sort((a, b) => Math.random() - 0.5); glossary = glossary.slice(0, count); glossary = glossary.join(" "); glossary += count > 1 ? "." : ""; return glossary.replace(/^\w/, (a) => a.toUpperCase()); } function r(max = 5, min = 1) { return (Math.random() * max + min) >> 0; }