1.5.2 • Published 3 years ago

@pronix/hyper-flow v1.5.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

npm.io

HyperFlow.js

npm.io npm.io

Framework for building progressive console applications on node.js platform

Getting started

$ yarn add @pronix/hyper-flow
#or
$ npm i @pronix/hyper-flow
const { Hyper, HyperContext } = require('@pronix/hyper-flow')
// or
// import { Hyper, HyperContext } from '@pronix/hyper-flow''

const app = new Hyper()
const ctx = new HyperContext()

ctx.on('/', () => console.log('hello'))

app.next(ctx)
app.listen()

Documentation 📄

using

at first, you need to create application

import { Hyper } from '@pronix/hyper-flow'

const app = new Hyper()

next you need to create ctx - this is the object that will process the commands, you can create more than one context and then you can change current context in runtime

import { Hyper, HyperContext, utils } from '@pronix/hyper-flow'

const app = new Hyper()

const ctx1 = new HyperContext(utils.marker('ctx1'))
const ctx2 = new HyperContext(utils.marker('ctx2'))

ctx1
    .on('/next', () => app.next(ctx2))
    .on('/back', () => app.back())
    .on('/', () => console.log(utils.renderCommands(ctx1.cmds)))

ctx2
    .on('/next', () => app.next(ctx1))
    .on('/back', () => app.back())
    .nothing('', ' ')

app
    .next(ctx1)
    .listen()

also you can use async code in your program, it will works, because the readline is async

const app = new Hyper()

const ctx = new HyperContext()
const ctx2 = new HyperContext()


ctx.on('/', () => {
    console.log('hello')
    app.next(ctx2)
})

ctx2
    .on('/', () => console.log('end'))
    .on('/ask', () => {
        // question must be a sync call ->
        const response = question('what is your name?')
        // processing response
        console.log(response)
    })
    .default((ctx, cmd) => {
        console.log(cmd)
    })

app.next(ctx)

// you can use async side-effects ->
setTimeout(() => {
    console.log('async call')
}, 3000)

app.listen()

marker is a tool, which writes the text in comand line befor every command, it is a string

import { error } from "@pronix/hyper-flow";

ctx.marker = 'ctx1:\\> '

ctx
    .on('/', () => console.log('hello'))
    
    .on('/error', () => console.log(error('error handler', 1)))
    
    .on('exit', () => process.exit(0))
    .on('/exit', ctx => ctx.run('exit'))

app
    .defaultContext
    .on('/info', () => console.log('info: ...'))
    .nothing('')

app
    .next(ctx)
    .listen()

stop word:

ctx
    .on('/', () => console.log('hello world'))

app.next(ctx)

app.stopWord = 'stop'

app.listen()

for developing

setup ⚙️

$ git clone http://github.com/pronix575/hyper-flow
$ cd hyper-flow

$ yarn setup
# or
$ npm setup

build 🛠

$ yarn build

start 🚀

$ yarn start

developing 🧱

$ yarn dev:build
$ yarn dev:start
1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.5

4 years ago

0.0.14

4 years ago

0.1.0

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago