1.0.4 • Published 1 year ago

goto-ts v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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...

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago