forked from meteorhacks/npm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (31 loc) · 678 Bytes
/
Copy pathindex.js
File metadata and controls
37 lines (31 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var Future = Npm.require('fibers/future');
Meteor.require = function(moduleName) {
var module = Npm.require(moduleName);
return module;
};
Meteor.sync = function(asynFunction) {
var future = new Future();
var sent = false;
var payload;
setTimeout(function() {
asynFunction(done);
function done(err, result) {
if(!sent) {
payload = {
result: result,
error: err
};
if(future.ret) {
//for 0.6.4.1 and older
future.ret();
} else {
//for 0.6.5 and newer
future.return();
}
}
}
}, 0);
future.wait();
sent = true;
return payload;
};