Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let callbackCounter = 1;
  2.  
  3.  
  4. function imagick() {
  5.  
  6.   let stack = [];
  7.  
  8.   let callbackFunction = function(param) {
  9.     stack.push(param);
  10.   }
  11.  
  12.   this.composit = function(param1) {
  13.    
  14.     return new _composit(param1, this, callbackFunction)
  15.   }
  16.   this.convert = function(param2) {
  17.     let callbackFunction = function(param) {
  18.       console.log("param");
  19.     }
  20.     return new _convert(param2, this, callbackFunction)
  21.   }
  22.  
  23.   this.write = function() {
  24.     console.log("collecting stack");
  25.     console.log(stack);
  26.   }
  27.  
  28.  
  29. }
  30.  
  31. function _composit(param, parent, callback) {
  32.   // reference to parent object
  33.   this.parentObj = parent;
  34.  
  35.   this.att = param
  36.  
  37.   console.log(this.att);
  38.  
  39.   this.test = function (obj) {
  40.     console.log(obj);
  41.  
  42.     // return to reference from itself
  43.     return this;
  44.   }
  45.  
  46.   this.end = function() {
  47.     // return to reference of parent object
  48.     callback("callback" + callbackCounter);
  49.  
  50.     callbackCounter++;
  51.  
  52.     return this.parentObj;
  53.   }
  54. }
  55.  
  56. function _convert(param, parent, callback) {
  57.   // reference to parent object
  58.   this.parentObj = parent;
  59.  
  60.   // saving param
  61.   this.att = param;
  62.  
  63.   // printing att
  64.   console.log(this.att);
  65.  
  66.   this.resize = function (obj) {
  67.     console.log(obj);
  68.  
  69.     // return to reference from itself
  70.     return this;
  71.   }
  72.  
  73.   this.end = function() {
  74.     // return to reference of parent object
  75.     callback();
  76.     return this.parentObj;
  77.   }
  78. }
  79.  
  80.  
  81. var im = new imagick();
  82.  
  83. im.composit("test").end().composit("test").end().composit("test").end().write();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement