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 env = { self: {} }; | |
const chunks = Array.from(document.body.querySelectorAll("script")) | |
.filter((s) => !!s.textContent && s.textContent.includes("self.__next_f")) | |
.forEach((s) => new Function("self", s.textContent)(env.self)); | |
return env.self.__next_f | |
.filter((c) => c[0] === 1) | |
.map((c) => c[1]) | |
.join(""); | |
})(); |
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
/// <reference types="react/canary" /> | |
import React, { cache } from "react"; | |
type Options = { passthrough?: boolean }; | |
const OPTIONS_DEFAULT: Options = { passthrough: false }; | |
type RecordOrTupleArg = Record<string, any> | any[] | |
export function cacheValue<TObj extends RecordOrTupleArg>( | |
v: RecordOrTupleArg, |
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 type Thenable<T> = PendingThenable<T> | FulfilledThenable<T> | RejectedThenable<T> | |
export type PendingThenable<T> = Promise<T> & { status: 'pending' } | |
export type FulfilledThenable<T> = Promise<T> & { status: 'fulfilled', value: T } | |
export type RejectedThenable<T> = Promise<T> & { status: 'rejected', reason: unknown } | |
export function trackThenableState<T>(promise: Promise<T>): Thenable<T> { | |
const thenable = promise as Thenable<T>; | |
if ("status" in thenable && typeof thenable.status === "string") { |
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
type Replace< | |
Obj extends Record<string, any>, | |
Field extends keyof Obj, | |
NewType, | |
> = Reveal< | |
{ [Key in keyof Obj]: Key extends Field ? NewType : Obj[Key] } | |
> | |
type Reveal<Obj extends Record<string, any>> = { | |
[K in keyof Obj]: Obj[K] |
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
// https://pico.bsky.mom/ | |
(async () => { | |
// sine | |
const lines = 24 | |
function sine(t) { | |
const w = 12; | |
const arr = new Array(12).fill('.'); | |
const ix = Math.floor(((Math.cos(t * 0.6) + 1) / 2) * w); | |
arr[ix] = '#'; |
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 `try-catch-finally` that works for both sync and async callbacks. */ | |
export function tryCatch<T>( | |
cb: () => T | Promise<T>, | |
options: { catch?: (error: unknown) => T; finally?: () => void } | |
): T { | |
const { catch: onCatch, finally: onFinally } = options | |
let isAsync = false | |
try { | |
const result = cb() |
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 type Thenable<T> = | |
| PendingThenable<T> | |
| FulfilledThenable<T> | |
| RejectedThenable<T> | |
type PendingThenable<T> = Promise<T> & { status: 'pending' } | |
type FulfilledThenable<T> = Promise<T> & { status: 'fulfilled'; value: T } | |
type RejectedThenable<T> = Promise<T> & { status: 'rejected'; reason: unknown } | |
export function trackThenableState<T>(promise: Promise<T>): Thenable<T> { |
OlderNewer