utils.js 2.2 KB

1
  1. "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.assign=assign,exports.enumerate=enumerate,exports.join=join,exports.walk=walk;var _dot=_interopRequireDefault(require("@d3v4pp/dot")),_type=_interopRequireDefault(require("@d3v4pp/type"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f=[],g=!0,h=!1;try{for(c=c.call(a);!(g=(d=c.next()).done)&&(f.push(d.value),!(b&&f.length===b));g=!0);}catch(a){h=!0,e=a}finally{try{g||null==c["return"]||c["return"]()}finally{if(h)throw e}}return f}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function assign(a,b,c){return"string"==typeof a?void(c[a]=b):void Object.keys(a).forEach(function(b){return c[b]=a[b]})}function enumerate(a,b,c){var d=a.split(/\.\$(?=\.|$)/),e=d.shift(),f=_dot["default"].get(b,e);if(!d.length)return c(e,f);if(Array.isArray(f))for(var j=0;j<f.length;j++){var g=join(j,e),h=g+d.join(".$");enumerate(h,b,c)}}function walk(a,b,c,d){var e=(0,_type["default"])(a);if("array"===e)return void a.forEach(function(a,e){return walk(a,b,join(e,c),join("$",d))});if("object"===e)for(var f=0,g=Object.entries(a);f<g.length;f++){var h=_slicedToArray(g[f],2),i=h[0],j=h[1],k=join(i,c),l=join(i,d);b(k,l)&&walk(j,b,k,l)}}function join(a,b){return b?"".concat(b,".").concat(a):a}