forked from kriskowal/q
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added q/util and q/queue, with step documentation.
- Loading branch information
Showing
12 changed files
with
671 additions
and
18 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,13 @@ | |||
|
|||
var Q = require("q"); | |||
|
|||
var delay = function (delay) { | |||
var d = Q.defer(); | |||
setTimeout(d.resolve, delay); | |||
return d.promise; | |||
}; | |||
|
|||
Q.when(delay(1000), function () { | |||
console.log('Hello, World!'); | |||
}); | |||
|
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,43 @@ | |||
|
|||
var Q = require("./util"); | |||
|
|||
var eventually = function (eventually) { | |||
return Q.delay(1000, eventually); | |||
}; | |||
|
|||
var x = Q.shallow([1, 2, 3].map(eventually)); | |||
Q.when(x, function (x) { | |||
console.log(x); | |||
}); | |||
|
|||
var x = Q.shallow({ | |||
"a": eventually(10), | |||
"b": eventually(20) | |||
}); | |||
Q.when(x, function (x) { | |||
console.log(x); | |||
}); | |||
|
|||
var x = Q.shallow({ | |||
"a": [1, 2, 3].map(eventually) | |||
}); | |||
Q.when(x, function (x) { | |||
console.log(x); | |||
}); | |||
|
|||
var x = Q.deep({ | |||
"a": [1, 2, 3].map(eventually) | |||
}); | |||
Q.when(x, function (x) { | |||
console.log(x); | |||
}); | |||
|
|||
var x = Q.deep([ | |||
{ | |||
"a": [1, 2, 3].map(eventually) | |||
} | |||
]); | |||
Q.when(x, function (x) { | |||
console.log(x); | |||
}); | |||
|
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,16 @@ | |||
|
|||
var Q = require("q/util"); | |||
var FS = require("q-fs"); | |||
|
|||
Q.step( | |||
function () { | |||
return FS.read(__filename); | |||
}, | |||
function (text) { | |||
return text.toUpperCase(); | |||
}, | |||
function (text) { | |||
console.log(text); | |||
} | |||
); | |||
|
Oops, something went wrong.