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 vitePluginSvgSpritesheet = ({ | |
| path, | |
| output, | |
| }: { | |
| path: string | string[]; | |
| output: string; | |
| }): Plugin => { | |
| let spritesheet: string; | |
| return { |
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
| function *XORShift32(seed: number | bigint): Generator<Number> { | |
| const base = 2 ** 32; | |
| seed = BigInt(seed); | |
| while(true) { | |
| let x = seed as bigint; | |
| x = BigInt.asUintN(32, x); | |
| x ^= x << 13n; | |
| x ^= x >> 17n; | |
| x ^= x << 5n; |
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 { createQueue } from './queue.js'; | |
| const fakeAsyncCall = (i: number) => | |
| new Promise<void>((resolve) => | |
| setTimeout(() => { | |
| console.log(i); | |
| resolve(); | |
| }, 1000) | |
| ); |
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 classNames = ( | |
| ...classes: Array<string | string[] | Record<string]: boolean }> | |
| ): string | undefined => classes | |
| .map(cls => cls?.constructor.name === 'Object' ? Object.keys(cls).filter(key => cls[key]) : cls) | |
| .flat() | |
| .filter(Boolean) | |
| .join(' ') || undefined; |
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
| /** | |
| Namespace for LZW compression and decompression. | |
| Methods: | |
| LZW.compress(uncompressed) | |
| LZW.decompress(compressed) | |
| */ | |
| function createDictionary({ size = 256, inverse = false } = {}) { | |
| const dictionary = new Map(); |
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
| if (!document.elementsFromPoint) { | |
| document.elementsFromPoint = | |
| document.msElementsFromPoint || | |
| function elementsFromPoint(x, y) { | |
| var stack = []; | |
| var element = document.elementFromPoint(x, y); | |
| try { | |
| while (element !== null) { | |
| stack.push({ |
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
| /** | |
| * Generate a random UUIDv4 (rfc4122 compliant) | |
| */ | |
| export function uuid(): string { | |
| const uuid = [8, 4, 4, 4, 12].map((segmentLength: number) => { | |
| let segment = Array(segmentLength); | |
| for (let i = 0; i < segmentLength; i++) | |
| // ToUint32 http://www.ecma-international.org/ecma-262/5.1/#sec-11.7.3 | |
| segment[i] = (Math.random() * 0xf) >>> 0; |
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
| { | |
| "trailingComma": "none", | |
| "tabWidth": 4, | |
| "semi": true, | |
| "singleQuote": true, | |
| "printWidth": 120 | |
| } |
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
| # editorconfig.org | |
| root = true | |
| [*] | |
| indent_style = space | |
| indent_size = 4 | |
| end_of_line = lf | |
| charset = utf-8 | |
| trim_trailing_whitespace = true | |
| insert_final_newline = true |
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 fibonacci = (n: number): number => { | |
| const delta = Math.sqrt(5); | |
| return Math.floor(((1 + delta) ** n - (1 - delta) ** n) / (2 ** n * delta)); | |
| }; |
NewerOlder