UNPKG

@visulima/ansi

Version:

ANSI escape codes for some terminal swag.

21 lines (17 loc) 870 B
'use strict'; var __defProp$1 = Object.defineProperty; var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true }); function ansiRegex({ onlyFirst = false } = {}) { const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)"; const pattern = [ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))" ].join("|"); return new RegExp(pattern, onlyFirst ? void 0 : "g"); } __name$1(ansiRegex, "ansiRegex"); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const regex = ansiRegex(); const strip = /* @__PURE__ */ __name((input) => input.replace(/\u001B\]0;.*\u0007/, "").replace(regex, ""), "strip"); module.exports = strip;