UNPKG

@tangelo/tangelo-configuration-toolkit

Version:

Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.

24 lines (20 loc) 876 B
/* eslint-disable no-control-regex */ const styles = {bold: 1, underline: 4, black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37, lblack: 90, lred: 91, lgreen: 92, lyellow: 93, lblue: 94, lmagenta: 95, lcyan: 96, lwhite: 97}; for (const name in styles ) { Object.defineProperty(String.prototype, name, { get () { const _this = this.replace(/\x1b\[0m/g, `\x1b[${styles[name]}m`); // replace reset control with color for supporting multiple colors in string return `\x1b[${styles[name]}m${_this}\x1b[0m`; } }); } Object.defineProperty(String.prototype, 'nostyle', { get () { return this.replace(/[\u001b\u009b][[()#;?]*(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''); } }); Object.defineProperty(String.prototype, 'toFws', { get () { return this.replace(/\\/g, '/'); } });