data-restructor 3.4.0 → 3.4.2
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/.auto-changelog +9 -0
- package/.auto-changelog-template.hbs +36 -0
- package/.github/workflows/codeql-analysis.yml +1 -1
- package/.github/workflows/continuous-integration.yaml +10 -1
- package/CHANGELOG.md +136 -31
- package/Commands.md +1 -0
- package/README.md +5 -0
- package/coverage/coverage-summary.json +3 -3
- package/coverage/datarestructor.js.html +133 -133
- package/coverage/describedfield.js.html +45 -45
- package/coverage/index.html +1 -1
- package/coverage/templateResolver.js.html +26 -26
- package/devdist/datarestructor-ie.js +53 -58
- package/devdist/datarestructor.js +35 -42
- package/devdist/describedfield-ie.js +10 -12
- package/devdist/describedfield.js +8 -10
- package/devdist/templateResolver-ie.js +22 -26
- package/devdist/templateResolver.js +11 -16
- package/dist/datarestructor-ie.js +693 -1
- package/dist/datarestructor-ie.js.map +1 -1
- package/dist/datarestructor.js +687 -1
- package/dist/datarestructor.js.map +1 -1
- package/dist/describedfield-ie.js +142 -1
- package/dist/describedfield-ie.js.map +1 -1
- package/dist/describedfield.js +142 -1
- package/dist/describedfield.js.map +1 -1
- package/dist/templateResolver-ie.js +82 -1
- package/dist/templateResolver-ie.js.map +1 -1
- package/dist/templateResolver.js +76 -1
- package/dist/templateResolver.js.map +1 -1
- package/docs/datarestructor.js.html +1 -1
- package/docs/describedfield.js.html +1 -1
- package/docs/index.html +6 -1
- package/docs/module-datarestructor.DescribedEntryCreator.html +94 -94
- package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
- package/docs/module-datarestructor.Restructor.html +1 -1
- package/docs/module-datarestructor.Transform.html +605 -605
- package/docs/module-datarestructor.html +959 -995
- package/docs/module-described_field.DescribedDataFieldBuilder.html +1 -1
- package/docs/module-described_field.DescribedDataFieldGroup.html +1 -1
- package/docs/module-described_field.html +1 -37
- package/docs/module-template_resolver.Resolver.html +167 -167
- package/docs/module-template_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G,OAAA5E,QAAiB,CAAC6E,kBAAoBC","sources":["src/js/templateResolver.js","lib/js/flattenToArray.js","lib/js/polyfills/indexOfPolyfill.js","lib/js/polyfills/objectKeysPolyfill.js","src/js/templateResolver-ie.js"],"sourcesContent":["/**\n * @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = templateResolverInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction templateResolverInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @module template_resolver\n */\nvar template_resolver = (module.exports = {}); // Export module for npm...\ntemplate_resolver.internalCreateIfNotExists = templateResolverInternalCreateIfNotExists;\n\nvar internal_object_tools = internal_object_tools || require(\"../../lib/js/flattenToArray\"); // supports vanilla js & npm\n\ntemplate_resolver.Resolver = (function () {\n var removeArrayBracketsRegEx = new RegExp(\"\\\\[\\\\d+\\\\]\", \"gi\");\n\n /**\n * Resolver. Is used inside this repository. It could also be used outside.\n * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.\n * @constructs Resolver\n * @alias module:template_resolver.Resolver\n */\n function Resolver(sourceDataObject) {\n /**\n * The properties of this source data object will be used to replace the placeholders in the template.\n */\n this.sourceDataObject = sourceDataObject;\n /**\n * Resolves the given template.\n *\n * The template may contain variables in double curly brackets.\n * Supported variables are all properties of this object, e.g. \"{{fieldName}}\", \"{{displayName}}\", \"{{value}}\".\n * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. \"{{summaries[0].value}}\"\n * Parts of the index can be inserted by using e.g. \"{{index[1]}}\".\n *\n * @param {string} template\n * @returns {string} resolved template\n */\n this.resolveTemplate = function (template) {\n return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));\n };\n /**\n * Returns a map like object, that contains all resolvable fields and their values as properties.\n * This function takes a variable count of input parameters,\n * each containing an object that contains resolvable fields to extract from.\n *\n * The recursion depth is limited to 3, so that an object,\n * that contains an object can contain another object (but not further).\n *\n * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.\n *\n * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.\n * @returns {object} object with resolvable field names and their values.\n * @public\n */\n this.resolvableFieldsOfAll = function () {\n var map = {};\n var ignoreInternalFields = function (propertyName) {\n return propertyName.indexOf(\"_\") !== 0 && propertyName.indexOf(\"._\") < 0;\n };\n var index;\n for (index = 0; index < arguments.length; index += 1) {\n addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);\n }\n return map;\n };\n /**\n * Replaces all variables in double curly brackets, e.g. {{property}},\n * with the value of that property from the resolvableProperties.\n *\n * Supported property types: string, number, boolean\n * @param {string} stringContainingVariables\n * @param {object[]} resolvableFields (name=value)\n */\n this.replaceResolvableFields = function (stringContainingVariables, resolvableFields) {\n var replaced = stringContainingVariables;\n var propertyNames = Object.keys(resolvableFields);\n var propertyIndex = 0;\n var propertyName = \"\";\n var propertyValue = \"\";\n for (propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1) {\n propertyName = propertyNames[propertyIndex];\n propertyValue = resolvableFields[propertyName];\n replaced = replaced.replace(\"{{\" + propertyName + \"}}\", propertyValue);\n }\n return replaced;\n };\n }\n\n /**\n * Adds the value of the \"fieldName\" property (including its group prefix) and its associated \"value\" property content.\n * For example: detail[2].fieldName=\"name\", detail[2].value=\"Smith\" lead to the additional property detail.name=\"Smith\".\n * @param {object} object with resolvable field names and their values.\n * @returns {object} object with resolvable field names and their values.\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addFieldsPerGroup(map) {\n var propertyNames = Object.keys(map);\n var i, fullPropertyName, propertyInfo, propertyValue;\n for (i = 0; i < propertyNames.length; i += 1) {\n fullPropertyName = propertyNames[i];\n propertyValue = map[fullPropertyName];\n propertyInfo = getPropertyNameInfos(fullPropertyName);\n // Supports fields that are defined by a property named \"fieldName\" (containing the name)\n // and a property named \"value\" inside the same sub object (containing its value).\n // Ignore custom fields that are named \"fieldName\"(propertyValue), since this would lead to an unpredictable behavior.\n // TODO could make \"fieldName\" and \"value\" configurable\n if (propertyInfo.name === \"fieldName\" && propertyValue !== \"fieldName\") {\n map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + \"value\"];\n }\n }\n return map;\n }\n\n /**\n * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.\n * @param {String} fullPropertyName\n * @returns {Object} Contains \"group\" (empty or group name including trailing separator \".\"), \"groupWithoutArrayIndices\" and \"name\" (property name).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function getPropertyNameInfos(fullPropertyName) {\n var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(\".\");\n var propertyName = fullPropertyName;\n if (positionOfRightMostSeparator > 0) {\n propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);\n }\n var propertyGroup = \"\";\n if (positionOfRightMostSeparator > 0) {\n propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing \".\".\n }\n var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, \"\");\n return { group: propertyGroup, groupWithoutArrayIndices: propertyGroupWithoutArrayIndices, name: propertyName };\n }\n\n /**\n * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).\n * Example: `{name: \"accountNumber\", value: \"12345\"}` becomes `mapObject[\"accountNumber\"]=\"12345\"`.\n *\n * @param {NameValuePair[]} elements flattened array of name-value-pairs\n * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.\n * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {\n var index, element;\n for (index = 0; index < elements.length; index += 1) {\n element = elements[index];\n if (typeof filterMatchesFunction === \"function\" && filterMatchesFunction(element.name)) {\n mapObject[element.name] = element.value;\n }\n }\n return mapObject;\n }\n\n return Resolver;\n}());\n","\"use strict\";\n/**\n * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss\n * @version ${project.version}\n * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}\n */\nvar module = module || {}; // Fallback for vanilla js without modules\n\n/**\n * internal_object_tools. Not meant to be used outside this repository.\n * @default {}\n */\nvar internal_object_tools = module.exports={}; // Export module for npm...\n\n/**\n * @typedef {Object} NameValuePair\n * @property {string} name - point separated names of the flattened main and sub properties, e.g. \"responses[2].hits.hits[4]._source.name\".\n * @property {string} value - value of the property\n */\n\n/**\n * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.\n * @param {number} maxRecursionDepth\n * @returns {NameValuePair[]} array of property name and value pairs\n */\ninternal_object_tools.flattenToArray = function (data, maxRecursionDepth) {\n var result = [];\n if (typeof maxRecursionDepth !== \"number\" || maxRecursionDepth < 1) {\n maxRecursionDepth = 20;\n }\n function recurse(cur, prop, depth) {\n if (depth > maxRecursionDepth || typeof cur === \"function\") {\n return;\n }\n if (Object(cur) !== cur) {\n result.push({ name: prop, value: cur });\n } else if (Array.isArray(cur)) {\n var i;\n var l = cur.length;\n for (i = 0; i < l; i += 1) {\n recurse(cur[i], prop + \"[\" + i + \"]\", depth + 1);\n }\n if (l === 0) {\n result[prop] = [];\n result.push({ name: prop, value: \"\" });\n }\n } else {\n var isEmpty = true;\n var p;\n for (p in cur) {\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p, depth + 1);\n }\n if (isEmpty && prop) {\n result.push({ name: prop, value: \"\" });\n }\n }\n }\n recurse(data, \"\", 0);\n return result;\n};\n","//https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill\nif (!Array.prototype.indexOf) Array.prototype.indexOf = (function(Object, max, min){\n \"use strict\";\n return function indexOf(member, fromIndex) {\n if(this===null||this===undefined)throw TypeError(\"Array.prototype.indexOf called on null or undefined\");\n \n var that = Object(this), Len = that.length >>> 0, i = min(fromIndex | 0, Len);\n if (i < 0) i = max(0, Len+i); else if (i >= Len) return -1;\n \n if(member===void 0){ for(; i !== Len; ++i) if(that[i]===void 0 && i in that) return i; // undefined\n }else if(member !== member){ for(; i !== Len; ++i) if(that[i] !== that[i]) return i; // NaN\n }else for(; i !== Len; ++i) if(that[i] === member) return i; // all else\n \n return -1; // if the value was not found, then return -1\n };\n })(Object, Math.max, Math.min);","//http://tokenposts.blogspot.com/2012/04/javascript-objectkeys-browser.html\nif (!Object.keys) Object.keys = function(o) {\n if (o !== Object(o))\n throw new TypeError('Object.keys called on a non-object');\n var k=[],p;\n for (p in o) if (Object.prototype.hasOwnProperty.call(o,p)) k.push(p);\n return k;\n }","\"use strict\";\nrequire(\"../../lib/js/polyfills/indexOfPolyfill.js\");\nrequire(\"../../lib/js/polyfills/objectKeysPolyfill.js\");\nvar template_resolver = require(\"../../src/js/templateResolver.js\");\nmodule.exports = {template_resolver : template_resolver};\n"],"names":["$03246337b2ee5537$var$module","$03246337b2ee5537$var$templateResolverInternalCreateIfNotExists","objectToCheck","$03246337b2ee5537$var$template_resolver","exports","internalCreateIfNotExists","$03246337b2ee5537$var$internal_object_tools","parcelRequire","Resolver","removeArrayBracketsRegEx","RegExp","getPropertyNameInfos","fullPropertyName","positionOfRightMostSeparator","lastIndexOf","propertyName","substr","propertyGroup","propertyGroupWithoutArrayIndices","replace","group","groupWithoutArrayIndices","name","addToFilteredMapObject","elements","mapObject","filterMatchesFunction","index","element","length","value","sourceDataObject","this","resolveTemplate","template","replaceResolvableFields","map","i","propertyInfo","propertyValue","propertyNames","Object","keys","addFieldsPerGroup","resolvableFieldsOfAll","ignoreInternalFields","indexOf","arguments","flattenToArray","stringContainingVariables","resolvableFields","replaced","propertyIndex","$4ee7050bd023907f$var$module","data","maxRecursionDepth","result","recurse","cur","prop","depth","push","Array","isArray","l","p","isEmpty","prototype","max","min","member","fromIndex","TypeError","that","Len","Math","o","k","hasOwnProperty","call","module","template_resolver","$gIYWy"],"version":3,"file":"templateResolver-ie.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":"A,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,I,E,E,Q,C,E,Q,S,C,C,C,ECAA,sGAAsG;AACtG,GAAI,CAAC,MAAM,SAAS,CAAC,OAAO,CAAG,KAAoC,EAAQ,EAAK,CAAjD,CAAA,MAAM,SAAS,CAAC,OAAO,EAAa,EAc9D,OAdsE,EAc9D,KAAK,GAAG,CAd2D,EAczD,KAAK,GAAG,CAZpB,SAAiB,CAAM,CAAE,CAAS,EACvC,GAAG,IAAI,GAAG,MAAM,AAAO,KAAA,IAAP,IAAI,CAAa,MAAM,UAAU,uDAEjD,IAAI,EAAO,EAAO,IAAI,EAAG,EAAM,EAAK,MAAM,GAAK,EAAG,EAAI,EAAI,AAAY,EAAZ,EAAe,GACzE,GAAI,EAAI,EAAG,EAAI,EAAI,EAAG,EAAI,QAAS,GAAI,GAAK,EAAK,OAAO,GAExD,GAAG,AAAS,KAAK,IAAd,EAAkB,CAAA,KAAM,IAAM,EAAK,EAAE,EAAG,GAAG,AAAU,KAAK,IAAf,CAAI,CAAC,EAAE,EAAa,KAAK,EAAM,OAAO,CAAG,aAAY;AAAf,MAC9E,GAAG,GAAW,EAAW,CAAA,KAAM,IAAM,EAAK,EAAE,EAAG,GAAG,CAAI,CA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,CAAG,CAAC,EAAE,CAAE,EAAO,EAAO,IAAM,EAAI,EAAG,EAAQ,GAEjD,GAAW,GACb,EAAO,IAAI,CAAC,CAAE,KAAM,EAAM,MAAO,EAAG,EAExC,EACF,EACQ,EAAM,GAAI,GACX,CACT,C,G,E,S,E,S,I,E,E,QCxDA,CAAA,OAAA,OAAA,CAAiB,CAAC,kBAAoB,CAAiB,C,gD","sources":["<anon>","lib/js/polyfills/indexOfPolyfill.js","lib/js/polyfills/objectKeysPolyfill.js","src/js/templateResolver.js","lib/js/flattenToArray.js","src/js/templateResolver-ie.js"],"sourcesContent":["\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirec1f2\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirec1f2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"3kxfc\", function(module, exports) {\n//https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill\nif (!Array.prototype.indexOf) Array.prototype.indexOf = function(Object1, max, min) {\n \"use strict\";\n return function indexOf(member, fromIndex) {\n if (this === null || this === undefined) throw TypeError(\"Array.prototype.indexOf called on null or undefined\");\n var that = Object1(this), Len = that.length >>> 0, i = min(fromIndex | 0, Len);\n if (i < 0) i = max(0, Len + i);\n else if (i >= Len) return -1;\n if (member === void 0) {\n for(; i !== Len; ++i)if (that[i] === void 0 && i in that) return i; // undefined\n } else if (member !== member) {\n for(; i !== Len; ++i)if (that[i] !== that[i]) return i; // NaN\n } else for(; i !== Len; ++i)if (that[i] === member) return i; // all else\n return -1; // if the value was not found, then return -1\n };\n}(Object, Math.max, Math.min);\n\n});\n\nparcelRegister(\"26y7f\", function(module, exports) {\n//http://tokenposts.blogspot.com/2012/04/javascript-objectkeys-browser.html\nif (!Object.keys) Object.keys = function(o) {\n if (o !== Object(o)) throw new TypeError(\"Object.keys called on a non-object\");\n var k = [], p;\n for(p in o)if (Object.prototype.hasOwnProperty.call(o, p)) k.push(p);\n return k;\n};\n\n});\n\nparcelRegister(\"8ZIyB\", function(module, exports) {\n/**\n * @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */ \"use strict\";\nvar $68c6955ebe469375$var$module = $68c6955ebe469375$var$templateResolverInternalCreateIfNotExists($68c6955ebe469375$var$module); // Fallback for vanilla js without modules\nfunction $68c6955ebe469375$var$templateResolverInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n/**\n * Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @module template_resolver\n */ var $68c6955ebe469375$var$template_resolver = $68c6955ebe469375$var$module.exports = {}; // Export module for npm...\n$68c6955ebe469375$var$template_resolver.internalCreateIfNotExists = $68c6955ebe469375$var$templateResolverInternalCreateIfNotExists;\n\nvar $68c6955ebe469375$var$internal_object_tools = $68c6955ebe469375$var$internal_object_tools || (parcelRequire(\"7HmuL\")); // supports vanilla js & npm\n$68c6955ebe469375$var$template_resolver.Resolver = function() {\n var removeArrayBracketsRegEx = new RegExp(\"\\\\[\\\\d+\\\\]\", \"gi\");\n /**\n * Resolver. Is used inside this repository. It could also be used outside.\n * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.\n * @constructs Resolver\n * @alias module:template_resolver.Resolver\n */ function Resolver(sourceDataObject) {\n /**\n * The properties of this source data object will be used to replace the placeholders in the template.\n */ this.sourceDataObject = sourceDataObject;\n /**\n * Resolves the given template.\n *\n * The template may contain variables in double curly brackets.\n * Supported variables are all properties of this object, e.g. \"{{fieldName}}\", \"{{displayName}}\", \"{{value}}\".\n * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. \"{{summaries[0].value}}\"\n * Parts of the index can be inserted by using e.g. \"{{index[1]}}\".\n *\n * @param {string} template\n * @returns {string} resolved template\n */ this.resolveTemplate = function(template) {\n return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));\n };\n /**\n * Returns a map like object, that contains all resolvable fields and their values as properties.\n * This function takes a variable count of input parameters,\n * each containing an object that contains resolvable fields to extract from.\n *\n * The recursion depth is limited to 3, so that an object,\n * that contains an object can contain another object (but not further).\n *\n * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.\n *\n * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.\n * @returns {object} object with resolvable field names and their values.\n * @public\n */ this.resolvableFieldsOfAll = function() {\n var map = {};\n var ignoreInternalFields = function(propertyName) {\n return propertyName.indexOf(\"_\") !== 0 && propertyName.indexOf(\"._\") < 0;\n };\n var index;\n for(index = 0; index < arguments.length; index += 1)addToFilteredMapObject($68c6955ebe469375$var$internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);\n return map;\n };\n /**\n * Replaces all variables in double curly brackets, e.g. {{property}},\n * with the value of that property from the resolvableProperties.\n *\n * Supported property types: string, number, boolean\n * @param {string} stringContainingVariables\n * @param {object[]} resolvableFields (name=value)\n */ this.replaceResolvableFields = function(stringContainingVariables, resolvableFields) {\n var replaced = stringContainingVariables;\n var propertyNames = Object.keys(resolvableFields);\n var propertyIndex = 0;\n var propertyName = \"\";\n var propertyValue = \"\";\n for(propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1){\n propertyName = propertyNames[propertyIndex];\n propertyValue = resolvableFields[propertyName];\n replaced = replaced.replace(\"{{\" + propertyName + \"}}\", propertyValue);\n }\n return replaced;\n };\n }\n /**\n * Adds the value of the \"fieldName\" property (including its group prefix) and its associated \"value\" property content.\n * For example: detail[2].fieldName=\"name\", detail[2].value=\"Smith\" lead to the additional property detail.name=\"Smith\".\n * @param {object} object with resolvable field names and their values.\n * @returns {object} object with resolvable field names and their values.\n * @protected\n * @memberof module:template_resolver.Resolver\n */ function addFieldsPerGroup(map) {\n var propertyNames = Object.keys(map);\n var i, fullPropertyName, propertyInfo, propertyValue;\n for(i = 0; i < propertyNames.length; i += 1){\n fullPropertyName = propertyNames[i];\n propertyValue = map[fullPropertyName];\n propertyInfo = getPropertyNameInfos(fullPropertyName);\n // Supports fields that are defined by a property named \"fieldName\" (containing the name)\n // and a property named \"value\" inside the same sub object (containing its value).\n // Ignore custom fields that are named \"fieldName\"(propertyValue), since this would lead to an unpredictable behavior.\n // TODO could make \"fieldName\" and \"value\" configurable\n if (propertyInfo.name === \"fieldName\" && propertyValue !== \"fieldName\") map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + \"value\"];\n }\n return map;\n }\n /**\n * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.\n * @param {String} fullPropertyName\n * @returns {Object} Contains \"group\" (empty or group name including trailing separator \".\"), \"groupWithoutArrayIndices\" and \"name\" (property name).\n * @protected\n * @memberof module:template_resolver.Resolver\n */ function getPropertyNameInfos(fullPropertyName) {\n var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(\".\");\n var propertyName = fullPropertyName;\n if (positionOfRightMostSeparator > 0) propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);\n var propertyGroup = \"\";\n if (positionOfRightMostSeparator > 0) propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing \".\".\n var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, \"\");\n return {\n group: propertyGroup,\n groupWithoutArrayIndices: propertyGroupWithoutArrayIndices,\n name: propertyName\n };\n }\n /**\n * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).\n * Example: `{name: \"accountNumber\", value: \"12345\"}` becomes `mapObject[\"accountNumber\"]=\"12345\"`.\n *\n * @param {NameValuePair[]} elements flattened array of name-value-pairs\n * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.\n * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).\n * @protected\n * @memberof module:template_resolver.Resolver\n */ function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {\n var index, element;\n for(index = 0; index < elements.length; index += 1){\n element = elements[index];\n if (typeof filterMatchesFunction === \"function\" && filterMatchesFunction(element.name)) mapObject[element.name] = element.value;\n }\n return mapObject;\n }\n return Resolver;\n}();\n\n});\nparcelRegister(\"7HmuL\", function(module, exports) {\n\"use strict\";\n/**\n * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss\n * @version ${project.version}\n * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}\n */ var $59adffa3db62607f$var$module = $59adffa3db62607f$var$module || {}; // Fallback for vanilla js without modules\n/**\n * internal_object_tools. Not meant to be used outside this repository.\n * @default {}\n */ var $59adffa3db62607f$var$internal_object_tools = $59adffa3db62607f$var$module.exports = {}; // Export module for npm...\n/**\n * @typedef {Object} NameValuePair\n * @property {string} name - point separated names of the flattened main and sub properties, e.g. \"responses[2].hits.hits[4]._source.name\".\n * @property {string} value - value of the property\n */ /**\n * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.\n * @param {number} maxRecursionDepth\n * @returns {NameValuePair[]} array of property name and value pairs\n */ $59adffa3db62607f$var$internal_object_tools.flattenToArray = function(data, maxRecursionDepth) {\n var result = [];\n if (typeof maxRecursionDepth !== \"number\" || maxRecursionDepth < 1) maxRecursionDepth = 20;\n function recurse(cur, prop, depth) {\n if (depth > maxRecursionDepth || typeof cur === \"function\") return;\n if (Object(cur) !== cur) result.push({\n name: prop,\n value: cur\n });\n else if (Array.isArray(cur)) {\n var i;\n var l = cur.length;\n for(i = 0; i < l; i += 1)recurse(cur[i], prop + \"[\" + i + \"]\", depth + 1);\n if (l === 0) {\n result[prop] = [];\n result.push({\n name: prop,\n value: \"\"\n });\n }\n } else {\n var isEmpty = true;\n var p;\n for(p in cur){\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p, depth + 1);\n }\n if (isEmpty && prop) result.push({\n name: prop,\n value: \"\"\n });\n }\n }\n recurse(data, \"\", 0);\n return result;\n};\n\n});\n\n\n\"use strict\";\nparcelRequire(\"3kxfc\");\nparcelRequire(\"26y7f\");\n\nvar $8ZIyB = parcelRequire(\"8ZIyB\");\nmodule.exports = {\n template_resolver: $8ZIyB\n};\n\n\n//# sourceMappingURL=templateResolver-ie.js.map\n","//https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill\nif (!Array.prototype.indexOf) Array.prototype.indexOf = (function(Object, max, min){\n \"use strict\";\n return function indexOf(member, fromIndex) {\n if(this===null||this===undefined)throw TypeError(\"Array.prototype.indexOf called on null or undefined\");\n \n var that = Object(this), Len = that.length >>> 0, i = min(fromIndex | 0, Len);\n if (i < 0) i = max(0, Len+i); else if (i >= Len) return -1;\n \n if(member===void 0){ for(; i !== Len; ++i) if(that[i]===void 0 && i in that) return i; // undefined\n }else if(member !== member){ for(; i !== Len; ++i) if(that[i] !== that[i]) return i; // NaN\n }else for(; i !== Len; ++i) if(that[i] === member) return i; // all else\n \n return -1; // if the value was not found, then return -1\n };\n })(Object, Math.max, Math.min);","//http://tokenposts.blogspot.com/2012/04/javascript-objectkeys-browser.html\nif (!Object.keys) Object.keys = function(o) {\n if (o !== Object(o))\n throw new TypeError('Object.keys called on a non-object');\n var k=[],p;\n for (p in o) if (Object.prototype.hasOwnProperty.call(o,p)) k.push(p);\n return k;\n }","/**\n * @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = templateResolverInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction templateResolverInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @module template_resolver\n */\nvar template_resolver = (module.exports = {}); // Export module for npm...\ntemplate_resolver.internalCreateIfNotExists = templateResolverInternalCreateIfNotExists;\n\nvar internal_object_tools = internal_object_tools || require(\"../../lib/js/flattenToArray\"); // supports vanilla js & npm\n\ntemplate_resolver.Resolver = (function () {\n var removeArrayBracketsRegEx = new RegExp(\"\\\\[\\\\d+\\\\]\", \"gi\");\n\n /**\n * Resolver. Is used inside this repository. It could also be used outside.\n * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.\n * @constructs Resolver\n * @alias module:template_resolver.Resolver\n */\n function Resolver(sourceDataObject) {\n /**\n * The properties of this source data object will be used to replace the placeholders in the template.\n */\n this.sourceDataObject = sourceDataObject;\n /**\n * Resolves the given template.\n *\n * The template may contain variables in double curly brackets.\n * Supported variables are all properties of this object, e.g. \"{{fieldName}}\", \"{{displayName}}\", \"{{value}}\".\n * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. \"{{summaries[0].value}}\"\n * Parts of the index can be inserted by using e.g. \"{{index[1]}}\".\n *\n * @param {string} template\n * @returns {string} resolved template\n */\n this.resolveTemplate = function (template) {\n return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));\n };\n /**\n * Returns a map like object, that contains all resolvable fields and their values as properties.\n * This function takes a variable count of input parameters,\n * each containing an object that contains resolvable fields to extract from.\n *\n * The recursion depth is limited to 3, so that an object,\n * that contains an object can contain another object (but not further).\n *\n * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.\n *\n * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.\n * @returns {object} object with resolvable field names and their values.\n * @public\n */\n this.resolvableFieldsOfAll = function () {\n var map = {};\n var ignoreInternalFields = function (propertyName) {\n return propertyName.indexOf(\"_\") !== 0 && propertyName.indexOf(\"._\") < 0;\n };\n var index;\n for (index = 0; index < arguments.length; index += 1) {\n addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);\n }\n return map;\n };\n /**\n * Replaces all variables in double curly brackets, e.g. {{property}},\n * with the value of that property from the resolvableProperties.\n *\n * Supported property types: string, number, boolean\n * @param {string} stringContainingVariables\n * @param {object[]} resolvableFields (name=value)\n */\n this.replaceResolvableFields = function (stringContainingVariables, resolvableFields) {\n var replaced = stringContainingVariables;\n var propertyNames = Object.keys(resolvableFields);\n var propertyIndex = 0;\n var propertyName = \"\";\n var propertyValue = \"\";\n for (propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1) {\n propertyName = propertyNames[propertyIndex];\n propertyValue = resolvableFields[propertyName];\n replaced = replaced.replace(\"{{\" + propertyName + \"}}\", propertyValue);\n }\n return replaced;\n };\n }\n\n /**\n * Adds the value of the \"fieldName\" property (including its group prefix) and its associated \"value\" property content.\n * For example: detail[2].fieldName=\"name\", detail[2].value=\"Smith\" lead to the additional property detail.name=\"Smith\".\n * @param {object} object with resolvable field names and their values.\n * @returns {object} object with resolvable field names and their values.\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addFieldsPerGroup(map) {\n var propertyNames = Object.keys(map);\n var i, fullPropertyName, propertyInfo, propertyValue;\n for (i = 0; i < propertyNames.length; i += 1) {\n fullPropertyName = propertyNames[i];\n propertyValue = map[fullPropertyName];\n propertyInfo = getPropertyNameInfos(fullPropertyName);\n // Supports fields that are defined by a property named \"fieldName\" (containing the name)\n // and a property named \"value\" inside the same sub object (containing its value).\n // Ignore custom fields that are named \"fieldName\"(propertyValue), since this would lead to an unpredictable behavior.\n // TODO could make \"fieldName\" and \"value\" configurable\n if (propertyInfo.name === \"fieldName\" && propertyValue !== \"fieldName\") {\n map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + \"value\"];\n }\n }\n return map;\n }\n\n /**\n * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.\n * @param {String} fullPropertyName\n * @returns {Object} Contains \"group\" (empty or group name including trailing separator \".\"), \"groupWithoutArrayIndices\" and \"name\" (property name).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function getPropertyNameInfos(fullPropertyName) {\n var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(\".\");\n var propertyName = fullPropertyName;\n if (positionOfRightMostSeparator > 0) {\n propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);\n }\n var propertyGroup = \"\";\n if (positionOfRightMostSeparator > 0) {\n propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing \".\".\n }\n var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, \"\");\n return { group: propertyGroup, groupWithoutArrayIndices: propertyGroupWithoutArrayIndices, name: propertyName };\n }\n\n /**\n * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).\n * Example: `{name: \"accountNumber\", value: \"12345\"}` becomes `mapObject[\"accountNumber\"]=\"12345\"`.\n *\n * @param {NameValuePair[]} elements flattened array of name-value-pairs\n * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.\n * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {\n var index, element;\n for (index = 0; index < elements.length; index += 1) {\n element = elements[index];\n if (typeof filterMatchesFunction === \"function\" && filterMatchesFunction(element.name)) {\n mapObject[element.name] = element.value;\n }\n }\n return mapObject;\n }\n\n return Resolver;\n}());\n","\"use strict\";\n/**\n * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss\n * @version ${project.version}\n * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}\n */\nvar module = module || {}; // Fallback for vanilla js without modules\n\n/**\n * internal_object_tools. Not meant to be used outside this repository.\n * @default {}\n */\nvar internal_object_tools = module.exports={}; // Export module for npm...\n\n/**\n * @typedef {Object} NameValuePair\n * @property {string} name - point separated names of the flattened main and sub properties, e.g. \"responses[2].hits.hits[4]._source.name\".\n * @property {string} value - value of the property\n */\n\n/**\n * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.\n * @param {number} maxRecursionDepth\n * @returns {NameValuePair[]} array of property name and value pairs\n */\ninternal_object_tools.flattenToArray = function (data, maxRecursionDepth) {\n var result = [];\n if (typeof maxRecursionDepth !== \"number\" || maxRecursionDepth < 1) {\n maxRecursionDepth = 20;\n }\n function recurse(cur, prop, depth) {\n if (depth > maxRecursionDepth || typeof cur === \"function\") {\n return;\n }\n if (Object(cur) !== cur) {\n result.push({ name: prop, value: cur });\n } else if (Array.isArray(cur)) {\n var i;\n var l = cur.length;\n for (i = 0; i < l; i += 1) {\n recurse(cur[i], prop + \"[\" + i + \"]\", depth + 1);\n }\n if (l === 0) {\n result[prop] = [];\n result.push({ name: prop, value: \"\" });\n }\n } else {\n var isEmpty = true;\n var p;\n for (p in cur) {\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p, depth + 1);\n }\n if (isEmpty && prop) {\n result.push({ name: prop, value: \"\" });\n }\n }\n }\n recurse(data, \"\", 0);\n return result;\n};\n","\"use strict\";\nrequire(\"../../lib/js/polyfills/indexOfPolyfill.js\");\nrequire(\"../../lib/js/polyfills/objectKeysPolyfill.js\");\nvar template_resolver = require(\"../../src/js/templateResolver.js\");\nmodule.exports = {template_resolver : template_resolver};\n"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","Array","prototype","indexOf","Object1","max","min","Object","Math","member","fromIndex","undefined","TypeError","that","Len","length","i","keys","o","p","k","hasOwnProperty","push","removeArrayBracketsRegEx","$68c6955ebe469375$var$module","$68c6955ebe469375$var$templateResolverInternalCreateIfNotExists","objectToCheck","$68c6955ebe469375$var$template_resolver","internalCreateIfNotExists","$68c6955ebe469375$var$internal_object_tools","Resolver","RegExp","sourceDataObject","resolveTemplate","template","replaceResolvableFields","addFieldsPerGroup","map","fullPropertyName","propertyInfo","propertyValue","propertyNames","getPropertyNameInfos","positionOfRightMostSeparator","lastIndexOf","propertyName","substr","propertyGroup","propertyGroupWithoutArrayIndices","replace","group","groupWithoutArrayIndices","name","resolvableFieldsOfAll","index","ignoreInternalFields","arguments","addToFilteredMapObject","elements","mapObject","filterMatchesFunction","element","value","flattenToArray","stringContainingVariables","resolvableFields","replaced","propertyIndex","$59adffa3db62607f$var$internal_object_tools","$59adffa3db62607f$var$module","data","maxRecursionDepth","result","recurse","cur","prop","depth","isArray","l","isEmpty","$8ZIyB","template_resolver"],"version":3,"file":"templateResolver-ie.js.map","sourceRoot":"../"}
|
package/dist/templateResolver.js
CHANGED
|
@@ -1,2 +1,77 @@
|
|
|
1
|
-
var e=
|
|
1
|
+
var e=globalThis,r={},t={},n=e.parcelRequirec1f2;null==n&&((n=function(e){if(e in r)return r[e].exports;if(e in t){var n=t[e];delete t[e];var a={id:e,exports:{}};return r[e]=a,n.call(a.exports,a,a.exports),a.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,r){t[e]=r},e.parcelRequirec1f2=n);var a=n.register;a("8ZIyB",function(e,r){var t,a=o(a);// Fallback for vanilla js without modules
|
|
2
|
+
function o(e){return e||{}}/**
|
|
3
|
+
* Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.
|
|
4
|
+
* @module template_resolver
|
|
5
|
+
*/var i=a.exports={};// Export module for npm...
|
|
6
|
+
i.internalCreateIfNotExists=o;var u=u||n("7HmuL");// supports vanilla js & npm
|
|
7
|
+
i.Resolver=(t=RegExp("\\[\\d+\\]","gi"),/**
|
|
8
|
+
* Resolver. Is used inside this repository. It could also be used outside.
|
|
9
|
+
* @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.
|
|
10
|
+
* @constructs Resolver
|
|
11
|
+
* @alias module:template_resolver.Resolver
|
|
12
|
+
*/function(e){/**
|
|
13
|
+
* The properties of this source data object will be used to replace the placeholders in the template.
|
|
14
|
+
*/this.sourceDataObject=e,/**
|
|
15
|
+
* Resolves the given template.
|
|
16
|
+
*
|
|
17
|
+
* The template may contain variables in double curly brackets.
|
|
18
|
+
* Supported variables are all properties of this object, e.g. "{{fieldName}}", "{{displayName}}", "{{value}}".
|
|
19
|
+
* Since this object may also contains (described) groups of sub objects, they can also be used, e.g. "{{summaries[0].value}}"
|
|
20
|
+
* Parts of the index can be inserted by using e.g. "{{index[1]}}".
|
|
21
|
+
*
|
|
22
|
+
* @param {string} template
|
|
23
|
+
* @returns {string} resolved template
|
|
24
|
+
*/this.resolveTemplate=function(e){return this.replaceResolvableFields(e,/**
|
|
25
|
+
* Adds the value of the "fieldName" property (including its group prefix) and its associated "value" property content.
|
|
26
|
+
* For example: detail[2].fieldName="name", detail[2].value="Smith" lead to the additional property detail.name="Smith".
|
|
27
|
+
* @param {object} object with resolvable field names and their values.
|
|
28
|
+
* @returns {object} object with resolvable field names and their values.
|
|
29
|
+
* @protected
|
|
30
|
+
* @memberof module:template_resolver.Resolver
|
|
31
|
+
*/function(e){var r,n,a,o,i=Object.keys(e);for(r=0;r<i.length;r+=1)o=e[n=i[r]],"fieldName"===(a=/**
|
|
32
|
+
* Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.
|
|
33
|
+
* @param {String} fullPropertyName
|
|
34
|
+
* @returns {Object} Contains "group" (empty or group name including trailing separator "."), "groupWithoutArrayIndices" and "name" (property name).
|
|
35
|
+
* @protected
|
|
36
|
+
* @memberof module:template_resolver.Resolver
|
|
37
|
+
*/function(e){var r=e.lastIndexOf("."),n=e;r>0&&(n=e.substr(r+1));var a="";r>0&&(a=e.substr(0,r+1));//includes the trailing ".".
|
|
38
|
+
var o=a.replace(t,"");return{group:a,groupWithoutArrayIndices:o,name:n}}(n)).name&&"fieldName"!==o&&(e[a.groupWithoutArrayIndices+o]=e[a.group+"value"]);return e}(this.resolvableFieldsOfAll(this.sourceDataObject)))},/**
|
|
39
|
+
* Returns a map like object, that contains all resolvable fields and their values as properties.
|
|
40
|
+
* This function takes a variable count of input parameters,
|
|
41
|
+
* each containing an object that contains resolvable fields to extract from.
|
|
42
|
+
*
|
|
43
|
+
* The recursion depth is limited to 3, so that an object,
|
|
44
|
+
* that contains an object can contain another object (but not further).
|
|
45
|
+
*
|
|
46
|
+
* Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.
|
|
47
|
+
*
|
|
48
|
+
* @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.
|
|
49
|
+
* @returns {object} object with resolvable field names and their values.
|
|
50
|
+
* @public
|
|
51
|
+
*/this.resolvableFieldsOfAll=function(){var e,r={},t=function(e){return 0!==e.indexOf("_")&&0>e.indexOf("._")};for(e=0;e<arguments.length;e+=1)/**
|
|
52
|
+
* Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).
|
|
53
|
+
* Example: `{name: "accountNumber", value: "12345"}` becomes `mapObject["accountNumber"]="12345"`.
|
|
54
|
+
*
|
|
55
|
+
* @param {NameValuePair[]} elements flattened array of name-value-pairs
|
|
56
|
+
* @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.
|
|
57
|
+
* @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).
|
|
58
|
+
* @protected
|
|
59
|
+
* @memberof module:template_resolver.Resolver
|
|
60
|
+
*/(function(e,r,t){var n,a;for(n=0;n<e.length;n+=1)a=e[n],"function"==typeof t&&t(a.name)&&(r[a.name]=a.value)})(u.flattenToArray(arguments[e],3),r,t);return r},/**
|
|
61
|
+
* Replaces all variables in double curly brackets, e.g. {{property}},
|
|
62
|
+
* with the value of that property from the resolvableProperties.
|
|
63
|
+
*
|
|
64
|
+
* Supported property types: string, number, boolean
|
|
65
|
+
* @param {string} stringContainingVariables
|
|
66
|
+
* @param {object[]} resolvableFields (name=value)
|
|
67
|
+
*/this.replaceResolvableFields=function(e,r){var t=e,n=Object.keys(r),a=0,o="",i="";for(a=0;a<n.length;a+=1)i=r[o=n[a]],t=t.replace("{{"+o+"}}",i);return t}})}),a("7HmuL",function(e,r){/**
|
|
68
|
+
* @typedef {Object} NameValuePair
|
|
69
|
+
* @property {string} name - point separated names of the flattened main and sub properties, e.g. "responses[2].hits.hits[4]._source.name".
|
|
70
|
+
* @property {string} value - value of the property
|
|
71
|
+
*//**
|
|
72
|
+
* @param {object} data hierarchical object that may consist fo fields, subfields and arrays.
|
|
73
|
+
* @param {number} maxRecursionDepth
|
|
74
|
+
* @returns {NameValuePair[]} array of property name and value pairs
|
|
75
|
+
*/(($59adffa3db62607f$var$module||{}).exports={}).flattenToArray=function(e,r){var t=[];return("number"!=typeof r||r<1)&&(r=20),function e(n,a,o){if(!(o>r)&&"function"!=typeof n){if(Object(n)!==n)t.push({name:a,value:n});else if(Array.isArray(n)){var i,u=n.length;for(i=0;i<u;i+=1)e(n[i],a+"["+i+"]",o+1);0===u&&(t[a]=[],t.push({name:a,value:""}))}else{var l,s=!0;for(l in n)s=!1,e(n[l],a?a+"."+l:l,o+1);s&&a&&t.push({name:a,value:""})}}}(e,"",0),t}}),n("8ZIyB");//# sourceMappingURL=templateResolver.js.map
|
|
76
|
+
|
|
2
77
|
//# sourceMappingURL=templateResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"sgBAMA,aACA,IAAIA,EAASC,EAA0CD,YAE9CC,EAA0CC,GACjD,OAAOA,GAAiB,GAO1B,IAAIC,EAAqBH,EAAOI,QAAU,GAC1CD,EAAkBE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K,CAAEvC,KAAMqC,EAAM7B,MAAO,MAIvC2B,CAAQH,EAAM,GAAI,GACXE","sources":["src/js/templateResolver.js","lib/js/flattenToArray.js"],"sourcesContent":["/**\n * @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = templateResolverInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction templateResolverInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @module template_resolver\n */\nvar template_resolver = (module.exports = {}); // Export module for npm...\ntemplate_resolver.internalCreateIfNotExists = templateResolverInternalCreateIfNotExists;\n\nvar internal_object_tools = internal_object_tools || require(\"../../lib/js/flattenToArray\"); // supports vanilla js & npm\n\ntemplate_resolver.Resolver = (function () {\n var removeArrayBracketsRegEx = new RegExp(\"\\\\[\\\\d+\\\\]\", \"gi\");\n\n /**\n * Resolver. Is used inside this repository. It could also be used outside.\n * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.\n * @constructs Resolver\n * @alias module:template_resolver.Resolver\n */\n function Resolver(sourceDataObject) {\n /**\n * The properties of this source data object will be used to replace the placeholders in the template.\n */\n this.sourceDataObject = sourceDataObject;\n /**\n * Resolves the given template.\n *\n * The template may contain variables in double curly brackets.\n * Supported variables are all properties of this object, e.g. \"{{fieldName}}\", \"{{displayName}}\", \"{{value}}\".\n * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. \"{{summaries[0].value}}\"\n * Parts of the index can be inserted by using e.g. \"{{index[1]}}\".\n *\n * @param {string} template\n * @returns {string} resolved template\n */\n this.resolveTemplate = function (template) {\n return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));\n };\n /**\n * Returns a map like object, that contains all resolvable fields and their values as properties.\n * This function takes a variable count of input parameters,\n * each containing an object that contains resolvable fields to extract from.\n *\n * The recursion depth is limited to 3, so that an object,\n * that contains an object can contain another object (but not further).\n *\n * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.\n *\n * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.\n * @returns {object} object with resolvable field names and their values.\n * @public\n */\n this.resolvableFieldsOfAll = function () {\n var map = {};\n var ignoreInternalFields = function (propertyName) {\n return propertyName.indexOf(\"_\") !== 0 && propertyName.indexOf(\"._\") < 0;\n };\n var index;\n for (index = 0; index < arguments.length; index += 1) {\n addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);\n }\n return map;\n };\n /**\n * Replaces all variables in double curly brackets, e.g. {{property}},\n * with the value of that property from the resolvableProperties.\n *\n * Supported property types: string, number, boolean\n * @param {string} stringContainingVariables\n * @param {object[]} resolvableFields (name=value)\n */\n this.replaceResolvableFields = function (stringContainingVariables, resolvableFields) {\n var replaced = stringContainingVariables;\n var propertyNames = Object.keys(resolvableFields);\n var propertyIndex = 0;\n var propertyName = \"\";\n var propertyValue = \"\";\n for (propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1) {\n propertyName = propertyNames[propertyIndex];\n propertyValue = resolvableFields[propertyName];\n replaced = replaced.replace(\"{{\" + propertyName + \"}}\", propertyValue);\n }\n return replaced;\n };\n }\n\n /**\n * Adds the value of the \"fieldName\" property (including its group prefix) and its associated \"value\" property content.\n * For example: detail[2].fieldName=\"name\", detail[2].value=\"Smith\" lead to the additional property detail.name=\"Smith\".\n * @param {object} object with resolvable field names and their values.\n * @returns {object} object with resolvable field names and their values.\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addFieldsPerGroup(map) {\n var propertyNames = Object.keys(map);\n var i, fullPropertyName, propertyInfo, propertyValue;\n for (i = 0; i < propertyNames.length; i += 1) {\n fullPropertyName = propertyNames[i];\n propertyValue = map[fullPropertyName];\n propertyInfo = getPropertyNameInfos(fullPropertyName);\n // Supports fields that are defined by a property named \"fieldName\" (containing the name)\n // and a property named \"value\" inside the same sub object (containing its value).\n // Ignore custom fields that are named \"fieldName\"(propertyValue), since this would lead to an unpredictable behavior.\n // TODO could make \"fieldName\" and \"value\" configurable\n if (propertyInfo.name === \"fieldName\" && propertyValue !== \"fieldName\") {\n map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + \"value\"];\n }\n }\n return map;\n }\n\n /**\n * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.\n * @param {String} fullPropertyName\n * @returns {Object} Contains \"group\" (empty or group name including trailing separator \".\"), \"groupWithoutArrayIndices\" and \"name\" (property name).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function getPropertyNameInfos(fullPropertyName) {\n var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(\".\");\n var propertyName = fullPropertyName;\n if (positionOfRightMostSeparator > 0) {\n propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);\n }\n var propertyGroup = \"\";\n if (positionOfRightMostSeparator > 0) {\n propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing \".\".\n }\n var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, \"\");\n return { group: propertyGroup, groupWithoutArrayIndices: propertyGroupWithoutArrayIndices, name: propertyName };\n }\n\n /**\n * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).\n * Example: `{name: \"accountNumber\", value: \"12345\"}` becomes `mapObject[\"accountNumber\"]=\"12345\"`.\n *\n * @param {NameValuePair[]} elements flattened array of name-value-pairs\n * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.\n * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {\n var index, element;\n for (index = 0; index < elements.length; index += 1) {\n element = elements[index];\n if (typeof filterMatchesFunction === \"function\" && filterMatchesFunction(element.name)) {\n mapObject[element.name] = element.value;\n }\n }\n return mapObject;\n }\n\n return Resolver;\n}());\n","\"use strict\";\n/**\n * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss\n * @version ${project.version}\n * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}\n */\nvar module = module || {}; // Fallback for vanilla js without modules\n\n/**\n * internal_object_tools. Not meant to be used outside this repository.\n * @default {}\n */\nvar internal_object_tools = module.exports={}; // Export module for npm...\n\n/**\n * @typedef {Object} NameValuePair\n * @property {string} name - point separated names of the flattened main and sub properties, e.g. \"responses[2].hits.hits[4]._source.name\".\n * @property {string} value - value of the property\n */\n\n/**\n * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.\n * @param {number} maxRecursionDepth\n * @returns {NameValuePair[]} array of property name and value pairs\n */\ninternal_object_tools.flattenToArray = function (data, maxRecursionDepth) {\n var result = [];\n if (typeof maxRecursionDepth !== \"number\" || maxRecursionDepth < 1) {\n maxRecursionDepth = 20;\n }\n function recurse(cur, prop, depth) {\n if (depth > maxRecursionDepth || typeof cur === \"function\") {\n return;\n }\n if (Object(cur) !== cur) {\n result.push({ name: prop, value: cur });\n } else if (Array.isArray(cur)) {\n var i;\n var l = cur.length;\n for (i = 0; i < l; i += 1) {\n recurse(cur[i], prop + \"[\" + i + \"]\", depth + 1);\n }\n if (l === 0) {\n result[prop] = [];\n result.push({ name: prop, value: \"\" });\n }\n } else {\n var isEmpty = true;\n var p;\n for (p in cur) {\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p, depth + 1);\n }\n if (isEmpty && prop) {\n result.push({ name: prop, value: \"\" });\n }\n }\n }\n recurse(data, \"\", 0);\n return result;\n};\n"],"names":["$03246337b2ee5537$var$module","$03246337b2ee5537$var$templateResolverInternalCreateIfNotExists","objectToCheck","$03246337b2ee5537$var$template_resolver","exports","internalCreateIfNotExists","$03246337b2ee5537$var$internal_object_tools","parcelRequire","Resolver","removeArrayBracketsRegEx","RegExp","getPropertyNameInfos","fullPropertyName","positionOfRightMostSeparator","lastIndexOf","propertyName","substr","propertyGroup","propertyGroupWithoutArrayIndices","replace","group","groupWithoutArrayIndices","name","addToFilteredMapObject","elements","mapObject","filterMatchesFunction","index","element","length","value","sourceDataObject","this","resolveTemplate","template","replaceResolvableFields","map","i","propertyInfo","propertyValue","propertyNames","Object","keys","addFieldsPerGroup","resolvableFieldsOfAll","ignoreInternalFields","indexOf","arguments","flattenToArray","stringContainingVariables","resolvableFields","replaced","propertyIndex","$4ee7050bd023907f$var$module","data","maxRecursionDepth","result","recurse","cur","prop","depth","push","Array","isArray","l","p","isEmpty"],"version":3,"file":"templateResolver.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":"A,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,I,E,E,Q,C,E,Q,S,C,C,C,ECOA,IAgBM,EAhBF,EAAS,EAA0C,EAAS,2CAA0C;AAE1G,SAAS,EAA0C,CAAa,EAC9D,OAAO,GAAiB,CAAC,CAC3B,CAEA;;;CAGC,EACD,IAAI,EAAqB,EAAO,OAAO,CAAG,CAAC,CAAI,4BAA2B;AAC1E,EAAkB,yBAAyB,CAAG,EAE9C,IAAI,EAAwB,GAAyB,EAAA,QAAwC,6BAA4B;AAEzH,EAAkB,QAAQ,EACpB,EAA2B,AAAI,OAAO,aAAc,MAExD;;;;;GAKC,EACD,SAAkB,CAAgB,EAChC;;KAEC,EACD,IAAI,CAAC,gBAAgB,CAAG,EACxB;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ADI,EACA,EAAI,EAAI,MAAM,CAClB,IAAK,EAAI,EAAG,EAAI,EAAG,GAAK,EACtB,EAAQ,CAAG,CAAC,EAAE,CAAE,EAAO,IAAM,EAAI,IAAK,EAAQ,EAEtC,CAAA,IAAN,IACF,CAAM,CAAC,EAAK,CAAG,EAAE,CACjB,EAAO,IAAI,CAAC,CAAE,KAAM,EAAM,MAAO,EAAG,GAExC,KAAO,CACL,IACI,EADA,EAAU,CAAA,EAEd,IAAK,KAAK,EACR,EAAU,CAAA,EACV,EAAQ,CAAG,CAAC,EAAE,CAAE,EAAO,EAAO,IAAM,EAAI,EAAG,EAAQ,GAEjD,GAAW,GACb,EAAO,IAAI,CAAC,CAAE,KAAM,EAAM,MAAO,EAAG,EAExC,EACF,EACQ,EAAM,GAAI,GACX,CACT,C,G,E,Q,6C","sources":["<anon>","src/js/templateResolver.js","lib/js/flattenToArray.js"],"sourcesContent":["\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirec1f2\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirec1f2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"8ZIyB\", function(module, exports) {\n/**\n * @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */ \"use strict\";\nvar $68c6955ebe469375$var$module = $68c6955ebe469375$var$templateResolverInternalCreateIfNotExists($68c6955ebe469375$var$module); // Fallback for vanilla js without modules\nfunction $68c6955ebe469375$var$templateResolverInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n/**\n * Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @module template_resolver\n */ var $68c6955ebe469375$var$template_resolver = $68c6955ebe469375$var$module.exports = {}; // Export module for npm...\n$68c6955ebe469375$var$template_resolver.internalCreateIfNotExists = $68c6955ebe469375$var$templateResolverInternalCreateIfNotExists;\n\nvar $68c6955ebe469375$var$internal_object_tools = $68c6955ebe469375$var$internal_object_tools || (parcelRequire(\"7HmuL\")); // supports vanilla js & npm\n$68c6955ebe469375$var$template_resolver.Resolver = function() {\n var removeArrayBracketsRegEx = new RegExp(\"\\\\[\\\\d+\\\\]\", \"gi\");\n /**\n * Resolver. Is used inside this repository. It could also be used outside.\n * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.\n * @constructs Resolver\n * @alias module:template_resolver.Resolver\n */ function Resolver(sourceDataObject) {\n /**\n * The properties of this source data object will be used to replace the placeholders in the template.\n */ this.sourceDataObject = sourceDataObject;\n /**\n * Resolves the given template.\n *\n * The template may contain variables in double curly brackets.\n * Supported variables are all properties of this object, e.g. \"{{fieldName}}\", \"{{displayName}}\", \"{{value}}\".\n * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. \"{{summaries[0].value}}\"\n * Parts of the index can be inserted by using e.g. \"{{index[1]}}\".\n *\n * @param {string} template\n * @returns {string} resolved template\n */ this.resolveTemplate = function(template) {\n return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));\n };\n /**\n * Returns a map like object, that contains all resolvable fields and their values as properties.\n * This function takes a variable count of input parameters,\n * each containing an object that contains resolvable fields to extract from.\n *\n * The recursion depth is limited to 3, so that an object,\n * that contains an object can contain another object (but not further).\n *\n * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.\n *\n * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.\n * @returns {object} object with resolvable field names and their values.\n * @public\n */ this.resolvableFieldsOfAll = function() {\n var map = {};\n var ignoreInternalFields = function(propertyName) {\n return propertyName.indexOf(\"_\") !== 0 && propertyName.indexOf(\"._\") < 0;\n };\n var index;\n for(index = 0; index < arguments.length; index += 1)addToFilteredMapObject($68c6955ebe469375$var$internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);\n return map;\n };\n /**\n * Replaces all variables in double curly brackets, e.g. {{property}},\n * with the value of that property from the resolvableProperties.\n *\n * Supported property types: string, number, boolean\n * @param {string} stringContainingVariables\n * @param {object[]} resolvableFields (name=value)\n */ this.replaceResolvableFields = function(stringContainingVariables, resolvableFields) {\n var replaced = stringContainingVariables;\n var propertyNames = Object.keys(resolvableFields);\n var propertyIndex = 0;\n var propertyName = \"\";\n var propertyValue = \"\";\n for(propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1){\n propertyName = propertyNames[propertyIndex];\n propertyValue = resolvableFields[propertyName];\n replaced = replaced.replace(\"{{\" + propertyName + \"}}\", propertyValue);\n }\n return replaced;\n };\n }\n /**\n * Adds the value of the \"fieldName\" property (including its group prefix) and its associated \"value\" property content.\n * For example: detail[2].fieldName=\"name\", detail[2].value=\"Smith\" lead to the additional property detail.name=\"Smith\".\n * @param {object} object with resolvable field names and their values.\n * @returns {object} object with resolvable field names and their values.\n * @protected\n * @memberof module:template_resolver.Resolver\n */ function addFieldsPerGroup(map) {\n var propertyNames = Object.keys(map);\n var i, fullPropertyName, propertyInfo, propertyValue;\n for(i = 0; i < propertyNames.length; i += 1){\n fullPropertyName = propertyNames[i];\n propertyValue = map[fullPropertyName];\n propertyInfo = getPropertyNameInfos(fullPropertyName);\n // Supports fields that are defined by a property named \"fieldName\" (containing the name)\n // and a property named \"value\" inside the same sub object (containing its value).\n // Ignore custom fields that are named \"fieldName\"(propertyValue), since this would lead to an unpredictable behavior.\n // TODO could make \"fieldName\" and \"value\" configurable\n if (propertyInfo.name === \"fieldName\" && propertyValue !== \"fieldName\") map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + \"value\"];\n }\n return map;\n }\n /**\n * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.\n * @param {String} fullPropertyName\n * @returns {Object} Contains \"group\" (empty or group name including trailing separator \".\"), \"groupWithoutArrayIndices\" and \"name\" (property name).\n * @protected\n * @memberof module:template_resolver.Resolver\n */ function getPropertyNameInfos(fullPropertyName) {\n var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(\".\");\n var propertyName = fullPropertyName;\n if (positionOfRightMostSeparator > 0) propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);\n var propertyGroup = \"\";\n if (positionOfRightMostSeparator > 0) propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing \".\".\n var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, \"\");\n return {\n group: propertyGroup,\n groupWithoutArrayIndices: propertyGroupWithoutArrayIndices,\n name: propertyName\n };\n }\n /**\n * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).\n * Example: `{name: \"accountNumber\", value: \"12345\"}` becomes `mapObject[\"accountNumber\"]=\"12345\"`.\n *\n * @param {NameValuePair[]} elements flattened array of name-value-pairs\n * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.\n * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).\n * @protected\n * @memberof module:template_resolver.Resolver\n */ function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {\n var index, element;\n for(index = 0; index < elements.length; index += 1){\n element = elements[index];\n if (typeof filterMatchesFunction === \"function\" && filterMatchesFunction(element.name)) mapObject[element.name] = element.value;\n }\n return mapObject;\n }\n return Resolver;\n}();\n\n});\nparcelRegister(\"7HmuL\", function(module, exports) {\n\"use strict\";\n/**\n * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss\n * @version ${project.version}\n * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}\n */ var $59adffa3db62607f$var$module = $59adffa3db62607f$var$module || {}; // Fallback for vanilla js without modules\n/**\n * internal_object_tools. Not meant to be used outside this repository.\n * @default {}\n */ var $59adffa3db62607f$var$internal_object_tools = $59adffa3db62607f$var$module.exports = {}; // Export module for npm...\n/**\n * @typedef {Object} NameValuePair\n * @property {string} name - point separated names of the flattened main and sub properties, e.g. \"responses[2].hits.hits[4]._source.name\".\n * @property {string} value - value of the property\n */ /**\n * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.\n * @param {number} maxRecursionDepth\n * @returns {NameValuePair[]} array of property name and value pairs\n */ $59adffa3db62607f$var$internal_object_tools.flattenToArray = function(data, maxRecursionDepth) {\n var result = [];\n if (typeof maxRecursionDepth !== \"number\" || maxRecursionDepth < 1) maxRecursionDepth = 20;\n function recurse(cur, prop, depth) {\n if (depth > maxRecursionDepth || typeof cur === \"function\") return;\n if (Object(cur) !== cur) result.push({\n name: prop,\n value: cur\n });\n else if (Array.isArray(cur)) {\n var i;\n var l = cur.length;\n for(i = 0; i < l; i += 1)recurse(cur[i], prop + \"[\" + i + \"]\", depth + 1);\n if (l === 0) {\n result[prop] = [];\n result.push({\n name: prop,\n value: \"\"\n });\n }\n } else {\n var isEmpty = true;\n var p;\n for(p in cur){\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p, depth + 1);\n }\n if (isEmpty && prop) result.push({\n name: prop,\n value: \"\"\n });\n }\n }\n recurse(data, \"\", 0);\n return result;\n};\n\n});\n\n\n\nparcelRequire(\"8ZIyB\");\n\n//# sourceMappingURL=templateResolver.js.map\n","/**\n * @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = templateResolverInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction templateResolverInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.\n * @module template_resolver\n */\nvar template_resolver = (module.exports = {}); // Export module for npm...\ntemplate_resolver.internalCreateIfNotExists = templateResolverInternalCreateIfNotExists;\n\nvar internal_object_tools = internal_object_tools || require(\"../../lib/js/flattenToArray\"); // supports vanilla js & npm\n\ntemplate_resolver.Resolver = (function () {\n var removeArrayBracketsRegEx = new RegExp(\"\\\\[\\\\d+\\\\]\", \"gi\");\n\n /**\n * Resolver. Is used inside this repository. It could also be used outside.\n * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.\n * @constructs Resolver\n * @alias module:template_resolver.Resolver\n */\n function Resolver(sourceDataObject) {\n /**\n * The properties of this source data object will be used to replace the placeholders in the template.\n */\n this.sourceDataObject = sourceDataObject;\n /**\n * Resolves the given template.\n *\n * The template may contain variables in double curly brackets.\n * Supported variables are all properties of this object, e.g. \"{{fieldName}}\", \"{{displayName}}\", \"{{value}}\".\n * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. \"{{summaries[0].value}}\"\n * Parts of the index can be inserted by using e.g. \"{{index[1]}}\".\n *\n * @param {string} template\n * @returns {string} resolved template\n */\n this.resolveTemplate = function (template) {\n return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));\n };\n /**\n * Returns a map like object, that contains all resolvable fields and their values as properties.\n * This function takes a variable count of input parameters,\n * each containing an object that contains resolvable fields to extract from.\n *\n * The recursion depth is limited to 3, so that an object,\n * that contains an object can contain another object (but not further).\n *\n * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.\n *\n * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.\n * @returns {object} object with resolvable field names and their values.\n * @public\n */\n this.resolvableFieldsOfAll = function () {\n var map = {};\n var ignoreInternalFields = function (propertyName) {\n return propertyName.indexOf(\"_\") !== 0 && propertyName.indexOf(\"._\") < 0;\n };\n var index;\n for (index = 0; index < arguments.length; index += 1) {\n addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);\n }\n return map;\n };\n /**\n * Replaces all variables in double curly brackets, e.g. {{property}},\n * with the value of that property from the resolvableProperties.\n *\n * Supported property types: string, number, boolean\n * @param {string} stringContainingVariables\n * @param {object[]} resolvableFields (name=value)\n */\n this.replaceResolvableFields = function (stringContainingVariables, resolvableFields) {\n var replaced = stringContainingVariables;\n var propertyNames = Object.keys(resolvableFields);\n var propertyIndex = 0;\n var propertyName = \"\";\n var propertyValue = \"\";\n for (propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1) {\n propertyName = propertyNames[propertyIndex];\n propertyValue = resolvableFields[propertyName];\n replaced = replaced.replace(\"{{\" + propertyName + \"}}\", propertyValue);\n }\n return replaced;\n };\n }\n\n /**\n * Adds the value of the \"fieldName\" property (including its group prefix) and its associated \"value\" property content.\n * For example: detail[2].fieldName=\"name\", detail[2].value=\"Smith\" lead to the additional property detail.name=\"Smith\".\n * @param {object} object with resolvable field names and their values.\n * @returns {object} object with resolvable field names and their values.\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addFieldsPerGroup(map) {\n var propertyNames = Object.keys(map);\n var i, fullPropertyName, propertyInfo, propertyValue;\n for (i = 0; i < propertyNames.length; i += 1) {\n fullPropertyName = propertyNames[i];\n propertyValue = map[fullPropertyName];\n propertyInfo = getPropertyNameInfos(fullPropertyName);\n // Supports fields that are defined by a property named \"fieldName\" (containing the name)\n // and a property named \"value\" inside the same sub object (containing its value).\n // Ignore custom fields that are named \"fieldName\"(propertyValue), since this would lead to an unpredictable behavior.\n // TODO could make \"fieldName\" and \"value\" configurable\n if (propertyInfo.name === \"fieldName\" && propertyValue !== \"fieldName\") {\n map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + \"value\"];\n }\n }\n return map;\n }\n\n /**\n * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.\n * @param {String} fullPropertyName\n * @returns {Object} Contains \"group\" (empty or group name including trailing separator \".\"), \"groupWithoutArrayIndices\" and \"name\" (property name).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function getPropertyNameInfos(fullPropertyName) {\n var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(\".\");\n var propertyName = fullPropertyName;\n if (positionOfRightMostSeparator > 0) {\n propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);\n }\n var propertyGroup = \"\";\n if (positionOfRightMostSeparator > 0) {\n propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing \".\".\n }\n var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, \"\");\n return { group: propertyGroup, groupWithoutArrayIndices: propertyGroupWithoutArrayIndices, name: propertyName };\n }\n\n /**\n * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).\n * Example: `{name: \"accountNumber\", value: \"12345\"}` becomes `mapObject[\"accountNumber\"]=\"12345\"`.\n *\n * @param {NameValuePair[]} elements flattened array of name-value-pairs\n * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.\n * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).\n * @protected\n * @memberof module:template_resolver.Resolver\n */\n function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {\n var index, element;\n for (index = 0; index < elements.length; index += 1) {\n element = elements[index];\n if (typeof filterMatchesFunction === \"function\" && filterMatchesFunction(element.name)) {\n mapObject[element.name] = element.value;\n }\n }\n return mapObject;\n }\n\n return Resolver;\n}());\n","\"use strict\";\n/**\n * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss\n * @version ${project.version}\n * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}\n */\nvar module = module || {}; // Fallback for vanilla js without modules\n\n/**\n * internal_object_tools. Not meant to be used outside this repository.\n * @default {}\n */\nvar internal_object_tools = module.exports={}; // Export module for npm...\n\n/**\n * @typedef {Object} NameValuePair\n * @property {string} name - point separated names of the flattened main and sub properties, e.g. \"responses[2].hits.hits[4]._source.name\".\n * @property {string} value - value of the property\n */\n\n/**\n * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.\n * @param {number} maxRecursionDepth\n * @returns {NameValuePair[]} array of property name and value pairs\n */\ninternal_object_tools.flattenToArray = function (data, maxRecursionDepth) {\n var result = [];\n if (typeof maxRecursionDepth !== \"number\" || maxRecursionDepth < 1) {\n maxRecursionDepth = 20;\n }\n function recurse(cur, prop, depth) {\n if (depth > maxRecursionDepth || typeof cur === \"function\") {\n return;\n }\n if (Object(cur) !== cur) {\n result.push({ name: prop, value: cur });\n } else if (Array.isArray(cur)) {\n var i;\n var l = cur.length;\n for (i = 0; i < l; i += 1) {\n recurse(cur[i], prop + \"[\" + i + \"]\", depth + 1);\n }\n if (l === 0) {\n result[prop] = [];\n result.push({ name: prop, value: \"\" });\n }\n } else {\n var isEmpty = true;\n var p;\n for (p in cur) {\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p, depth + 1);\n }\n if (isEmpty && prop) {\n result.push({ name: prop, value: \"\" });\n }\n }\n }\n recurse(data, \"\", 0);\n return result;\n};\n"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","removeArrayBracketsRegEx","$68c6955ebe469375$var$module","$68c6955ebe469375$var$templateResolverInternalCreateIfNotExists","objectToCheck","$68c6955ebe469375$var$template_resolver","internalCreateIfNotExists","$68c6955ebe469375$var$internal_object_tools","Resolver","RegExp","sourceDataObject","resolveTemplate","template","replaceResolvableFields","addFieldsPerGroup","map","i","fullPropertyName","propertyInfo","propertyValue","propertyNames","Object","keys","length","getPropertyNameInfos","positionOfRightMostSeparator","lastIndexOf","propertyName","substr","propertyGroup","propertyGroupWithoutArrayIndices","replace","group","groupWithoutArrayIndices","name","resolvableFieldsOfAll","index","ignoreInternalFields","indexOf","arguments","addToFilteredMapObject","elements","mapObject","filterMatchesFunction","element","value","flattenToArray","stringContainingVariables","resolvableFields","replaced","propertyIndex","$59adffa3db62607f$var$internal_object_tools","$59adffa3db62607f$var$module","data","maxRecursionDepth","result","recurse","cur","prop","depth","push","Array","isArray","l","p","isEmpty"],"version":3,"file":"templateResolver.js.map","sourceRoot":"../"}
|
|
@@ -1280,7 +1280,7 @@ datarestructor.Restructor.processJsonUsingDescriptions = function(jsonData, desc
|
|
|
1280
1280
|
<br class="clear">
|
|
1281
1281
|
|
|
1282
1282
|
<footer>
|
|
1283
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc
|
|
1283
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Fri Oct 20 2023 21:28:55 GMT+0200 (Central European Summer Time)
|
|
1284
1284
|
</footer>
|
|
1285
1285
|
|
|
1286
1286
|
<script> prettyPrint(); </script>
|
|
@@ -334,7 +334,7 @@ described_field.DescribedDataFieldGroup = (function () {
|
|
|
334
334
|
<br class="clear">
|
|
335
335
|
|
|
336
336
|
<footer>
|
|
337
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc
|
|
337
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Fri Oct 20 2023 21:28:55 GMT+0200 (Central European Summer Time)
|
|
338
338
|
</footer>
|
|
339
339
|
|
|
340
340
|
<script> prettyPrint(); </script>
|
package/docs/index.html
CHANGED
|
@@ -466,6 +466,11 @@ That leads to recursion and duplication, that need to be limited. This can be co
|
|
|
466
466
|
<li><strong>setMaxRecursionDepth(number)</strong> numeric value that defines the maximum recursion depth</li>
|
|
467
467
|
<li><strong>setRemoveDuplicationAboveRecursionDepth(number)</strong> numeric value that defines the recursion depth, above which duplications inside groups will be removed.</li>
|
|
468
468
|
</ul>
|
|
469
|
+
<h2>Related blog articles</h2>
|
|
470
|
+
<ul>
|
|
471
|
+
<li><a href="https://joht.github.io/johtizen/build/2022/01/20/github-actions-push-into-repository.html">Most effective ways to push within GitHub Actions</a></li>
|
|
472
|
+
<li><a href="https://joht.github.io/johtizen/build/2021/02/21/continuous-integration-javascript.html">Continuous Integration for JavaScript with npm</a></li>
|
|
473
|
+
</ul>
|
|
469
474
|
<h2>References</h2>
|
|
470
475
|
<ul>
|
|
471
476
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Polyfill">Mozilla MDN web docs - polyfill for 'Array.filter'</a> for browser compatibility</li>
|
|
@@ -812,7 +817,7 @@ That leads to recursion and duplication, that need to be limited. This can be co
|
|
|
812
817
|
<br class="clear">
|
|
813
818
|
|
|
814
819
|
<footer>
|
|
815
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc
|
|
820
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Fri Oct 20 2023 21:28:55 GMT+0200 (Central European Summer Time)
|
|
816
821
|
</footer>
|
|
817
822
|
|
|
818
823
|
<script> prettyPrint(); </script>
|