node_modules/strip-ansi/index.js in immosquare-cleaner-0.1.22 vs node_modules/strip-ansi/index.js in immosquare-cleaner-0.1.23
- old
+ new
@@ -1,4 +1,14 @@
-'use strict';
-const ansiRegex = require('ansi-regex');
+import ansiRegex from 'ansi-regex';
-module.exports = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
+const regex = ansiRegex();
+
+export default function stripAnsi(string) {
+ if (typeof string !== 'string') {
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
+ }
+
+ // Even though the regex is global, we don't need to reset the `.lastIndex`
+ // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
+ // and doing it manually has a performance penalty.
+ return string.replace(regex, '');
+}