0.2.0 • Published 7 years ago

nodeui v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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
0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago