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 objMap<T extends Record<string, any>, U>( | |
template: T, | |
eachKey: <P extends Extract<keyof T, string>>(name: P, value: T[P]) => U, | |
): { | |
[P in Extract<keyof T, string>]: U; | |
} { | |
// @ts-ignore | |
return Object.fromEntries( | |
Object.entries(template) | |
.filter(([name]) => typeof name === "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
pub mod prelude { | |
// some custom proc macros | |
pub use i_app_types_proc::shared; | |
// a "concepts" module that is purely for documenting through doc links | |
pub use crate::concepts; | |
// other common shared modules re-exported... | |
pub use crate::runtime; | |
pub use crate::testing; |
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
/** | |
* Add items with a throttled effect of applying the items. | |
* We might use this to collect items and then apply them in batches like for | |
* search results and timeline items. | |
*/ | |
export function collectAndFlush<T>( | |
then: (items: T[]) => void, | |
// 60 fps | |
throttleMs: number = 17, | |
): { |
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
/** | |
* As a proof of concept, | |
* JSON'infy the args, and parse them into a new Request Init, | |
* Make the fetch request with the new Request Init | |
* JSONify the response and use the jsonified response data | |
* to recreate the response object and return that | |
* | |
*/ | |
const fetchProxyProofOfConcept: typeof fetch = async (...args) => { |
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 { Component, DevJSX, JSXNode, JSXOutput } from "@builder.io/qwik"; | |
import { useSignal, useVisibleTask$ } from "@builder.io/qwik"; | |
const QWIK_DATA_ATTR = "data-qwik-inspector"; | |
interface HackedProps { | |
"data-qwik-inspector"?: DevJSX; | |
"p:where"?: DevJSX; | |
} | |
function createLinkFromDevJSX(dev: DevJSX) { |
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 warned = new Set<string>(); | |
export function warnOnce(message: string) { | |
if (!warned.has(message)) { | |
warned.add(message); | |
console.warn(message); | |
} | |
} |
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
/** Improve preview of union types in autocomplete. */ | |
export type Prettify<T> = { [K in keyof T]: T[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
#!/usr/bin/env node | |
// Required parameters: | |
// @raycast.schemaVersion 1 | |
// @raycast.title Obfuscate | |
// @raycast.mode compact | |
// Optional parameters: | |
// @raycast.icon 🤖 | |
// @raycast.argument1 { "type": "text", "placeholder": "Original" } |
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 MINUTE = 1000 * 60; | |
function asyncCachedFn<Args extends any[], Result>(options: { | |
fn: (...args: Args) => Promise<Result>; | |
key: (...args: Args) => string; | |
}) { | |
const cache: Map< | |
string, | |
{ computedAt: number; evict: any; result: Promise<Result> } |
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
// regexes to remove lines from thrown error stacktraces | |
const AT_NODE_INTERNAL_RE = /^\s*at.+node:internal.+/gm; | |
const AT_TYPES_INTERNAL_RE = /^\s*at.+\/types\/src\/.+/gm; | |
const AT_INVARIANT_RE = /^\s*(at|[^@]+@) (?:Object\.)?invariant.+/gm; | |
const AT_INVARIANT_MORE_RE = /^\s*at.+(?:invariant|asError|createErrorObj).+/gm; | |
const AT_TEST_HELPERS_RE = /^\s*(at|[^@]+@).+test\-helpers.+/gm; | |
// const AT_WEB_MODULES = /^\s*(at|[^@]+@).+(web_modules|\-[a-f0-9]{8}\.js).*/gm | |
const AT_ASSORTED_HELPERS_RE = | |
/^\s*(at|[^@]+@).+(debounce|invariant|iife)\.[tj]s.*/gm; |