-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
43 lines (32 loc) · 1.16 KB
/
server.js
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
38
39
40
41
42
43
FullContact = Npm.require('fullcontact');
var AsyncDecorator = function (Client, scope) {
var client = new Client(scope);
decorateClient(client, this);
Object.defineProperty(this, 'client', {
value: client,
enumerable: true
});
};
function decorateClient(client, decorator) {
var methods = _.functions(client),
decorator = decorator || {};
_.chain(client).pick(methods).each(function(method, methodName) {
decorator[methodName] = Meteor.wrapAsync(method, client);
});
return decorator;
}
FullContact.define(FullContact.prototype, 'location', function define() {
return new AsyncDecorator(FullContact.Location, this);
});
FullContact.define(FullContact.prototype, 'email', function define() {
return new AsyncDecorator(FullContact.Email, this);
});
FullContact.define(FullContact.prototype, 'person', function define() {
return new AsyncDecorator(FullContact.Person, this);
});
FullContact.define(FullContact.prototype, 'name', function define() {
return new AsyncDecorator(FullContact.Name, this);
});
FullContact.define(FullContact.prototype, 'company', function define() {
return new AsyncDecorator(FullContact.Company, this);
});