Skip to content

Instantly share code, notes, and snippets.

@danro
danro / readme.md
Last active Aug 29, 2015
mash.js - functional prototype mixins
@danro
danro / index.js
Last active Aug 29, 2015
requirebin sketch
View index.js
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) {
@danro
danro / index.js
Created Jun 28, 2014
requirebin sketch
View index.js
var mash = require('mash-js');
function Animal() {}
mash(Animal, function() {
this.init = function(name) {
this.name = name;
};
this.move = function(meters) {
console.log(this.name + ' moved ' + meters + 'm.');
@danro
danro / index.js
Created Jun 28, 2014
requirebin sketch
View index.js
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) {
@danro
danro / index.js
Created Jun 28, 2014
requirebin sketch
View index.js
var mash = require('mash-js');
var foo = mash(function () {
this.init = function () {
console.log('hello mash');
};
});
foo.create();
View validate-example.js
// validation mixin
var validation = {
getDefaultProps: function () {
return {
validate: []
}
}
, hasErrors: function () {
var errors = []
@danro
danro / index.js
Created Jan 22, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var Hogan = require('hogan.js');
var data = {
screenName: "dhg",
nested: {}
};
@danro
danro / index.js
Created Apr 21, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var pluralize = require('pluralize');
document.body.innerHTML = pluralize.singular('Pasties');
@danro
danro / index.js
Created Apr 25, 2015
requirebin sketch
View index.js
var Promise = require('promise');
var promise = new Promise(function (resolve, reject) {
resolve();
}).done(function() {
console.log('done!');
});
@danro
danro / _test.sh
Last active Aug 29, 2015
No const warning 😢
View _test.sh
./node_modules/.bin/babel test.js # SyntaxError: test.js: Line 2: "FOO" is read-only
./node_modules/.bin/eslint test.js # Nothing