tsfxxk
v1.0.0
Published
a tiny brainfuck interpreter built with the TypeScript type system
Downloads
71
Readme
Tsfuck
a tiny brainfuck interpreter by TypeScript type system.
一个用 TS 类型体操写成的 Brainfuck 解释器
Try it
npm i tsfxxk
# or
yarn add tsfxxk
import type { Tsfuck } from 'tsfxxk'
type Output = Tsfuck<',+.', 'a'> // extends 'b'
Usage
Tsfuck provides an entry type:
type Tsfuck <ProgramString extends string, InputString extends string>
Simple enough! This type receives ProgramString
and InputString
, then extends the output string.
// e.g.
type Output = Tsfuck<',+.>,-.', 'ac'> // extends 'bb'
// error
type Output = Tsfuck<'[', ''> // extends 'TsfuckError: Unbalanced brackets'
type Output = Tsfuck<',,,', 'ab'> // extends 'TsfuckError: Input not enough'