Skip to content

HomeArchbishop/tsfuck2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tsfuck2

a tiny brainfuck interpreter by TypeScript type system.

一个用 TS 类型体操写成的 Brainfuck 解释器

  • Accurate execution

  • Great excptions handling

  • BETTER than tsfuck of mine

// tsfxxk
Tsfuck<'++[>+<-]>.', ''>
// ❌ Type instantiation is excessively deep and possibly infinite.

// tsfxxk2
Tsfuck<'++[>+<-]>.', ''>
// ✔️ '\x02'

Try it

npm i tsfxxk2
# or
yarn add tsfxxk2
import type { Tsfuck } from 'tsfxxk2'

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'
type Output = Tsfuck<'++[>+++[>+<-]+<-]>.>.', ''> // extends '\x01\x07'

// error
type Output = Tsfuck<'[', ''> // extends 'TsfuckError: Unbalanced brackets'
type Output = Tsfuck<',,,', 'ab'> // extends 'TsfuckError: Input not enough'

About

😈BETTER tiny brainfuck interpreter by TypeScript type

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published