UNPKG

app-decorators

Version:

Collection of useful ES7 Decorators, writtin in ES6, that can be used for building webapps

101 lines (81 loc) 3.52 kB
System.register(['app-decorators/src/libs/element-to-function'], function (_export, _context) { "use strict"; var _elementToFunc, _slicedToArray, promises, lazyPolyfillLoader; return { setters: [function (_appDecoratorsSrcLibsElementToFunction) { _elementToFunc = _appDecoratorsSrcLibsElementToFunction.default; }], execute: function () { _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); promises = null; _export('lazyPolyfillLoader', lazyPolyfillLoader = function lazyPolyfillLoader(Loader, modules) { var basePath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; // when already resolved if (promises) { return promises; } // determine which polyfills needed var _modules = modules.filter(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), global = _ref2[0], property = _ref2[1]; return !global[property]; }); // when nothing to do if (!_modules.length) { return Promise.resolve([]); } var _basePath = basePath ? basePath + '/' : basePath; // resolve polyfills promises = Promise.all(_modules.map(function (_ref3) { var _ref4 = _slicedToArray(_ref3, 4), global = _ref4[0], property = _ref4[1], path = _ref4[2], assign = _ref4[3]; return Loader.import('' + _basePath + path).then(function (module) { return !assign ? global[property] = module : null; }); })); promises.catch(function (error) { throw new Error(error); }); return promises; }); _export('lazyPolyfillLoader', lazyPolyfillLoader); } }; }); //# sourceMappingURL=lazyPolyfillLoader.js.map