a zip code crypto-currency system good for red ONLY

ModuleReason.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const util = require("util");
  7. class ModuleReason {
  8. constructor(module, dependency) {
  9. this.module = module;
  10. this.dependency = dependency;
  11. this._chunks = null;
  12. }
  13. hasChunk(chunk) {
  14. if(this._chunks) {
  15. if(this._chunks.has(chunk))
  16. return true;
  17. } else if(this.module._chunks.has(chunk))
  18. return true;
  19. return false;
  20. }
  21. rewriteChunks(oldChunk, newChunks) {
  22. if(!this._chunks) {
  23. if(!this.module._chunks.has(oldChunk))
  24. return;
  25. this._chunks = new Set(this.module._chunks);
  26. }
  27. if(this._chunks.has(oldChunk)) {
  28. this._chunks.delete(oldChunk);
  29. for(let i = 0; i < newChunks.length; i++) {
  30. this._chunks.add(newChunks[i]);
  31. }
  32. }
  33. }
  34. }
  35. Object.defineProperty(ModuleReason.prototype, "chunks", {
  36. configurable: false,
  37. get: util.deprecate(function() {
  38. return this._chunks ? Array.from(this._chunks) : null;
  39. }, "ModuleReason.chunks: Use ModuleReason.hasChunk/rewriteChunks instead"),
  40. set() {
  41. throw new Error("Readonly. Use ModuleReason.rewriteChunks to modify chunks.");
  42. }
  43. });
  44. module.exports = ModuleReason;