Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "hippo", | ||
"version": "0.2.0", | ||
"version": "0.3.1", | ||
"homepage": "https://github.com/Attamusc/hippo", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -31,19 +31,11 @@ /** | ||
if (!this._head) { | ||
return this._getRootDescriptor() | ||
.then(function(rootResource) { | ||
this._head = rootResource; | ||
return this._getRootDescriptor() | ||
.then(this._doWalk.bind(this, args)); | ||
}; | ||
if (!args.length) { | ||
return this._head; | ||
} | ||
return this._doWalk(args); | ||
}.bind(this)); | ||
} | ||
return this._doWalk(args); | ||
Client.prototype.clearDescriptorCache = function() { | ||
delete this._descriptorCache; | ||
}; | ||
Client.prototype._doWalk = function(shortNames) { | ||
Client.prototype._doWalk = function(shortNames, head) { | ||
var self = this; | ||
@@ -61,3 +53,3 @@ var walkerPath = toWalkerPath(shortNames); | ||
}); | ||
}, Promise.resolve(this._head)) | ||
}, Promise.resolve(head)) | ||
.then(function(resource) { | ||
@@ -80,2 +72,6 @@ var uri = resource.getConnection('self'); | ||
Client.prototype._getDescriptor = function(uri) { | ||
if ((this._descriptorCache = this._descriptorCache || {})[uri]) { | ||
return this._descriptorCache[uri]; | ||
} | ||
var options = { | ||
@@ -87,6 +83,11 @@ url: uri, | ||
return xhr(options) | ||
this._descriptorCache[uri] = xhr(options) | ||
.then(function(descriptor) { | ||
return new Resource(descriptor); | ||
}); | ||
this._descriptorCache[uri].catch(function() { | ||
delete this._descriptorCache[uri]; | ||
}); | ||
return this._descriptorCache[uri]; | ||
}; | ||
@@ -93,0 +94,0 @@ |
{ | ||
"name": "be-hippo", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A PropositionH hypermedia consumer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,2 +35,6 @@ define(['chai-as-promised', 'lib/client', 'lib/resource'], function(chaiAsPromised, Client, Resource) { | ||
afterEach(function() { | ||
client.clearDescriptorCache(); | ||
}); | ||
describe('that does not conform to the hypermedia format', function() { | ||
@@ -37,0 +41,0 @@ var response = [200, { "Content-Type": "application/json" }, JSON.stringify({})]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62613
1660