Skip to content

Instantly share code, notes, and snippets.

@danro
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save danro/1d7a7d20b972c8055623 to your computer and use it in GitHub Desktop.

Select an option

Save danro/1d7a7d20b972c8055623 to your computer and use it in GitHub Desktop.

Revisions

  1. danro revised this gist Jun 28, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@
    "name": "requirebin-sketch",
    "version": "1.0.0",
    "dependencies": {
    "mash-js": "0.9.x"
    "mash-js": "0.9.0"
    }
    }
  2. danro revised this gist Jun 28, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@
    "name": "requirebin-sketch",
    "version": "1.0.0",
    "dependencies": {
    "mash-js": "0.9.0"
    "mash-js": "0.9.x"
    }
    }
  3. danro revised this gist Jun 28, 2014. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@ mash(Hero, function () {

    this.attack = function (enemy) {
    console.log('Hero attacks the ' + enemy);
    this.slash(25);
    this.fireball(80);
    this.slash(45);
    this.fireball(200);
    };
    });

    2 changes: 1 addition & 1 deletion minified.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"yw/lAm":[function(require,module,exports){function mash(base,mixin){if(!mixin){mixin=base;base={}}var proto=base.prototype;if(proto==={}.prototype)proto=base;mixin.call(proto);base.create=function(){var ctor=base;if(typeof ctor!=="function"){ctor=function(){};ctor.prototype=base}var inst=new ctor;if(typeof inst.init==="function"){inst.init.apply(inst,arguments)}return inst};base.mash=function(obj){mixin.call(obj);return proto};return base}module.exports=mash},{}],"mash-js":[function(require,module,exports){module.exports=require("yw/lAm")},{}]},{},[]);var mash=require("mash-js");var withSword=mash(function(){this.slash=function(dmg){console.log("Sword slash for "+dmg+" damage!")}});var withMagic=mash(function(){this.fireball=function(dmg){console.log("Cast fireball for "+dmg+" damage!")};this.slash=function(){console.log("Oops we slashed with magic")}});function Hero(){}mash(Hero,function(){withSword.mash(this);withMagic.mash(this);this.slash=withSword.slash;this.attack=function(enemy){console.log("Hero attacks the "+enemy);this.slash(25);this.fireball(80)}});var hero=new Hero;hero.attack("Goblin");
    require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"yw/lAm":[function(require,module,exports){function mash(base,mixin){if(!mixin){mixin=base;base={}}var proto=base.prototype;if(proto==={}.prototype)proto=base;mixin.call(proto);base.create=function(){var ctor=base;if(typeof ctor!=="function"){ctor=function(){};ctor.prototype=base}var inst=new ctor;if(typeof inst.init==="function"){inst.init.apply(inst,arguments)}return inst};base.mash=function(obj){mixin.call(obj);return proto};return base}module.exports=mash},{}],"mash-js":[function(require,module,exports){module.exports=require("yw/lAm")},{}]},{},[]);var mash=require("mash-js");var withSword=mash(function(){this.slash=function(dmg){console.log("Sword slash for "+dmg+" damage!")}});var withMagic=mash(function(){this.fireball=function(dmg){console.log("Cast fireball for "+dmg+" damage!")};this.slash=function(){console.log("Oops we slashed with magic")}});function Hero(){}mash(Hero,function(){withSword.mash(this);withMagic.mash(this);this.slash=withSword.slash;this.attack=function(enemy){console.log("Hero attacks the "+enemy);this.slash(45);this.fireball(200)}});var hero=new Hero;hero.attack("Goblin");
  4. danro revised this gist Jun 28, 2014. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -31,4 +31,4 @@ mash(Hero, function () {
    });

    var hero = new Hero();
    hero.attack('Orc');
    hero.attack('Goblin');
    2 changes: 1 addition & 1 deletion minified.js
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"yw/lAm":[function(require,module,exports){function mash(base,mixin){if(!mixin){mixin=base;base={}}var proto=base.prototype;if(proto==={}.prototype)proto=base;mixin.call(proto);base.create=function(){var ctor=base;if(typeof ctor!=="function"){ctor=function(){};ctor.prototype=base}var inst=new ctor;if(typeof inst.init==="function"){inst.init.apply(inst,arguments)}return inst};base.mash=function(obj){mixin.call(obj);return proto};return base}module.exports=mash},{}],"mash-js":[function(require,module,exports){module.exports=require("yw/lAm")},{}]},{},[]);var mash=require("mash-js");var withSword=mash(function(){this.slash=function(dmg){console.log("Sword slash for "+dmg+" damage!")}});var withMagic=mash(function(){this.fireball=function(dmg){console.log("Cast fireball for "+dmg+" damage!")};this.slash=function(){console.log("Oops we slashed with magic")}});function Hero(){}mash(Hero,function(){withSword.mash(this);withMagic.mash(this);this.slash=withSword.slash;this.attack=function(enemy){console.log("Hero attacks the "+enemy);this.slash(25);this.fireball(80)}});var hero=new Hero;hero.attack("Orc");
    require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"yw/lAm":[function(require,module,exports){function mash(base,mixin){if(!mixin){mixin=base;base={}}var proto=base.prototype;if(proto==={}.prototype)proto=base;mixin.call(proto);base.create=function(){var ctor=base;if(typeof ctor!=="function"){ctor=function(){};ctor.prototype=base}var inst=new ctor;if(typeof inst.init==="function"){inst.init.apply(inst,arguments)}return inst};base.mash=function(obj){mixin.call(obj);return proto};return base}module.exports=mash},{}],"mash-js":[function(require,module,exports){module.exports=require("yw/lAm")},{}]},{},[]);var mash=require("mash-js");var withSword=mash(function(){this.slash=function(dmg){console.log("Sword slash for "+dmg+" damage!")}});var withMagic=mash(function(){this.fireball=function(dmg){console.log("Cast fireball for "+dmg+" damage!")};this.slash=function(){console.log("Oops we slashed with magic")}});function Hero(){}mash(Hero,function(){withSword.mash(this);withMagic.mash(this);this.slash=withSword.slash;this.attack=function(enemy){console.log("Hero attacks the "+enemy);this.slash(25);this.fireball(80)}});var hero=new Hero;hero.attack("Goblin");
  5. danro created this gist Jun 28, 2014.
    34 changes: 34 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    var mash = require('mash-js');

    var withSword = mash(function () {
    this.slash = function (dmg) {
    console.log('Sword slash for ' + dmg + ' damage!');
    };
    });

    var withMagic = mash(function () {
    this.fireball = function (dmg) {
    console.log('Cast fireball for ' + dmg + ' damage!');
    };
    this.slash = function () {
    console.log('Oops we slashed with magic');
    };
    });

    function Hero() {}
    mash(Hero, function () {
    withSword.mash(this);
    withMagic.mash(this);

    // Make sure we always slash with swords
    this.slash = withSword.slash;

    this.attack = function (enemy) {
    console.log('Hero attacks the ' + enemy);
    this.slash(25);
    this.fireball(80);
    };
    });

    var hero = new Hero();
    hero.attack('Orc');
    1 change: 1 addition & 0 deletions minified.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"yw/lAm":[function(require,module,exports){function mash(base,mixin){if(!mixin){mixin=base;base={}}var proto=base.prototype;if(proto==={}.prototype)proto=base;mixin.call(proto);base.create=function(){var ctor=base;if(typeof ctor!=="function"){ctor=function(){};ctor.prototype=base}var inst=new ctor;if(typeof inst.init==="function"){inst.init.apply(inst,arguments)}return inst};base.mash=function(obj){mixin.call(obj);return proto};return base}module.exports=mash},{}],"mash-js":[function(require,module,exports){module.exports=require("yw/lAm")},{}]},{},[]);var mash=require("mash-js");var withSword=mash(function(){this.slash=function(dmg){console.log("Sword slash for "+dmg+" damage!")}});var withMagic=mash(function(){this.fireball=function(dmg){console.log("Cast fireball for "+dmg+" damage!")};this.slash=function(){console.log("Oops we slashed with magic")}});function Hero(){}mash(Hero,function(){withSword.mash(this);withMagic.mash(this);this.slash=withSword.slash;this.attack=function(enemy){console.log("Hero attacks the "+enemy);this.slash(25);this.fireball(80)}});var hero=new Hero;hero.attack("Orc");
    7 changes: 7 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    {
    "name": "requirebin-sketch",
    "version": "1.0.0",
    "dependencies": {
    "mash-js": "0.9.0"
    }
    }
    2 changes: 2 additions & 0 deletions page-head.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <style type='text/css'>html, body { margin: 0; padding: 0; border: 0; }
    body, html { height: 100%; width: 100%; }</style>
    1 change: 1 addition & 0 deletions requirebin.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    made with [requirebin](http://requirebin.com)