@kamilic/blockblock
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

npm version Build Status codecov

blockblock

Representing values use chars.

Usage

install

npm install @kamilic/blockblock

default

const BB = require('@kamilic/blockblock');
const b = BB();
b.value(10); // ██████████
b.value(10.1); // ██████████
b.value(10.126); // ██████████
b.value(10.25); // ██████████▎

b.percentage(10); // ██████████

custom emoji blockblock

const F = require('@kamilic/blockblock');
const b = F({
    max: 12,
    stepBlocks: ["😞", "😔", "😟", "😢", "😑", "😐", "😏", "🙂", "😀", "😆"]
});
b.value(10); // "😆😆😆😆😆😆😆😆😆😆"
b.value(10.125); // "😆😆😆😆😆😆😆😆😆😆😞"
b.value(10.2); // "😆😆😆😆😆😆😆😆😆😆😔"

b.precentage(100) // "😆😆😆😆😆😆😆😆😆😆😆😆"

Options

const F = require('@kamilic/blockblock');
const bb = F({
    // Maximum value
    max: 100,
    // Define different chars for represeting value (0 < value <= 1)
    // "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"
    // 1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8, 8/8
    stepBlocks: ["▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"]
});

Methods

  • bb.value(value: number): string - get blockblock string.
  • bb.percentage(percent: number): string - get blockblock string using percentage based on provided max.

Readme

Keywords

none

Package Sidebar

Install

npm i @kamilic/blockblock

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

19.9 kB

Total Files

10

Last publish

Collaborators

  • kamilic