This file contains 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 characters
class ISO8601 { | |
#originalString: ParsedISO["originalString"]; | |
#repetitions?: ParsedISO["repetitions"]; | |
#dates: | |
| Readonly<[Readonly<ISOPart>, Readonly<ISODatePart>]> | |
| Readonly<[Readonly<ISODatePart>, Readonly<ISOPart>]> | |
| Readonly<[Readonly<ISOPart>]>; | |
get originalString() { | |
return this.#originalString; |
This file contains 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 characters
const units = [ | |
'zero', 'one', 'two', 'three', 'four', | |
'five', 'six', 'seven', 'eight', 'nine', | |
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', | |
'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', | |
]; | |
const tens = [ | |
'', 'ten', 'twenty', 'thirty', 'fourty', | |
'fifty', 'sixty', 'seventy', 'eighty', 'ninety', |
This file contains 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 characters
const units = [ | |
'zero', | |
'one', | |
'two', | |
'three', | |
'four', | |
'five', | |
'six', | |
'seven', | |
'eight', |
This file contains 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 characters
const byteNumber = () => Math.random() * 2 ** 8 >> 0; | |
export const randomHex = () => | |
'#' + (2 ** (2 ** 3 * 3) * Math.random() >> 0).toString(16).padStart(6,'0') | |
; | |
export const randomRGB = () => | |
`rgb(${[byteNumber(),byteNumber(),byteNumber()]})` | |
; |
This file contains 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 characters
// TODO: output “required:” array correctly | |
const payloads = [{ | |
a: 'one', | |
b: 2, | |
c: { | |
face: 'me' | |
}, | |
d: [1,2] | |
},{ |
This file contains 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 characters
async function getChanceOfMatchingBirthday({ | |
numberOfPeopleInTheRoom = 23, | |
howManyRoomsToAverageBetween = 1e5, | |
} = {}) { | |
let initDate = Date.now(); | |
let testCount = 0; | |
let matchCount = 0; | |
while (testCount < howManyRoomsToAverageBetween) { | |
if (!(testCount % 5e3) && Date.now() >= initDate + 16) { |
This file contains 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 characters
// To log the results: | |
// | |
// getFiles(__dirname, { ignore: ['node_modules'] }) | |
// .then(files => console.log( | |
// files | |
// .flat(Infinity) | |
// .filter(( Oo) => (Oo )) | |
// )); | |
// Available options: |
This file contains 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 characters
function getYarnLockDupes(yarnLock) { | |
return yarnLock | |
.split('\n') | |
.filter(a => !a.startsWith(' ') && !a.startsWith('#')) | |
.map(a => a.replace(/[:"]/g, '')) | |
.flatMap(a => a.split(/, ?/g)) | |
.filter(a => a) | |
.flatMap(a => { | |
const versions = a.split(' || '); | |
if (versions.length === 1) { return a; } |
This file contains 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 characters
/** | |
* Used like: | |
* const cls = buildBEMBuilder("block-name"); | |
* | |
* let blockClass = cls(); | |
* // => "block-name" | |
* | |
* let modifiedBlockClass = cls({ | |
* goodModifier: true, | |
* badModifier: false, |
This file contains 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 characters
/** | |
* Used like: | |
* const cls = buildBEMBuilder("block-name"); | |
* | |
* let blockClass = cls(); | |
* // => "block-name" | |
* | |
* let modifiedBlockClass = cls({ | |
* goodModifier: true, | |
* badModifier: false, |
NewerOlder