This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Bar = { bar: ... } | |
var Foo = { foo: ... } | |
var Delegate = { | |
foo: function() { | |
Foo.foo.apply(this, arguments); | |
}, | |
bar: function() { | |
Bar.bar.apply(this, arguments); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mediator.on("receive:thingsFromDB", function(things) { | |
// how I get res here? | |
res.send(things); | |
}); | |
app.get("/things", function(req, res) { | |
mediator.emit("request:thingsFromDB"); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function _routerCallback(req, res) { | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dexter_e> Is there a way to limit Static file match attempts to a certain directory like /static/ ? | |
[6:33 PM] ⇐ fatjonny ([email protected]) quit: Ping timeout: 252 seconds | |
[6:34 PM] <tjholowaychuk> dexter_e use('/static', express.static('static')) | |
[6:34 PM] <tjholowaychuk> that /static can be whatever you want though | |
[6:34 PM] <tjholowaychuk> /public etc | |
[6:34 PM] <dexter_e> and then all other static file load attempts will be ignored ? | |
[6:34 PM] <dexter_e> ( if they don't match any other routes ) | |
[6:35 PM] <tjholowaychuk> yeah | |
[6:35 PM] <dexter_e> Sweet! Thanks! | |
[6:35 PM] <dexter_e> I had one more question about Caching.. Is the cashe reset upon restart ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tasker = Object.create(EventEmitter.prototype, pd({ | |
"options": options, | |
"descruct": require("./descruct").bind(this, tasker), | |
"addTask": require('./tasks/addTask').bind(this, tasker), | |
"removeTask": require('./tasks/removeTask').bind(this, tasker), | |
"getTasksRunning": require('./tasks/getTasksRunning').bind(this, tasker), | |
"getTasksQueued": require('./tasks/getTasksQueued').bind(this, tasker) | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var new = function _new(Constructor) { | |
var thisObj = Object.create(Constructor.prototype); | |
var args = Array.prototype.slice.call(arguments, 1); | |
var retObj = Constructor.apply(thisObj, args); | |
if (typeof retObj === "object") { | |
return retObj; | |
} else { | |
return thisObj | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Tasker = exports.Tasker = function _Tasker(options) { | |
this.options = options; | |
this.state = {}; | |
}; | |
Tasker.prototype = new EventEmitter2(); | |
Tasker.prototype.destruct = destructTasker; | |
Tasker.prototype.addTask = tasks.addTask; | |
Tasker.prototype.removeTask = tasks.removeTask; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Constructor = function _constructor(prop, arg) { | |
this.property = prop; | |
this.public = arg + "dynamic"; | |
} | |
Constructor.prototype.method = function () { | |
... | |
} | |
var obj = new Constructor(42, "value of public"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pd = function _pd(props) { | |
var obj = {}; | |
Object.keys(props).forEach(function (key) { | |
obj[key] = Object.getOwnPropertyDescriptor(props, key); | |
}); | |
return obj; | |
}; | |
pd.merge = function _merge() { | |
var o = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var add = function(a,b) { | |
if (this) dance(); | |
else return a + b; | |
} | |
var addOne = add.bind(null, 1); | |
addOne.call("can I dance please :("); |