This file contains 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
'use strict'; | |
var domain = require('domain') | |
, fs = require('fs') | |
, trycatch = require('trycatch') | |
; | |
function thirdPartyFoo(callback) { | |
var d1 = domain.create(); | |
d1.on('error', function(err) { |
This file contains 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
before(function (done) { | |
/** | |
* Mocha is extremely zealous about trapping errors, and runs each test | |
* in a try / catch block. To get the exception to propagate out to the | |
* domain's uncaughtException handler, we need to put the test in an | |
* asynchronous context and break out of the mocha jail. | |
*/ | |
process.nextTick(function () { | |
// disable mocha's error handler | |
mochaHandler = process.listeners('uncaughtException').pop(); |
This file contains 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 f(){var a=arguments,l=a.length/2,o='';for(var i=0;i<l;i++)o+=String.fromCharCode(a[i]|a[i+l]);return o} | |
// =f(6,15,2,2,5,3,4,0,12,0,14,15,2,6,5,12,12,64,96,112,112,96,112,112,32,64,32,64,96,112,112,96,96,96) |
This file contains 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 original = cb; | |
cb = function wrapper() { | |
var args = arguments; | |
process.nextTick(original.apply.bind(this, this, args)); | |
}; |
This file contains 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 BadNewsBears() { | |
var a = 0; | |
Object.defineProperty(this, 'inc', | |
{get : function () { return a++; }, | |
enumerable : true}); | |
Object.defineProperty(this, 'wtf', | |
{get : function () { | |
var b = (this.inc, this.inc, this.inc); | |
return b; | |
}, |
This file contains 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 x = 'global'; | |
function test() { | |
var x = 'local'; | |
("eval",eval)("console.log(x)"); | |
} | |
test(); |
This file contains 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 confusing(bool) { | |
if (bool) { | |
function nested() { | |
console.log("yes"); | |
} | |
} | |
else { | |
function nested() { | |
console.log("no") | |
} |
This file contains 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 lessConfusin(bool) { | |
var nested; | |
if (bool) { | |
nested = function () { | |
console.log("yes"); | |
} | |
} | |
else { | |
nested = function () { | |
console.log("no") |
This file contains 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 alsoUnconfusing(bool) { | |
function nested() { | |
if (bool) { | |
console.log("yes"); | |
} | |
else { | |
console.log("no"); | |
} | |
} | |
This file contains 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
'use strict'; | |
function generate(parent, name) { | |
var node = new parent.constructor(); | |
Object.defineProperty(parent, name, { | |
enumerable : true, | |
configurable : false, | |
writable : false, | |
value : node |