@rimiti/stimmy
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = _default; | ||
exports.default = function (start = '{', end = '}') { | ||
function _default(start = '{', end = '}') { | ||
// remove RegExp specials | ||
const theStart = start.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
const theEnd = end.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
const arrayReg = new RegExp(`(${theStart}(.+?)${theEnd})`, 'g'); | ||
@@ -17,3 +17,2 @@ const objectReg = new RegExp(`(${theStart}([^}]+)${theEnd})`, 'g'); | ||
const endReg = new RegExp(`${theEnd}`, 'g'); | ||
return (value, items) => { | ||
@@ -27,4 +26,4 @@ if (typeof value === 'string' && items instanceof Array) { | ||
return value.replace(objectReg, i => { | ||
const key = i.replace(startReg, '').replace(endReg, ''); | ||
// $FlowFixMe: Flow doesn't understand computed values | ||
const key = i.replace(startReg, '').replace(endReg, ''); // $FlowFixMe: Flow doesn't understand computed values | ||
if (!items[key]) return i; | ||
@@ -34,7 +33,6 @@ return items[key]; | ||
} | ||
return value; | ||
}; | ||
}; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJzdGFydCIsImVuZCIsInRoZVN0YXJ0IiwicmVwbGFjZSIsInRoZUVuZCIsImFycmF5UmVnIiwiUmVnRXhwIiwib2JqZWN0UmVnIiwic3RhcnRSZWciLCJlbmRSZWciLCJ2YWx1ZSIsIml0ZW1zIiwiQXJyYXkiLCJpIiwiT2JqZWN0Iiwia2V5Il0sIm1hcHBpbmdzIjoiOzs7Ozs7a0JBQ2UsVUFBVUEsUUFBZ0IsR0FBMUIsRUFBK0JDLE1BQWMsR0FBN0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3RyaW5nLCBpdGVtczogQXJyYXk8bWl4ZWQ+IHwgT2JqZWN0KTogc3RyaW5nID0+IHtcbiAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnc3RyaW5nJyAmJiBpdGVtcyBpbnN0YW5jZW9mIEFycmF5KSB7XG4gICAgICAvLyAkRmxvd0ZpeE1lOiBGbG93IGRvZXNuJ3QgdW5kZXJzdGFuZCBjb21wdXRlZCB2YWx1ZXNcbiAgICAgIHJldHVybiB2YWx1ZS5yZXBsYWNlKGFycmF5UmVnLCAoaSkgPT4gaXRlbXNbaS5yZXBsYWNlKHN0YXJ0UmVnLCAnJykucmVwbGFjZShlbmRSZWcsICcnKV0pO1xuICAgIH1cblxuICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdzdHJpbmcnICYmIGl0ZW1zIGluc3RhbmNlb2YgT2JqZWN0KSB7XG4gICAgICByZXR1cm4gdmFsdWUucmVwbGFjZShvYmplY3RSZWcsIChpKSA9PiB7XG4gICAgICAgIGNvbnN0IGtleSA9IGkucmVwbGFjZShzdGFydFJlZywgJycpLnJlcGxhY2UoZW5kUmVnLCAnJyk7XG4gICAgICAgIC8vICRGbG93Rml4TWU6IEZsb3cgZG9lc24ndCB1bmRlcnN0YW5kIGNvbXB1dGVkIHZhbHVlc1xuICAgICAgICBpZiAoIWl0ZW1zW2tleV0pIHJldHVybiBpO1xuICAgICAgICByZXR1cm4gaXRlbXNba2V5XTtcbiAgICAgIH0pO1xuICAgIH1cbiAgICByZXR1cm4gdmFsdWU7XG4gIH07XG59XG4iXX0= | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJzdGFydCIsImVuZCIsInRoZVN0YXJ0IiwicmVwbGFjZSIsInRoZUVuZCIsImFycmF5UmVnIiwiUmVnRXhwIiwib2JqZWN0UmVnIiwic3RhcnRSZWciLCJlbmRSZWciLC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4gICAgfVxuICAgIHJldHVybiB2YWx1ZTtcbiAgfTtcbn1cbiJdfQ== |
{ | ||
"name": "@rimiti/stimmy", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Replace your string variables by your values easily.", | ||
@@ -45,17 +45,13 @@ "license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "~6.26.3", | ||
"babel-eslint": "~10.0.1", | ||
"babel-jest": "^23.6.0", | ||
"babel-plugin-add-module-exports": "^1.0.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "~6.26.2", | ||
"babel-plugin-transform-flow-strip-types": "~6.22.0", | ||
"babel-plugin-transform-runtime": "~6.23.0", | ||
"babel-preset-stage-3": "~6.24.1", | ||
"eslint": "^5.11.1", | ||
"eslint-config-airbnb-base": "~13.1.0", | ||
"eslint-plugin-flowtype": "~3.2.0", | ||
"eslint-plugin-import": "~2.14.0", | ||
"flow-bin": "~0.89.0", | ||
"jest": "^23.6.0" | ||
"@babel/cli": "7.12.10", | ||
"@babel/core": "7.12.10", | ||
"@babel/preset-env": "7.12.11", | ||
"@babel/preset-flow": "7.12.1", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "7.18.0", | ||
"eslint-config-airbnb-base": "14.2.1", | ||
"eslint-plugin-flowtype": "5.2.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"jest": "26.6.3", | ||
"flow-bin": "0.143.0" | ||
}, | ||
@@ -62,0 +58,0 @@ "jest": { |
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
11
10828
28