@nyaomaru/divider 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -69,13 +69,9 @@ var regexCache = /* @__PURE__ */ new Map();
69
69
  function getRegex(separators) {
70
70
  if (isEmptyArray(separators)) return null;
71
71
  const key = JSON.stringify(separators);
72
- if (!regexCache.has(key)) {
73
- const pattern = separators.reduce(
74
- (acc, sep) => acc + escapeRegExp(sep),
75
- ""
76
- );
77
- regexCache.set(key, new RegExp(`[${pattern}]`, "g"));
78
- }
72
+ if (regexCache.has(key)) return regexCache.get(key);
73
+ const pattern = separators.reduce((acc, sep) => acc + escapeRegExp(sep), "");
74
+ regexCache.set(key, new RegExp(`[${pattern}]`, "g"));
79
75
  return regexCache.get(key);
80
76
  }
81
77
  function escapeRegExp(str) {
package/dist/index.js CHANGED
@@ -39,13 +39,9 @@ var regexCache = /* @__PURE__ */ new Map();
39
39
  function getRegex(separators) {
40
40
  if (isEmptyArray(separators)) return null;
41
41
  const key = JSON.stringify(separators);
42
- if (!regexCache.has(key)) {
43
- const pattern = separators.reduce(
44
- (acc, sep) => acc + escapeRegExp(sep),
45
- ""
46
- );
47
- regexCache.set(key, new RegExp(`[${pattern}]`, "g"));
48
- }
42
+ if (regexCache.has(key)) return regexCache.get(key);
43
+ const pattern = separators.reduce((acc, sep) => acc + escapeRegExp(sep), "");
44
+ regexCache.set(key, new RegExp(`[${pattern}]`, "g"));
49
45
  return regexCache.get(key);
50
46
  }
51
47
  function escapeRegExp(str) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nyaomaru/divider",
3
3
  "type": "module",
4
- "version": "1.8.1",
4
+ "version": "1.8.2",
5
5
  "description": "To divide string or string[] with a given separator",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",