General
PromptBeginner5 minmarkdown
Untitled Skill
185
1. Create `src/transforms/yourFunction.ts`
Loading actions...
Main instructions and any bundled files for this skill.
src/transforms/yourFunction.tssrc/transforms/index.tssrc/pipeline.tstest/yourFunction.test.ts@group tag (Timing, Buffering, Filtering, Transformation, or Utilities)pnpm test && pnpm lint && pnpm build-fastexport async function* yourFunction<T>(source: AsyncIterable<T>, param: P): AsyncGenerator<T> {
for await (const item of source) {
yield transformedItem
}
}
map.ts, filter.tsminInterval.ts, throttle.tsbuffer.ts, chunk.tssplit.ts, replace.tsCritical rule: Errors must be thrown during await ticks, not in callbacks.
Errors in setTimeout/Promise.race callbacks escape user try/catch blocks. Instead, store errors and rethrow on the next await:
export async function* myTimingFunction<T>(source: AsyncIterable<T>) {
let error: Error | null = null
const consumer = (async () => {
try {
for await (const item of source) {
/* ... */
}
} catch (err) {
error = err instanceof Error ? err : new Error(String(err))
}
})()
while (true) {
if (error) throw error // Thrown during await tick - catchable by user
// ... yield logic
}
}
When to apply: Any function using setTimeout, setInterval, Promise.race, or background async operations.
Reference: buffer.ts has the canonical error handling pattern.
consume().return()test/timing-helpers.tstap() must pass through parent's return type, not just yield typetransforms/index.ts AND pipeline.tsTypeScript and ESLint rules that MUST be followed when creating, modifying, or reviewing any file under apps/frontend/, including .ts, .tsx, .js, and .jsx files. Also apply when discussing frontend li...
risks