@domql/utils 2.3.153 → 2.4.0
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/LICENSE +1 -1
- package/cookie.js +28 -0
- package/dist/cjs/cookie.js +50 -0
- package/dist/cjs/env.js +32 -0
- package/dist/cjs/globals.js +30 -0
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/key.js +33 -0
- package/dist/cjs/object.js +10 -9
- package/dist/cjs/string.js +2 -1
- package/env.js +10 -0
- package/globals.js +8 -0
- package/index.js +4 -1
- package/key.js +14 -0
- package/object.js +10 -7
- package/package.json +10 -5
- package/string.js +9 -2
package/LICENSE
CHANGED
package/cookie.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { isUndefined } from './types'
|
|
4
|
+
|
|
5
|
+
export const isMobile = (() => typeof navigator === 'undefined'
|
|
6
|
+
? false
|
|
7
|
+
: /Mobi/.test(navigator.userAgent))()
|
|
8
|
+
|
|
9
|
+
export const setCookie = (cname, cvalue, exdays = 365) => {
|
|
10
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return
|
|
11
|
+
const d = new Date()
|
|
12
|
+
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
|
|
13
|
+
const expires = `expires=${d.toUTCString()}`
|
|
14
|
+
document.cookie = `${cname}=${cvalue};${expires};path=/`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getCookie = (cname) => {
|
|
18
|
+
if (isUndefined(document) || isUndefined(document.cookie)) return
|
|
19
|
+
const name = `${cname}=`
|
|
20
|
+
const decodedCookie = decodeURIComponent(document.cookie)
|
|
21
|
+
const ca = decodedCookie.split(';')
|
|
22
|
+
for (let i = 0; i < ca.length; i++) {
|
|
23
|
+
let c = ca[i]
|
|
24
|
+
while (c.charAt(0) === ' ') c = c.substring(1)
|
|
25
|
+
if (c.indexOf(name) === 0) return c.substring(name.length, c.length)
|
|
26
|
+
}
|
|
27
|
+
return ''
|
|
28
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cookie_exports = {};
|
|
20
|
+
__export(cookie_exports, {
|
|
21
|
+
getCookie: () => getCookie,
|
|
22
|
+
isMobile: () => isMobile,
|
|
23
|
+
setCookie: () => setCookie
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cookie_exports);
|
|
26
|
+
var import_types = require("./types");
|
|
27
|
+
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
28
|
+
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
29
|
+
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
30
|
+
return;
|
|
31
|
+
const d = /* @__PURE__ */ new Date();
|
|
32
|
+
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
33
|
+
const expires = `expires=${d.toUTCString()}`;
|
|
34
|
+
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
35
|
+
};
|
|
36
|
+
const getCookie = (cname) => {
|
|
37
|
+
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
38
|
+
return;
|
|
39
|
+
const name = `${cname}=`;
|
|
40
|
+
const decodedCookie = decodeURIComponent(document.cookie);
|
|
41
|
+
const ca = decodedCookie.split(";");
|
|
42
|
+
for (let i = 0; i < ca.length; i++) {
|
|
43
|
+
let c = ca[i];
|
|
44
|
+
while (c.charAt(0) === " ")
|
|
45
|
+
c = c.substring(1);
|
|
46
|
+
if (c.indexOf(name) === 0)
|
|
47
|
+
return c.substring(name.length, c.length);
|
|
48
|
+
}
|
|
49
|
+
return "";
|
|
50
|
+
};
|
package/dist/cjs/env.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var env_exports = {};
|
|
20
|
+
__export(env_exports, {
|
|
21
|
+
NODE_ENV: () => NODE_ENV,
|
|
22
|
+
getNev: () => getNev,
|
|
23
|
+
isDevelopment: () => isDevelopment,
|
|
24
|
+
isProduction: () => isProduction,
|
|
25
|
+
isTest: () => isTest
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(env_exports);
|
|
28
|
+
const NODE_ENV = "development";
|
|
29
|
+
const isProduction = (env = NODE_ENV) => env === "production" || env === "prod" || env !== "development" && env !== "dev" && env !== "test";
|
|
30
|
+
const isTest = (env = NODE_ENV) => env === "test";
|
|
31
|
+
const isDevelopment = (env = NODE_ENV) => env === "development" || env === "dev";
|
|
32
|
+
const getNev = (key, env = NODE_ENV) => env[key];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var globals_exports = {};
|
|
20
|
+
__export(globals_exports, {
|
|
21
|
+
document: () => document,
|
|
22
|
+
global: () => global,
|
|
23
|
+
self: () => self,
|
|
24
|
+
window: () => window
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(globals_exports);
|
|
27
|
+
const global = globalThis;
|
|
28
|
+
const self = globalThis;
|
|
29
|
+
const window = globalThis;
|
|
30
|
+
const document = window.document;
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var utils_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(utils_exports);
|
|
18
|
-
__reExport(utils_exports, require("
|
|
18
|
+
__reExport(utils_exports, require("./key.js"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./env.js"), module.exports);
|
|
19
20
|
__reExport(utils_exports, require("./types.js"), module.exports);
|
|
20
21
|
__reExport(utils_exports, require("./object.js"), module.exports);
|
|
21
22
|
__reExport(utils_exports, require("./function.js"), module.exports);
|
|
@@ -23,3 +24,5 @@ __reExport(utils_exports, require("./array.js"), module.exports);
|
|
|
23
24
|
__reExport(utils_exports, require("./node.js"), module.exports);
|
|
24
25
|
__reExport(utils_exports, require("./log.js"), module.exports);
|
|
25
26
|
__reExport(utils_exports, require("./string.js"), module.exports);
|
|
27
|
+
__reExport(utils_exports, require("./globals.js"), module.exports);
|
|
28
|
+
__reExport(utils_exports, require("./cookie.js"), module.exports);
|
package/dist/cjs/key.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var key_exports = {};
|
|
20
|
+
__export(key_exports, {
|
|
21
|
+
createKey: () => createKey,
|
|
22
|
+
createSnapshotId: () => createSnapshotId
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(key_exports);
|
|
25
|
+
const createKey = function() {
|
|
26
|
+
let index = 0;
|
|
27
|
+
function newId() {
|
|
28
|
+
index++;
|
|
29
|
+
return index;
|
|
30
|
+
}
|
|
31
|
+
return newId;
|
|
32
|
+
}();
|
|
33
|
+
const createSnapshotId = createKey;
|
package/dist/cjs/object.js
CHANGED
|
@@ -64,9 +64,8 @@ const map = (obj, extention, element) => {
|
|
|
64
64
|
};
|
|
65
65
|
const merge = (element, obj, excludeFrom = []) => {
|
|
66
66
|
for (const e in obj) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
67
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e);
|
|
68
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__"))
|
|
70
69
|
continue;
|
|
71
70
|
const elementProp = element[e];
|
|
72
71
|
const objProp = obj[e];
|
|
@@ -78,9 +77,8 @@ const merge = (element, obj, excludeFrom = []) => {
|
|
|
78
77
|
};
|
|
79
78
|
const deepMerge = (element, extend, excludeFrom = []) => {
|
|
80
79
|
for (const e in extend) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
80
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e);
|
|
81
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith("__"))
|
|
84
82
|
continue;
|
|
85
83
|
const elementProp = element[e];
|
|
86
84
|
const extendProp = extend[e];
|
|
@@ -95,7 +93,8 @@ const deepMerge = (element, extend, excludeFrom = []) => {
|
|
|
95
93
|
const clone = (obj, excludeFrom = []) => {
|
|
96
94
|
const o = {};
|
|
97
95
|
for (const prop in obj) {
|
|
98
|
-
|
|
96
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
97
|
+
if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith("__"))
|
|
99
98
|
continue;
|
|
100
99
|
o[prop] = obj[prop];
|
|
101
100
|
}
|
|
@@ -107,7 +106,8 @@ const deepCloneExclude = (obj, excludeFrom = []) => {
|
|
|
107
106
|
}
|
|
108
107
|
const o = {};
|
|
109
108
|
for (const k in obj) {
|
|
110
|
-
|
|
109
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, k);
|
|
110
|
+
if (!hasOwnProperty || excludeFrom.includes(k) || k.startsWith("__"))
|
|
111
111
|
continue;
|
|
112
112
|
let v = obj[k];
|
|
113
113
|
if (k === "extend" && (0, import_types.isArray)(v)) {
|
|
@@ -231,7 +231,8 @@ const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
|
231
231
|
};
|
|
232
232
|
const deepDestringify = (obj, stringified = {}) => {
|
|
233
233
|
for (const prop in obj) {
|
|
234
|
-
|
|
234
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop);
|
|
235
|
+
if (!hasOwnProperty)
|
|
235
236
|
continue;
|
|
236
237
|
const objProp = obj[prop];
|
|
237
238
|
if ((0, import_types.isString)(objProp)) {
|
package/dist/cjs/string.js
CHANGED
|
@@ -30,10 +30,11 @@ const stringIncludesAny = (str, characters) => {
|
|
|
30
30
|
}
|
|
31
31
|
return false;
|
|
32
32
|
};
|
|
33
|
+
const brackRegex = /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g;
|
|
33
34
|
const replaceLiteralsWithObjectFields = (str, state) => {
|
|
34
35
|
if (!str.includes("{{"))
|
|
35
36
|
return str;
|
|
36
|
-
return str.replace(
|
|
37
|
+
return str.replace(brackRegex, (_, parentPath, variable) => {
|
|
37
38
|
if (parentPath) {
|
|
38
39
|
const parentLevels = parentPath.match(/\.\.\//g).length;
|
|
39
40
|
let parentState = state;
|
package/env.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const NODE_ENV = process.env.NODE_ENV
|
|
4
|
+
|
|
5
|
+
export const isProduction = (env = NODE_ENV) => (env === 'production' || env === 'prod') ||
|
|
6
|
+
(env !== 'development' && env !== 'dev' && env !== 'test')
|
|
7
|
+
export const isTest = (env = NODE_ENV) => env === 'test'
|
|
8
|
+
export const isDevelopment = (env = NODE_ENV) => env === 'development' || env === 'dev'
|
|
9
|
+
|
|
10
|
+
export const getNev = (key, env = NODE_ENV) => env[key]
|
package/globals.js
ADDED
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
export * from '
|
|
3
|
+
export * from './key.js'
|
|
4
|
+
export * from './env.js'
|
|
4
5
|
export * from './types.js'
|
|
5
6
|
export * from './object.js'
|
|
6
7
|
export * from './function.js'
|
|
@@ -8,3 +9,5 @@ export * from './array.js'
|
|
|
8
9
|
export * from './node.js'
|
|
9
10
|
export * from './log.js'
|
|
10
11
|
export * from './string.js'
|
|
12
|
+
export * from './globals.js'
|
|
13
|
+
export * from './cookie.js'
|
package/key.js
ADDED
package/object.js
CHANGED
|
@@ -24,8 +24,8 @@ export const map = (obj, extention, element) => {
|
|
|
24
24
|
|
|
25
25
|
export const merge = (element, obj, excludeFrom = []) => {
|
|
26
26
|
for (const e in obj) {
|
|
27
|
-
|
|
28
|
-
if (excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
27
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e)
|
|
28
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
29
29
|
const elementProp = element[e]
|
|
30
30
|
const objProp = obj[e]
|
|
31
31
|
if (elementProp === undefined) {
|
|
@@ -37,8 +37,8 @@ export const merge = (element, obj, excludeFrom = []) => {
|
|
|
37
37
|
|
|
38
38
|
export const deepMerge = (element, extend, excludeFrom = []) => {
|
|
39
39
|
for (const e in extend) {
|
|
40
|
-
|
|
41
|
-
if (excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
40
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e)
|
|
41
|
+
if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
42
42
|
const elementProp = element[e]
|
|
43
43
|
const extendProp = extend[e]
|
|
44
44
|
if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
|
|
@@ -53,7 +53,8 @@ export const deepMerge = (element, extend, excludeFrom = []) => {
|
|
|
53
53
|
export const clone = (obj, excludeFrom = []) => {
|
|
54
54
|
const o = {}
|
|
55
55
|
for (const prop in obj) {
|
|
56
|
-
|
|
56
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
|
|
57
|
+
if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__')) continue
|
|
57
58
|
o[prop] = obj[prop]
|
|
58
59
|
}
|
|
59
60
|
return o
|
|
@@ -67,7 +68,8 @@ export const deepCloneExclude = (obj, excludeFrom = []) => {
|
|
|
67
68
|
|
|
68
69
|
const o = {}
|
|
69
70
|
for (const k in obj) {
|
|
70
|
-
|
|
71
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, k)
|
|
72
|
+
if (!hasOwnProperty || excludeFrom.includes(k) || k.startsWith('__')) continue
|
|
71
73
|
|
|
72
74
|
let v = obj[k]
|
|
73
75
|
|
|
@@ -208,7 +210,8 @@ export const detachFunctionsFromObject = (obj, detached = {}) => {
|
|
|
208
210
|
*/
|
|
209
211
|
export const deepDestringify = (obj, stringified = {}) => {
|
|
210
212
|
for (const prop in obj) {
|
|
211
|
-
|
|
213
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
|
|
214
|
+
if (!hasOwnProperty) continue
|
|
212
215
|
const objProp = obj[prop]
|
|
213
216
|
if (isString(objProp)) {
|
|
214
217
|
if (objProp.includes('=>') || objProp.includes('function') || objProp.startsWith('(')) {
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"main": "index.js",
|
|
8
|
-
"exports":
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"kalduna": "./index.js",
|
|
11
|
+
"default": "./dist/cjs/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
9
14
|
"source": "index.js",
|
|
10
15
|
"files": [
|
|
11
16
|
"*.js",
|
|
12
17
|
"dist"
|
|
13
18
|
],
|
|
14
19
|
"scripts": {
|
|
15
|
-
"copy:package:cjs": "cp
|
|
20
|
+
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
16
21
|
"build:esm": "npx esbuild *.js --target=es2019 --format=esm --outdir=dist/esm",
|
|
17
22
|
"build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
18
23
|
"build": "yarn build:cjs",
|
|
@@ -21,9 +26,9 @@
|
|
|
21
26
|
"dependencies": {
|
|
22
27
|
"@domql/globals": "latest",
|
|
23
28
|
"@domql/key": "latest",
|
|
24
|
-
"@domql/tags": "
|
|
29
|
+
"@domql/tags": "^2.3.117"
|
|
25
30
|
},
|
|
26
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "d01a7237a0065a5a439a03062064076c5fdc91b7",
|
|
27
32
|
"devDependencies": {
|
|
28
33
|
"@babel/core": "^7.12.0"
|
|
29
34
|
}
|
package/string.js
CHANGED
|
@@ -8,10 +8,17 @@ export const stringIncludesAny = (str, characters) => {
|
|
|
8
8
|
}
|
|
9
9
|
return false
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Replaces placeholders in a string with corresponding {{ }} values from an object.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} str - The string containing placeholders to replace.
|
|
15
|
+
* @param {object} state - The object containing the values to substitute.
|
|
16
|
+
* @returns {string} The modified string with placeholders replaced by values from the object.
|
|
17
|
+
*/
|
|
18
|
+
const brackRegex = /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g
|
|
12
19
|
export const replaceLiteralsWithObjectFields = (str, state) => {
|
|
13
20
|
if (!str.includes('{{')) return str
|
|
14
|
-
return str.replace(
|
|
21
|
+
return str.replace(brackRegex, (_, parentPath, variable) => {
|
|
15
22
|
if (parentPath) {
|
|
16
23
|
const parentLevels = parentPath.match(/\.\.\//g).length
|
|
17
24
|
let parentState = state
|