UNPKG

2.13 kBJavaScriptView Raw
1var YouBase, exports,
2 __slice = [].slice;
3
4YouBase = (function() {
5 function YouBase(custodian) {
6 this.custodian = custodian != null ? custodian : 'http://api.youbase.io';
7 if (!(this instanceof YouBase)) {
8 return new YouBase(this.custodian);
9 }
10 if (typeof this.custodian === 'string') {
11 this.custodian = YouBase.Custodian({
12 storage: 'rest',
13 url: this.custodian
14 });
15 }
16 }
17
18 YouBase.prototype.wallet = function() {
19 return (function(func, args, ctor) {
20 ctor.prototype = func.prototype;
21 var child = new ctor, result = func.apply(child, args);
22 return Object(result) === result ? result : child;
23 })(YouBase.Wallet, [this.custodian].concat(__slice.call(arguments)), function(){});
24 };
25
26 YouBase.prototype.document = function() {
27 return (function(func, args, ctor) {
28 ctor.prototype = func.prototype;
29 var child = new ctor, result = func.apply(child, args);
30 return Object(result) === result ? result : child;
31 })(YouBase.Document, [this.custodian].concat(__slice.call(arguments)), function(){});
32 };
33
34 YouBase.prototype.definition = function() {
35 return (function(func, args, ctor) {
36 ctor.prototype = func.prototype;
37 var child = new ctor, result = func.apply(child, args);
38 return Object(result) === result ? result : child;
39 })(YouBase.Definition, [this.custodian].concat(__slice.call(arguments)), function(){});
40 };
41
42 YouBase.prototype.collection = function() {
43 return (function(func, args, ctor) {
44 ctor.prototype = func.prototype;
45 var child = new ctor, result = func.apply(child, args);
46 return Object(result) === result ? result : child;
47 })(YouBase.Collection, [this.custodian, YouBase.Document].concat(__slice.call(arguments)), function(){});
48 };
49
50 return YouBase;
51
52})();
53
54YouBase.Custodian = require('./custodian');
55
56YouBase.Definition = require('./definition');
57
58YouBase.Wallet = require('./wallet');
59
60YouBase.Document = require('./document');
61
62YouBase.Collection = require('./collection');
63
64YouBase.Envelope = require('ecc-envelope');
65
66exports = module.exports = YouBase;