goto-ts
v1.0.4
Published
Goto in typescript
Downloads
9
Readme
GOTO-TS
goto
in typescript/javascript because we've all been missing it and also why not.
import { Goto } from "goto-ts"
let a = 1
const fn = new Goto<number>()
.label("1",() => {
console.log("hello 1")
})
.label("2",goto => {
console.log("hello 2")
if(a++ < 10){
goto("1")
}
})
.label("3",(_,_return) => {
console.log("hello 3")
_return(a)
})
.toFunction()
fn()
.then(b => b === 10 //true)
import { withGoto } from "goto-ts"
const fn = async (x: number) => {
await withGoto({
'abc': goto => {
x++
goto('cde')
},
'bcd': (_,_return) => {
x++
_return(null)
},
'cde': goto => {
x++
goto('bcd')
}
})
return x
}
More to come soon...