0.1.0 • Published 2 years ago

dynamicwriter v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

What is this?

A program to log statements to the console with typewriter effect

Installation

Run npm i dynamicwriter

Use

import { dynamicWriter, writer } from 'dynamicwriter'

const execute = async () =>
    {
        await writer('your-statement-to-be-logged', 100);
        await dynamicWriter('your-statement-to-be-logged' ["-", 50], ["be", "150"], ["end//", "100"]);
    }

execute();

Parameters

The writer is a much simple function which accepts two parameters, first is the string that is to be logged and the second is the time period to log each character of the string. The default value of the time period is 50 ms.

Note: In the above example, a string has been provided as first argument. writer will log each character every 100 ms till the last character in the string.

. The dynamicWriter accepts a string as first parameter, followed by one or more arrays of two elements, each of which defines the word inside the provided string upto which the dynamicWriter has to log with a certain pace. dynamicWriter divides the provided string into sub strings as per the arguments and utilizes the writer to log each sub string. The first element of the array can be set as 'end//' which specifies the that upto the last character of the string will be logged as per the time period which will be specified in the next element.

Note: In the above example, a string has been provided followed by arrays. As specified, dynamicWriter will log each character every 50 ms upto the first '-', then each character every 150 ms upto the first 'be' and finally each character every 100 ms till the last character in the string.

Caution

Both dynamicWriter and writer returns as promise and therefore they are to be awaited to avoid any other logging statements before either of the function is completed.