Node API (ttfx-node)
Chalk-style functions backed by the prebuilt engine. No child processes, no Rust needed.
npm i ttfx-node
import { play, getFrames, listEffects } from 'ttfx-node';
await play('Deploy complete', 'decrypt'); // animates your terminal
const frames = getFrames('hi', 'beams', { seed: 1 }); // pure ANSI strings
const tuned = getFrames('hi', 'decrypt', {
seed: 1, effectArgs: ['--typing-speed', '5'], // any effect flag, CLI-validated
});
Options
seed— deterministic output; omit for varietyframeRate— pacing hint (default 60)canvasWidth / canvasHeight— fixed canvas, else hugs inputtabWidth, wrapText, noColor, xtermColorsmaxFrames— safety cap (default 10000, hard max 100000)randomEffect + includeEffects / excludeEffectseffectArgs— every effect flag, verbatim fromnpx ttfx-js <effect> --help
Patterns
- Fire-and-forget animation →
play(). Always passseedin tests. - Custom players, snapshots, pre-baked output →
getFrames(). Same seed, byte-identical frames. playprints plain final text underNO_COLOR/pipes/CI automatically.- Ctrl-C:
playrestores the cursor and rejects with codeINTERRUPTED— catch it and choose your exit code.