UNPKG

tree-to-flat-map

Version:

Convert a tree to a flat map with dot-separated keys

3 lines (2 loc) 477 B
"use strict";exports.treeToFlatMap=function(r,e){var t=(void 0===e?{}:e).separator;return function r(e,t,n,i){if("object"!=typeof e){var o;if(n in i)throw new Error('Tree has multiple leaves for path "'+n+'": '+JSON.stringify(i[n])+" and "+JSON.stringify(e)+".");return Object.assign(((o={})[n]=e,o),i)}return Object.keys(e).reduce((function(i,o){return r(e[o],t,n?""+n+t+o:o,i)}),i)}(r,void 0===t?".":t,"",{})}; //# sourceMappingURL=tree-to-flat-map.cjs.production.min.js.map