Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) {
- 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 (param) {
- console.log(param);
- // return to reference from itself
- return this;
- }
- this.end = function () {
- // return to reference of parent object
- callback("callback 1");
- 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 (param) {
- console.log(param);
- // return to reference from itself
- return this;
- }
- this.end = function () {
- // return to reference of parent object
- callback("callback 2");
- return this.parentObj;
- }
- }
- var im = new imagick();
- im.composit("test")
- .test("blub")
- .end()
- .composit("test")
- .test("blub")
- .end()
- .composit("test")
- .end()
- .write();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement