Ox.getAsync: fix docs, rename var
This commit is contained in:
parent
b4dc8d2d58
commit
bbd80ccf4f
1 changed files with 10 additions and 3 deletions
|
@ -30,17 +30,24 @@ Ox.get = function(url, callback) {
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.getAsync <f> Runs an asynchonous loader for an array of URLs
|
Ox.getAsync <f> Runs an asynchonous loader for an array of URLs
|
||||||
(urls, map, callback) -> <u> undefined
|
(urls, get, callback) -> <u> undefined
|
||||||
urls <s|a> URL or array of either URLs or arrays of URLs
|
urls <s|a> URL or array of either URLs or arrays of URLs
|
||||||
Multiple URLs in the same array will be processed simultaneously, but
|
Multiple URLs in the same array will be processed simultaneously, but
|
||||||
multiple arrays of URLs will be processed in that order.
|
multiple arrays of URLs will be processed in that order.
|
||||||
|
get <f> Asynchronous function that loads a URL (for example Ox.get)
|
||||||
|
url <s> URL
|
||||||
|
callback <f> Callback function
|
||||||
|
result <s> Result
|
||||||
|
error <o|null> Error, or null
|
||||||
|
code <n> Status code
|
||||||
|
text <s> Status text
|
||||||
callback <f> Callback function
|
callback <f> Callback function
|
||||||
results <o> Results
|
results <o> Results
|
||||||
Keys are file names, values are results
|
Keys are file names, values are results
|
||||||
errors <o|null> Errors, or null
|
errors <o|null> Errors, or null
|
||||||
Keys are file names, values are error objects
|
Keys are file names, values are error objects
|
||||||
@*/
|
@*/
|
||||||
Ox.getAsync = function(urls, map, callback) {
|
Ox.getAsync = function(urls, get, callback) {
|
||||||
urls = Ox.clone(Ox.makeArray(urls));
|
urls = Ox.clone(Ox.makeArray(urls));
|
||||||
var errors = {}, i = 0, n = urls.length, results = {};
|
var errors = {}, i = 0, n = urls.length, results = {};
|
||||||
function done() {
|
function done() {
|
||||||
|
@ -63,7 +70,7 @@ Ox.getAsync = function(urls, map, callback) {
|
||||||
iterate();
|
iterate();
|
||||||
} else {
|
} else {
|
||||||
urls.forEach(function(url) {
|
urls.forEach(function(url) {
|
||||||
map(url, function(result, error) {
|
get(url, function(result, error) {
|
||||||
Ox.extend(results, url, result);
|
Ox.extend(results, url, result);
|
||||||
Ox.extend(errors, url, error);
|
Ox.extend(errors, url, error);
|
||||||
++i == n && done();
|
++i == n && done();
|
||||||
|
|
Loading…
Reference in a new issue