UNPKG

4.07 kBSource Map (JSON)View Raw
1{"version":3,"file":"value-extractor.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAwB,eAAID,IAE5BD,EAAqB,eAAIC,GAC1B,CATD,CASGK,MAAM,KACT,O,8tECwBAH,EAAOD,QAlCP,SAAwBK,EAAQC,GAAuB,IAAdC,EAAU,UAAH,6CAAG,CAAC,EAE5CC,EAAiB,CACrBC,WAAY,CAAC,IAAK,KAClBC,SAAS,GAGLC,EAAS,EAAH,KAAOH,GAAmBD,GACtC,IAAuCI,EAAOF,WAAU,GAAjDG,EAAc,KAAEC,EAAY,KAE7BC,EAAQ,IAAIC,OAAOT,EAAQU,QAAQ,IAAID,OAAO,GAAD,OAAIH,EAAc,iBAASC,GAAgB,KAAM,SAAU,KAGxGI,EAASZ,EAAOa,MAAMJ,GACtBK,EAAS,CAAC,EAChB,GAAIF,EAAQ,CACVA,EAAOG,QAGP,IAAIC,EAAa,EACjBf,EAAQU,QAAQ,IAAID,OAAO,GAAD,OAAIH,EAAc,iBAASC,GAAgB,MAAM,SAACK,EAAOI,GACjF,IAAIC,EAAQN,EAAOI,KACnBF,EAAOG,QAAiBE,IAAVD,EAAsBA,EAAQ,IAC9C,GACF,CAQA,OAAOJ,CACT,C,GChCIM,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBH,IAAjBI,EACH,OAAOA,EAAa5B,QAGrB,IAAIC,EAASwB,EAAyBE,GAAY,CAGjD3B,QAAS,CAAC,GAOX,OAHA6B,EAAoBF,GAAU1B,EAAQA,EAAOD,QAAS0B,GAG/CzB,EAAOD,OACf,CCnB0B0B,CAAoB,I,MDF1CD,C","sources":["webpack://valueExtractor/webpack/universalModuleDefinition","webpack://valueExtractor/./src/index.js","webpack://valueExtractor/webpack/bootstrap","webpack://valueExtractor/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"valueExtractor\"] = factory();\n\telse\n\t\troot[\"valueExtractor\"] = factory();\n})(this, () => {\nreturn ","function valueExtractor(string, pattern, options = {}) {\n \n const defaultOptions = {\n delimiters: ['{', '}'],\n partial: false,\n };\n\n const option = {...defaultOptions, ...options}\n const [startDelimiter, endDelimiter] = option.delimiters;\n \n const regex = new RegExp(pattern.replace(new RegExp(`${startDelimiter}(\\\\w+)${endDelimiter}`, 'g'), '(.*)?'), 'i')\n\n // Extract the values from the string\n const values = string.match(regex);\n const result = {};\n if (values) {\n values.shift();\n\n // Create an object with keys based on the pattern and values based on the extracted values\n let valueIndex = 0;\n pattern.replace(new RegExp(`${startDelimiter}(\\\\w+)${endDelimiter}`, 'g'), (match, key) => {\n let value = values[valueIndex++];\n result[key] = value !== undefined ? value : null;\n });\n } \n // else if (partial) {\n // // Create an object with keys based on the pattern and null values for all keys\n // pattern.replace(new RegExp(`${startDelimiter}(\\\\w+)${endDelimiter}`, 'g'), (match, key) => {\n // result[key] = null;\n // });\n // }\n\n return result;\n}\nmodule.exports = valueExtractor;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(88);\n"],"names":["root","factory","exports","module","define","amd","this","string","pattern","options","defaultOptions","delimiters","partial","option","startDelimiter","endDelimiter","regex","RegExp","replace","values","match","result","shift","valueIndex","key","value","undefined","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
\No newline at end of file