const logger = createLogger({
level: 'info',
transports: new transports.Console(),
format: customFormat(),
});
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 characters
export const jab = <T>(v: T) => Promise.allSettled([ v ]).then(([ r ]) => r) |
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 characters
const XML = { stringify: (value: any, tag: string) => `<${tag}>` + Object.entries(value).reduce((p, [k, v]) => p + (v && typeof v === 'object' ? XML.stringify(v, k) : `<${k}>${v}</${k}>`), '') + `</${tag}>` }; |
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 characters
---Run a benchmark | |
---@param fn function | |
---@param outer_iter integer? | |
---@param inner_iter integer? | |
---@param warmup_iter integer? | |
local function bench(fn, outer_iter, inner_iter, warmup_iter) | |
outer_iter = outer_iter or 100 | |
inner_iter = inner_iter or 10000 | |
warmup_iter = warmup_iter or 10 |
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 characters
/** | |
* A simple fetch() wrapper with timeout. | |
* @param input - Same as `fetch()`. | |
* @param init - Same as `fetch()`, but with an extra option `timeout` (defaults to no timeout). | |
* @returns - Same as `fetch()`. | |
*/ | |
export const fetchWithTimeout = (input: RequestInfo, init?: RequestInit & { timeout?: number }) => { | |
if (typeof init?.timeout === 'number') { | |
const controller = new AbortController(); | |
const timeoutId = setTimeout(() => controller.abort(new TimeoutError()), init.timeout); |
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 characters
const path = require('path'); | |
const fs = require('fs/promises'); | |
// ---------------------------------------- CONFIG ---------------------------------------- // | |
/** | |
* Add the fonts to copy here. | |
* Make sure you've installed the Fontsource package for the font! | |
* Uses the same font family format as the Google Font API. |
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 characters
import type { Readable, Unsubscriber } from 'svelte/store'; | |
/** List of Readable stores */ | |
type Stores = [ Readable<any>, ...Array<Readable<any>> ] | Array<Readable<any>>; | |
/** Values from a list of Readable stores */ | |
type StoresValues<T> = { | |
[K in keyof T]: T[K] extends Readable<infer U> ? U : never; | |
}; |
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 characters
export function job(time: number | string, job: Function): number { | |
let millis: number; | |
if (typeof time === 'number') { | |
millis = time; | |
} else { | |
if (!isNaN(time)) { | |
millis = parseInt(time); | |
} else { | |
const num = parseInt(time.slice(0, -1)); |
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 characters
const fs = require('fs'); | |
const LEVELS = JSON.parse(fs.readFileSync('./levels.json')); | |
let argv = process.argv.splice(2); | |
const FORCE_RECALC = argv.includes('-f') || argv.includes('--force'); | |
if (FORCE_RECALC) { | |
argv = argv.filter(v => v !== '-f' && v !== '--force'); |
NewerOlder