add callback to Ox.api

This commit is contained in:
rlx 2012-03-29 19:32:05 +00:00
parent f3ff4b791d
commit 4b59c9a2a9

View file

@ -2,6 +2,8 @@
/*@ /*@
Ox.api <f> Turns an array into a list API Ox.api <f> Turns an array into a list API
<code>Ox.api</code> takes an array and returns a function that allows you to
run complex queries against it. See the examples below for details.
(items, options) -> <f> List API (items, options) -> <f> List API
items <[o]> An array of objects (key/value stores) items <[o]> An array of objects (key/value stores)
options <o> Options object options <o> Options object
@ -215,7 +217,7 @@ Ox.api = function(items, options) {
return match; return match;
} }
return function(options) { return function(options, callback) {
var data, var data,
result = {data: {}, status: {code: 200, text: 'ok'}}, result = {data: {}, status: {code: 200, text: 'ok'}},
sort = {}; sort = {};
@ -278,6 +280,7 @@ Ox.api = function(items, options) {
); );
} }
} }
callback && callback(result);
return result; return result;
}; };