a zip code crypto-currency system good for red ONLY

Entrypoint.js 934B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class Entrypoint {
  7. constructor(name) {
  8. this.name = name;
  9. this.chunks = [];
  10. }
  11. unshiftChunk(chunk) {
  12. this.chunks.unshift(chunk);
  13. chunk.entrypoints.push(this);
  14. }
  15. insertChunk(chunk, before) {
  16. const idx = this.chunks.indexOf(before);
  17. if(idx >= 0) {
  18. this.chunks.splice(idx, 0, chunk);
  19. } else {
  20. throw new Error("before chunk not found");
  21. }
  22. chunk.entrypoints.push(this);
  23. }
  24. getFiles() {
  25. const files = [];
  26. for(let chunkIdx = 0; chunkIdx < this.chunks.length; chunkIdx++) {
  27. for(let fileIdx = 0; fileIdx < this.chunks[chunkIdx].files.length; fileIdx++) {
  28. if(files.indexOf(this.chunks[chunkIdx].files[fileIdx]) === -1) {
  29. files.push(this.chunks[chunkIdx].files[fileIdx]);
  30. }
  31. }
  32. }
  33. return files;
  34. }
  35. }
  36. module.exports = Entrypoint;