@domql/utils 2.5.71 → 2.5.76

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/array.js CHANGED
@@ -53,6 +53,7 @@ export const cutArrayBeforeValue = (arr, value) => {
53
53
  }
54
54
 
55
55
  export const cutArrayAfterValue = (arr, value) => {
56
+ if (!isArray(arr)) return
56
57
  const index = arr.indexOf(value)
57
58
  if (index !== -1) {
58
59
  return arr.slice(index + 1)
package/dist/cjs/array.js CHANGED
@@ -71,6 +71,8 @@ const cutArrayBeforeValue = (arr, value) => {
71
71
  return arr;
72
72
  };
73
73
  const cutArrayAfterValue = (arr, value) => {
74
+ if (!(0, import_types.isArray)(arr))
75
+ return;
74
76
  const index = arr.indexOf(value);
75
77
  if (index !== -1) {
76
78
  return arr.slice(index + 1);
@@ -36,13 +36,17 @@ const trimStringFromSymbols = (str, characters) => {
36
36
  const pattern = new RegExp(`[${characters.join("\\")}]`, "g");
37
37
  return str.replace(pattern, "");
38
38
  };
39
- const brackRegex = /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g;
40
- const replaceLiteralsWithObjectFields = (str, state) => {
41
- if (!str.includes("{{"))
39
+ const brackRegex = {
40
+ 2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
41
+ 3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
42
+ };
43
+ const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
44
+ if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
42
45
  return str;
43
- return str.replace(brackRegex, (_, parentPath, variable) => {
46
+ const reg = brackRegex[options.bracketsLength || 2];
47
+ return str.replace(reg, (_, parentPath, variable) => {
44
48
  if (parentPath) {
45
- const parentLevels = parentPath.match(/\.\.\//g).length;
49
+ const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
46
50
  let parentState = state;
47
51
  for (let i = 0; i < parentLevels; i++) {
48
52
  parentState = parentState.parent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.71",
3
+ "version": "2.5.76",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -23,7 +23,7 @@
23
23
  "build": "yarn build:cjs",
24
24
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
25
25
  },
26
- "gitHead": "2750ffc91678c3b2e02f21c82fe58bc593414adb",
26
+ "gitHead": "767e48d9adb22095984c0feb21fd92f045cdfe4a",
27
27
  "devDependencies": {
28
28
  "@babel/core": "^7.12.0"
29
29
  }
package/string.js CHANGED
@@ -24,12 +24,17 @@ export const trimStringFromSymbols = (str, characters) => {
24
24
  * @param {object} state - The object containing the values to substitute.
25
25
  * @returns {string} The modified string with placeholders replaced by values from the object.
26
26
  */
27
- const brackRegex = /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g
28
- export const replaceLiteralsWithObjectFields = (str, state) => {
29
- if (!str.includes('{{')) return str
30
- return str.replace(brackRegex, (_, parentPath, variable) => {
27
+ const brackRegex = {
28
+ 2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
29
+ 3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
30
+ }
31
+
32
+ export const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
33
+ if (!str.includes(options.bracketsLength === 3 ? '{{{' : '{{')) return str
34
+ const reg = brackRegex[options.bracketsLength || 2]
35
+ return str.replace(reg, (_, parentPath, variable) => {
31
36
  if (parentPath) {
32
- const parentLevels = parentPath.match(/\.\.\//g).length
37
+ const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length
33
38
  let parentState = state
34
39
  for (let i = 0; i < parentLevels; i++) {
35
40
  parentState = parentState.parent