From 5a33b916670e5a8917ae0d51a0cff63a624ae405 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 29 Oct 2023 09:24:54 +0000 Subject: [PATCH] chore(index): add inline comment explaining regex cache --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index 4360e56..904aa77 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ const errorMessages = { 3221225477: "Segmentation fault", }; +// Cache immutable regex as they are expensive to create and garbage collect const unrtfPathRegex = /(.+)unrtf/u; const unrtfVersionRegex = /^(\d{1,2}\.\d{1,2}\.\d{1,2})/u; const rtfMagicNumberRegex = /^\{\\rtf/u;