a zip code crypto-currency system good for red ONLY

AsyncDependenciesBlock.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const DependenciesBlock = require("./DependenciesBlock");
  7. module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
  8. constructor(name, module, loc) {
  9. super();
  10. this.chunkName = name;
  11. this.chunks = null;
  12. this.module = module;
  13. this.loc = loc;
  14. }
  15. get chunk() {
  16. throw new Error("`chunk` was been renamed to `chunks` and is now an array");
  17. }
  18. set chunk(chunk) {
  19. throw new Error("`chunk` was been renamed to `chunks` and is now an array");
  20. }
  21. updateHash(hash) {
  22. hash.update(this.chunkName || "");
  23. hash.update(this.chunks && this.chunks.map((chunk) => {
  24. return chunk.id !== null ? chunk.id : "";
  25. }).join(",") || "");
  26. super.updateHash(hash);
  27. }
  28. disconnect() {
  29. this.chunks = null;
  30. super.disconnect();
  31. }
  32. unseal() {
  33. this.chunks = null;
  34. super.unseal();
  35. }
  36. sortItems() {
  37. super.sortItems();
  38. if(this.chunks) {
  39. this.chunks.sort((a, b) => a.compareTo(b));
  40. }
  41. }
  42. };