0.0.1 • Published 10 months ago

@ansi-art/interactive-input v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

interactive-input

Get browser-like input on the command line in pure JS using ansi escape codes.

Usage

const tracker = new InteractiveInput({});
process.stdin.setRawMode(true);
process.stdin.on('data', (buffer) => {
    tracker.consume(buffer.toJSON());
});
tracker.start();
const gracefulTerminate = ()=>{ tracker.stop(); };
process.on('SIGTERM', gracefulTerminate);
process.on('SIGINT', gracefulTerminate);
tracker.on('keypress', (event)=>{
    if(event.key === 'Escape'){
        gracefulTerminate();
        process.exit();
    }
});
tracker.on('mouseup', (event)=>{ /* ... */  });
tracker.on('mousedown', (event)=>{ /* ... */  });
tracker.on('mousemove', (event)=>{ /* ... */  });

Testing

Run the es module tests to test the root modules

npm run import-test

to run the same test inside the browser:

npm run browser-test

to run the same test headless in chrome:

npm run headless-browser-test

to run the same test inside docker:

npm run container-test

Run the commonjs tests against the /dist commonjs source (generated with the build-commonjs target).

npm run require-test

Development

All work is done in the .mjs files and will be transpiled on commit to commonjs and tested.

If the above tests pass, then attempt a commit which will generate .d.ts files alongside the src files and commonjs classes in dist

0.0.1

10 months ago