@k8ts/instruments
Version:
A collection of utilities and core components for k8ts.
64 lines • 2.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMarkerForIndex = getMarkerForIndex;
exports.getMarkerForExternal = getMarkerForExternal;
const chalk_1 = __importDefault(require("chalk"));
const interchangeable = {
diamond: "◆",
star: "★",
four_shapes: "❖",
four_star: "✦",
star_circled_filled: "✪",
aster: "✱",
helm: "☸ ",
ball_circled: "◉",
lines_circled: "◍ ",
plus_circled: "⊕ ",
triangle_down: "▼",
dot_triangled: "◬",
diamond_diamonded: "◈",
circle_squared_filled: "◙",
triangle_filled_half: "◭",
heart_arrow: "❥",
bullet_squared_filled: "◘",
copyright: "©",
section: "§",
paragraph: "¶",
weird_circle: "¤",
euro: "€",
yen: "¥",
plus_filled: "✚",
mac_char: "⌘ "
};
const colors = [
chalk_1.default.redBright,
chalk_1.default.yellowBright,
chalk_1.default.blue,
chalk_1.default.magenta,
chalk_1.default.cyan,
chalk_1.default.blueBright
];
const numbered = Object.values(interchangeable);
// We want to have symbols be as distinct as possible
// that means we use each symbol with a different color
// Instead of using all symbols of a single color, then all symbols of another color
// We mix it up, so we only get repeat colors after all symbols have been used
// we can get combinations of color + symbol like this:
// symbol = i % symbols.length
// color = (Math.floor(i / colors.length) + i)
function getMarkerForIndex(index) {
const clampedIndex = index % numbered.length;
const multiplier = Math.floor(index / numbered.length);
const char = numbered[clampedIndex];
const color = colors[(multiplier + clampedIndex) % colors.length];
const colored = color(char);
return `${colored} `;
}
function getMarkerForExternal() {
const external = "∃";
return chalk_1.default.yellowBright(external);
}
//# sourceMappingURL=markers.js.map