potion-client
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -23,3 +23,2 @@ "use strict"; | ||
_super.apply(this, arguments); | ||
this.promise = $q; | ||
} | ||
@@ -31,2 +30,3 @@ Potion.prototype.fetch = function (url, options) { | ||
}; | ||
Potion.promise = $q; | ||
return Potion; | ||
@@ -33,0 +33,0 @@ }(base_1.PotionBase)); |
@@ -35,4 +35,4 @@ export declare function readonly(target: any, property: any): void; | ||
export declare abstract class PotionBase { | ||
protected static promise: any; | ||
resources: {}; | ||
promise: any; | ||
private _prefix; | ||
@@ -39,0 +39,0 @@ private _itemCache; |
16
base.js
@@ -102,3 +102,2 @@ "use strict"; | ||
this.resources = {}; | ||
this.promise = window.Promise; | ||
this._promises = []; | ||
@@ -141,3 +140,3 @@ this._prefix = prefix; | ||
if (item) { | ||
return this.promise.resolve(item); | ||
return this.constructor.promise.resolve(item); | ||
} | ||
@@ -197,3 +196,3 @@ } | ||
if (json instanceof Array) { | ||
return this.promise.all(json.map(function (item) { return _this._fromPotionJson(item); })); | ||
return this.constructor.promise.all(json.map(function (item) { return _this._fromPotionJson(item); })); | ||
} | ||
@@ -205,3 +204,3 @@ else if (typeof json.$uri === 'string') { | ||
if (key === '$uri') { | ||
promises_1.push(this_1.promise.resolve([key, uri_1])); | ||
promises_1.push(this_1.constructor.promise.resolve([key, uri_1])); | ||
} | ||
@@ -219,3 +218,3 @@ else { | ||
} | ||
return this.promise.all(promises_1).then(function (propertyValuePairs) { | ||
return this.constructor.promise.all(promises_1).then(function (propertyValuePairs) { | ||
var properties = utils_1.pairsToObject(propertyValuePairs); // `propertyValuePairs` is a collection of [key, value] pairs | ||
@@ -241,3 +240,3 @@ var obj = {}; | ||
else if (typeof json.$date !== 'undefined') { | ||
return this.promise.resolve(new Date(json.$date)); | ||
return this.constructor.promise.resolve(new Date(json.$date)); | ||
} | ||
@@ -256,3 +255,3 @@ } | ||
} | ||
return this.promise.all(promises).then(function (propertyValuePairs) { | ||
return this.constructor.promise.all(promises).then(function (propertyValuePairs) { | ||
return utils_1.pairsToObject(propertyValuePairs); | ||
@@ -262,5 +261,6 @@ }); | ||
else { | ||
return this.promise.resolve(json); | ||
return this.constructor.promise.resolve(json); | ||
} | ||
}; | ||
PotionBase.promise = window.Promise; | ||
return PotionBase; | ||
@@ -267,0 +267,0 @@ }()); |
{ | ||
"name": "potion-client", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A ES6 client for APIs written in Flask-Potion", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40048