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
function hasOwnProperty(key) { | |
if(this[key]) { | |
var proto = this.prototype; | |
if(proto) { | |
return ((key in this.prototype) && (this[key] === this.prototype[key])); | |
} | |
return true; | |
} else { | |
return false; | |
} |
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 data; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function(chunk) { | |
data += chunk; | |
}); | |
process.stdin.on('end', function() { |
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 Base = { | |
_ops: {}, | |
_privateFnc: function () {}, | |
abstract: function () {}, | |
init: function (ops) { | |
this._ops = ops || {}; | |
// INIT | |
} | |
}; |
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
include("/utils.js"); | |
// "this" scope is the object, closures work like normal. Basically this is a nowmal "call" use for functions | |
Object.prototype.instance_eval = function (input) { | |
// Convert the function to a string so that we can rebind it | |
if (typeof input === 'function') { | |
return input.call(this); | |
} | |
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
// Add some ruby-like methods to some of the builtins | |
Object.prototype.instance_eval = function (block) { | |
// Convert the function to a string so that we can rebind it | |
if (typeof block === 'function') { | |
block = "(" + block + ").call(this)"; | |
} | |
// Eval using "this" as the "with" scope | |
return eval("with(this) { " + block + "}"); | |
}; |
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
// res.write is defined by the app framework to take callbacks; it stores the | |
// callbacks in a queue that ensures FIFO order, and when req.end is called it | |
// waits for all the write callbacks to finish before ending | |
var hello = function(req, res) { | |
res.writeHead(200, {}); | |
res.write(function(){ this('Hello World'); }; | |
res.end(); | |
} |
NewerOlder