Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let callbackCounter = 1;
- function imagick() {
- let stack = [];
- let callbackFunction = function(param) {
- stack.push(param);
- }
- this.composit = function(param1) {
- return new _composit(param1, this, callbackFunction)
- }
- this.convert = function(param2) {
- let callbackFunction = function(param) {
- console.log("param");
- }
- return new _convert(param2, this, callbackFunction)
- }
- this.write = function() {
- console.log("collecting stack");
- console.log(stack);
- }
- }
- function _composit(param, parent, callback) {
- // reference to parent object
- this.parentObj = parent;
- this.att = param
- console.log(this.att);
- this.test = function (obj) {
- console.log(obj);
- // return to reference from itself
- return this;
- }
- this.end = function() {
- // return to reference of parent object
- callback("callback" + callbackCounter);
- callbackCounter++;
- return this.parentObj;
- }
- }
- function _convert(param, parent, callback) {
- // reference to parent object
- this.parentObj = parent;
- // saving param
- this.att = param;
- // printing att
- console.log(this.att);
- this.resize = function (obj) {
- console.log(obj);
- // return to reference from itself
- return this;
- }
- this.end = function() {
- // return to reference of parent object
- callback();
- return this.parentObj;
- }
- }
- var im = new imagick();
- im.composit("test").end().composit("test").end().composit("test").end().write();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement