Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a "Lazy" constructor for wrapping promises for objects with kno…
…wn eventual types.
- Loading branch information
Kristopher Kowal
committed
May 19, 2011
1 parent
9a3ac58
commit a0a3e31
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
|
|||
var Q = require('qq'); | |||
|
|||
exports['test Lazy'] = function (ASSERT, done) { | |||
var inputs = [1,2,3]; | |||
var proxy = Q.Lazy(Array, Q.delay(1, inputs)); | |||
var results = []; | |||
var ready = proxy.forEach(function (n) { | |||
results.push(n); | |||
}); | |||
Q.when(ready, function () { | |||
ASSERT.deepEqual(results, inputs, 'forEach on Lazied Array'); | |||
}).then(done, function () { | |||
ASSERT.ok(false); | |||
done(); | |||
});; | |||
}; | |||
|
|||
if (module == require.main) | |||
require('test').run(exports) | |||
|