Simple terminal spinners for Deno

Simple terminal spinners for Deno

Kia Simple terminal spinners for Deno Kia is based on, and has much of the features of, ora. The project was also influenced by the work of: cli-spinners, and CLI Spinners for Deno

Kia

Simple terminal spinners for Deno 🦕

Version 0.4.0

weather.ts example

Kia is based on, and has much of the features of, ora. The project was also influenced by the work of: cli-spinners, and CLI Spinners for Deno

Usage

import Kia from "https://deno.land/x/[email protected]/mod.ts";

// Just a function to async sleep
function sleep(ms: number) {
    return new Promise((resolve) => setTimeout(resolve, ms));
}

const kia: any = new Kia("I will be back in about 3 seconds");
kia.start();
await sleep(3000) // or any other async action that'll take some time
kia.succeed("Action completed");

More thorough examples are available in the examples folder

API

kia()

kia(text)

kia(options)

Kia can be created with a string or the Options interface. A string is simply mapped to Options.text

const kia = new Kia("Hello");
// or
const kia = new Kia({
    text: "Hello",
    color: "Red",
});
options

You can pass any of the following options to the kia context:

text

Type: String

Default: ""

The text to display after the spinner

color

Type: Color

Default: "white"

The color for the spinner to be. Uses the color type in util.ts, which maps to the Deno standard colors.

spinner

Type: Spinner

Default: Dependent on OS (See below)

The spinner that the Kia instance should use. There are spinners provided in spinners.ts or you can provide it with an object like so:

    {
        interval: 80,
        frames: ["-", "|"]
    }

On windows the spinner defaults to windows, while on other OSes it defaults to dots.

Spinners can also be imported from anywhere as long as they follow this format. See the examples/externalSpinners.ts example for more info.

indent

Type: number

Default: 0

The level of indentation of the spinner in spaces

cursor

Type: boolean

Default: false

Whether or not to display a cursor when the spinner is active

writer

Type: Deno.Writer

Default: Deno.stdout

The resource to output to. This can be anything that uses the Writer interface including stdout, stderr, and files.

Instance

.start(text?)

Starts the spinner. Optionally sets the text at the same time. Returns Kia instance.

.stop()

Stops the spinner and clears the line. Returns Kia instance.

.set(text)

.set(options)

Allows you to change the spinners options. Returns Kia instance.

const kia = new Kia("Hello");
kia.set({ text: "Goodbye", color: "Red" });

.succeed(text?)

.fail(text?)

.warn(text?)

.info(text?)

Stops the spinner, and returns a message with the current text or the provided text as well as an icon indicating status. Wraps around stopWithFlair(). Returns Kia instance.

.stopWithFlair(text, flair)

Stops the spinner, and returns a message with the current text or the provided text as well as the preceding flair/icon. Returns Kia instance.

.stopAndPersist(options)

Stops the spinner and holds it in a static state. Returns the instance.

.renderNextFrame()

Renders the next frame of the spinner when it is stopped (i.e. can only be run after .stopAndPersist()).

.getText()

Returns the current text of the spinner

.getFrame()

Returns the current spinner frame

forPromise(action, text)

forPromise(action, options)

import { forPromise } from "https://deno.land/x/[email protected]/mod.ts";

forPromise(
    async () => {
        await yourAsyncAction();
    },
    { text: name }
);

Starts a spinner for a promise. The spinner is stopped with .succeed() if the promise fulfills or with .fail() if it rejects. Returns the spinner instance.

action

Type: Promise

Download Details:

Author: HarryPeach

Source Code: https://github.com/HarryPeach/kia

deno node nodejs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings