Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node UI

NPM version NPM downloads

Command Line UI components for Node.js

This module is based on clui and draftlog

:: Setup :: Usage :: Test :: Build

Setup

Installing this module in your project

yarn add nodeui
# or via npm
npm install nodeui

Usage

import * as chalk from 'chalk';
import  {Banner, Gauge, Spinner, Sparkline, Progress, Line, LineBuffer} from 'nodeui'
(async () => {
    try {
        const banner = new Banner('  Node UI is Awesome!    See what you can build with this module   ');
    
        let spinner = new Spinner('initial message');
        spinner.start();
        await sleep(800);
        spinner.message = 'still working...';
        await sleep(800);
        spinner.message = 'almost done...';
        await sleep(800);
        spinner.stop()
    } catch (err) {
        console.log('Error:::', err)
    }
})();
async function* getProgressSlowly() {
    let progress = 0;

    while (progress <= 100) {
        await sleep(50);
        progress += Math.round(Math.random() * 5);
        if (progress >= 100) {
            yield 100;
        } else {
            yield progress;
        }
    }
}

async function startDownload() {
    let myProgress = new Progress(50, chalk.green('Finished download!'));

    for await (let progress of getProgressSlowly()) {
        myProgress.update(progress, 100)
    }
}

(async () => {
    console.log('Starting downloads...');
    for (let i = 0; i < 10; i ++) {
        startDownload()
    }
})();

Developer Setup

Setup

yarn

Build

yarn run build

Examples

# ts-node examples.js
ts-node --disableWarnings  examples.ts

Test

yarn run test

Publish

yarn run prepublishOnly
cd dist
npm publish

About

👄 Command Line UI components for Node.js

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages