Created
December 22, 2010 00:57
-
-
Save jashkenas/750910 to your computer and use it in GitHub Desktop.
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
for f, index in files | |
extname = path.extname f | |
fs.lstat f, (err, stats) -> | |
if !stats.isDirectory() and extname is '.coffee' | |
fs.readFile f, 'utf8', compileCallback | |
else if stats.isDirectory() | |
readDirAfterThisOne = -> | |
if index is files.length - 1 then clearInterval(h) and processDir(f) | |
h = setInterval readDirAfterThisOne, 50 | |
# In order for this to work reliably, f and extname would have to be captured, but index would have | |
# to *not* be captured, so that the readDirAfterThisOne closure can work. Here's how this would be | |
# written with the proposed `do` syntax: | |
for f, index in files | |
extname = path.extname f | |
do (f, extname) -> | |
fs.lstat f, (err, stats) -> | |
if !stats.isDirectory() and extname is '.coffee' | |
fs.readFile f, 'utf8', compileCallback | |
else if stats.isDirectory() | |
readDirAfterThisOne = -> | |
if index is files.length - 1 then clearInterval(h) and processDir(f) | |
h = setInterval readDirAfterThisOne, 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment