Created
April 25, 2014 21:38
-
-
Save guyellis/11304222 to your computer and use it in GitHub Desktop.
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
// Demonstrates to anyone who has any doubts that | |
// lodash remove() will not procede (i.e. execute | |
// synchronously) until it has a result. | |
var _ = require('lodash'); | |
var x = [1,2,3,4,5,6,7,8,9]; | |
console.log('a1: ' + a); | |
var a = _.remove(x, function(item){ | |
var r = delay(); | |
return item == 5; | |
}); | |
console.log('a2: ' + a); | |
function delay() { | |
var y = 0; | |
for(var i=0; i<100000000; i++) { | |
y += i; | |
} | |
return y; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment