site-panzai/node_modules/youch/build/helpers-B9BQYaS6.js
2026-11-13 13:57:04 +01:00

23 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import useColors from "@poppinss/colors";
const ANSI_REGEX = new RegExp([`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|"), "g");
function htmlEscape(value) {
return value.replace(/&/g, "&amp;").replace(/\\"/g, "&bsol;&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
function wordWrap(value, options) {
const width = options.width;
const indent = options.indent;
const newLine = `${options.newLine}${indent}`;
if (!width) return options.escape ? options.escape(value) : htmlEscape(value);
let regexString = ".{1," + width + "}";
regexString += "([\\s​]+|$)|[^\\s​]+?([\\s​]+|$)";
const re = new RegExp(regexString, "g");
return (value.match(re) || []).map(function(line) {
if (line.slice(-1) === "\n") line = line.slice(0, line.length - 1);
return options.escape ? options.escape(line) : htmlEscape(line);
}).join(newLine);
}
function stripAnsi(value) {
return value.replace(ANSI_REGEX, "");
}
const colors = useColors.ansi();
export { wordWrap as i, htmlEscape as n, stripAnsi as r, colors as t };