a zip code crypto-currency system good for red ONLY

DepBlockHelpers.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const DepBlockHelpers = exports;
  7. DepBlockHelpers.getLoadDepBlockWrapper = (depBlock, outputOptions, requestShortener, name) => {
  8. const promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
  9. return [
  10. promiseCode + ".then(",
  11. ").catch(",
  12. ")"
  13. ];
  14. };
  15. DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, name) => {
  16. if(depBlock.chunks) {
  17. const chunks = depBlock.chunks.filter(chunk => !chunk.hasRuntime() && chunk.id !== null);
  18. const pathChunkCheck = outputOptions.pathinfo && depBlock.chunkName;
  19. const shortChunkName = requestShortener.shorten(depBlock.chunkName);
  20. const chunkReason = asComment(depBlock.chunkReason);
  21. const requireChunkId = chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
  22. name = asComment(name);
  23. if(chunks.length === 1) {
  24. const chunkId = JSON.stringify(chunks[0].id);
  25. return `__webpack_require__.e${name}(${chunkId}${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}${chunkReason})`;
  26. } else if(chunks.length > 0) {
  27. return `Promise.all${name}(${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}[${chunks.map(requireChunkId).join(", ")}])`;
  28. }
  29. }
  30. return "new Promise(function(resolve) { resolve(); })";
  31. };
  32. function asComment(str) {
  33. if(!str) return "";
  34. return `/* ${str} */`;
  35. }