From 709af0868e6de4c9bd22316b9a41ab0170090b8b Mon Sep 17 00:00:00 2001 From: ehmicky Date: Fri, 26 Feb 2021 10:16:22 +0100 Subject: [PATCH] Small performance improvement when creating the RegExp (#4) --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 8ab64b4..3622820 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ 'use strict'; const ansiRegex = require('ansi-regex'); -// Removes the `g` flag -const regex = new RegExp(ansiRegex().source); +const regex = ansiRegex({onlyFirst: true}); module.exports = string => regex.test(string);