@socketsecurity/lib
Version:
Core utilities and infrastructure for Socket.dev security tools
63 lines (62 loc) • 2.12 kB
JavaScript
;
/* Socket Lib - Built with esbuild */
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ansi_exports = {};
__export(ansi_exports, {
ANSI_BOLD: () => ANSI_BOLD,
ANSI_DIM: () => ANSI_DIM,
ANSI_ITALIC: () => ANSI_ITALIC,
ANSI_RESET: () => ANSI_RESET,
ANSI_STRIKETHROUGH: () => ANSI_STRIKETHROUGH,
ANSI_UNDERLINE: () => ANSI_UNDERLINE,
ansiRegex: () => ansiRegex,
stripAnsi: () => stripAnsi
});
module.exports = __toCommonJS(ansi_exports);
const ANSI_RESET = "\x1B[0m";
const ANSI_BOLD = "\x1B[1m";
const ANSI_DIM = "\x1B[2m";
const ANSI_ITALIC = "\x1B[3m";
const ANSI_UNDERLINE = "\x1B[4m";
const ANSI_STRIKETHROUGH = "\x1B[9m";
const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
// @__NO_SIDE_EFFECTS__
function ansiRegex(options) {
const { onlyFirst } = options ?? {};
const ST = "(?:\\u0007\\u001B\\u005C|\\u009C)";
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
const pattern = `${osc}|${csi}`;
return new RegExp(pattern, onlyFirst ? void 0 : "g");
}
// @__NO_SIDE_EFFECTS__
function stripAnsi(text) {
return text.replace(ANSI_REGEX, "");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ANSI_BOLD,
ANSI_DIM,
ANSI_ITALIC,
ANSI_RESET,
ANSI_STRIKETHROUGH,
ANSI_UNDERLINE,
ansiRegex,
stripAnsi
});