Advertisement
Guest User

Untitled

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