Socket
Book a DemoInstallSign in
Socket

message-await

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

message-await

A utility to print message with an async success or failure in node.js

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

message-await

A utility to print message with an async success or failure in node.js

Installation

npm install message-await

Why Use This?

It's a really simple way of giving your user feedback that we are waiting for something and then to give feedback on success or failure:

Spinner Animation

Usage

import print from 'message-await';

const messageAwait = print('Loading the thing', true, chalk.blue);

await someAsyncProcess;

messageAwait.success('The thing loaded');

Examples

Success or Failure

import print from 'message-await';

const messageAwait = print('Loading the thing', true, chalk.blue);

await someAsyncProcess;

messageAwait.success("optional complete message");
// OR: messageAwait.fail("optional fail message");
// OR: messageAwait.complete(true, "optional message")
// OR: messageAwait.complete(false)

Progress

import print from '../src';
import chalk from 'chalk';

const messageAwait = print('Loading', true, chalk.blue);

function onProgressCallback(complete: number, total: number){
    messageAwait.updateMessage(`Loading ${complete}/${total}`);
}

function onCompleteCallback(total: number){
    messageAwait.success(`Loading ${complete}/${total}`);
}

someAsyncFunction(onProgressCallback, onCompleteCallback);

Progress Animation

Await

    const result = await print('Waiting', true, chalk.blue).await(examplePromise, true, true, 'Done', 'Fail');

Success

Await Success Example

Fail

The above example exits the process and prints the error message when the promise is rejected: Await Fail Example

Keywords

async

FAQs

Package last updated on 06 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts