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: make `pages` optional and measure the div when unspecified, this will | |
// allow more normal document flow and make it easier to do both mobile and | |
// desktop. | |
import { | |
createContext, | |
useCallback, | |
useContext, | |
useEffect, | |
useMemo, | |
useRef, |
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
// hack as self-circulating types are not working in 4.5.4 | |
interface Tree extends Record<string, number | Tree> { } | |
type Subtree = Tree[keyof Tree] | |
const uniqueNumbersSet = new Set<number>(); | |
const getUniqueSortedNumbers = (tree: Tree) => { | |
Object.values(tree).forEach((subtree: Subtree) => { | |
if (typeof subtree === "number") { | |
return !uniqueNumbersSet.has(subtree) && uniqueNumbersSet.add(subtree); |
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
1. | |
console.log = function (this: Function, ...args: unknown[]) { | |
const remappedArgs = [...args.map((elementToLog) => [elementToLog, typeof elementToLog])].flat() | |
this.apply(console, remappedArgs); | |
}.bind(console.log); | |
console.log('123', [1, 2], 12, Symbol('symbol'), { hello: 1 }, undefined, null, BigInt(9007199254740991)); | |
// 123 string (2) [1, 2]0: 11: 2length: 2[[Prototype]]: Array(0) object 12 number Symbol(symbol) symbol {hello: 1} object undefined undefined null object 9007199254740991n bigint |