@domql/utils
Advanced tools
Comparing version 2.5.167 to 2.5.168
@@ -49,10 +49,11 @@ "use strict"; | ||
}; | ||
const replaceLiteralsWithObjectFields = (str, state, options = {}) => { | ||
function replaceLiteralsWithObjectFields(str, options = {}, forcedState) { | ||
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{")) | ||
return str; | ||
const reg = brackRegex[options.bracketsLength || 2]; | ||
const obj = forcedState || this.state || {}; | ||
return str.replace(reg, (_, parentPath, variable) => { | ||
if (parentPath) { | ||
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length; | ||
let parentState = state; | ||
let parentState = obj; | ||
for (let i = 0; i < parentLevels; i++) { | ||
@@ -67,7 +68,7 @@ parentState = parentState.parent; | ||
} else { | ||
const value = state[variable.trim()]; | ||
const value = obj[variable.trim()]; | ||
return value !== void 0 ? `${value}` : ""; | ||
} | ||
}); | ||
}; | ||
} | ||
const lowercaseFirstLetter = (inputString) => { | ||
@@ -74,0 +75,0 @@ return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`; |
@@ -17,10 +17,11 @@ const stringIncludesAny = (str, characters) => { | ||
}; | ||
const replaceLiteralsWithObjectFields = (str, state, options = {}) => { | ||
function replaceLiteralsWithObjectFields(str, options = {}, forcedState) { | ||
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{")) | ||
return str; | ||
const reg = brackRegex[options.bracketsLength || 2]; | ||
const obj = forcedState || this.state || {}; | ||
return str.replace(reg, (_, parentPath, variable) => { | ||
if (parentPath) { | ||
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length; | ||
let parentState = state; | ||
let parentState = obj; | ||
for (let i = 0; i < parentLevels; i++) { | ||
@@ -35,7 +36,7 @@ parentState = parentState.parent; | ||
} else { | ||
const value = state[variable.trim()]; | ||
const value = obj[variable.trim()]; | ||
return value !== void 0 ? `${value}` : ""; | ||
} | ||
}); | ||
}; | ||
} | ||
const lowercaseFirstLetter = (inputString) => { | ||
@@ -42,0 +43,0 @@ return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`; |
{ | ||
"name": "@domql/utils", | ||
"version": "2.5.167", | ||
"version": "2.5.168", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "type": "module", | ||
}, | ||
"gitHead": "3851b6d1029397dcf61c44682be5b9c234993e74", | ||
"gitHead": "6c935c3d1ff70096bb532e9c5426ffc5af0677dc", | ||
"devDependencies": { | ||
@@ -31,0 +31,0 @@ "@babel/core": "^7.12.0" |
@@ -32,9 +32,10 @@ 'use strict' | ||
export const replaceLiteralsWithObjectFields = (str, state, options = {}) => { | ||
export function replaceLiteralsWithObjectFields (str, options = {}, forcedState) { | ||
if (!str.includes(options.bracketsLength === 3 ? '{{{' : '{{')) return str | ||
const reg = brackRegex[options.bracketsLength || 2] | ||
const obj = forcedState || this.state || {} | ||
return str.replace(reg, (_, parentPath, variable) => { | ||
if (parentPath) { | ||
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length | ||
let parentState = state | ||
let parentState = obj | ||
for (let i = 0; i < parentLevels; i++) { | ||
@@ -49,3 +50,3 @@ parentState = parentState.parent | ||
} else { | ||
const value = state[variable.trim()] | ||
const value = obj[variable.trim()] | ||
return value !== undefined ? `${value}` : '' | ||
@@ -52,0 +53,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154319
4905