@mudbean/pen-static
v1.1.3
Published
一点点 🤏 color-pen 的静态数据
Readme
@mudbean/pen-static
安装
npm install --save @mudbean/pen-staticANSI 模块相关
escANSI 转义符csiCSI(Control Sequence Introducer)带[的esc字符串\u001b[或者是\x1bterminalResetStyle重置属性样式,即\x1b[0mterminalRegExp一个用于创建 ANSI 的正则字符串的函数,可用与判断字符串是否包含 ANSI 转义或是清理
esc
esc 表示 ANSI 的控制序列前缀描述,即 \x1b 或者是 \u001b。
import { esc } from '@mudbean/pen-static';
// 光标向上
const cursorMoveUpStr = esc.concat('[2A');
console.log(cursorMoveUpStr);csi
csi 表示 ANSI 的控制序列,即 \x1b[ 或者是 \u001b[。
import { csi } from '@mudbean/pen-static';
// 光标向上
const cursorMoveUpStr = csi.concat('2A');
console.log(cursorMoveUpStr);terminalResetStyle
terminalRestStyle 表示 ANSI 的属性重置,即 \x1b[0m 或 \u001b[0m 或 \x1b[m 或 \u001b[m。
import { pen } from '@mudbean/pen';
import { terminalResetStyle } from '@mudbean/pen-static';
pen.red`我是红色的文本${terminalResetStyle.concat('其实,在使用 terminalResetStyle 的时候会被截断,而最后的返回,这里也是红的')}我也是红色的`;terminalRegExp 正则
生成一段长的 ANSI 正则字符串,用于判断字符串是否包含 ANSI 转义或是清理字符串中的 ANSI 转义码。
import { terminalRegExp } from '@mudbean/pen-static';
const tempRegExp = terminalRegExp();
tempRegExp.latestIndex = 0;
console.log(tempRegExp.test('\x1b[0m')); // true
tempRegExp.latestIndex = 0;
console.log(tempRegExp.test('\x1b[?25l')); // true
tempRegExp.latestIndex = 0;
console.log(tempRegExp.test('\x1b[38;5;236m')); // true状态
此软件包是 @mudbean 生态系统的一部分。
它使用严格的 TypeScript 编写,并通过 Rollup 构建进行验证。
虽然单元测试较少,但 API 稳定,并在生产环境中大量使用。
