@barchart/common-js
Advanced tools
Comparing version 4.28.1 to 4.29.0
@@ -13,4 +13,4 @@ const assert = require('./../../lang/assert'), | ||
/** | ||
* Describes all of the reasons for API failure. Since there can be multiple reasons, the reasons are | ||
* stored in a tree structure. | ||
* Describes all of the reasons for API failure. Since there can be multiple | ||
* reasons, the reasons are stored in a tree structure. | ||
* | ||
@@ -24,4 +24,4 @@ * @public | ||
this._head = new Tree(); | ||
this._current = this._head; | ||
this._root = new Tree(); | ||
this._current = this._root; | ||
} | ||
@@ -55,7 +55,18 @@ | ||
* @public | ||
* @param {Boolean=} previous | ||
* @returns {FailureReason} - The current instance, allowing for method chaining. | ||
*/ | ||
reset() { | ||
this._current = this._head; | ||
reset(previous) { | ||
assert.argumentIsOptional(previous, 'previous', Boolean); | ||
let node; | ||
if (previous && this._current.getIsInner()) { | ||
node = this._current.getParent(); | ||
} else { | ||
node = this._root; | ||
} | ||
this._current = node; | ||
return this; | ||
@@ -71,3 +82,3 @@ } | ||
format() { | ||
const reasons = this._head.toJSObj((item) => { | ||
const reasons = this._root.toJSObj((item) => { | ||
const formatted = { }; | ||
@@ -83,3 +94,3 @@ | ||
return formatted; | ||
}); | ||
}, true); | ||
@@ -100,3 +111,3 @@ return reasons.children; | ||
return this._head.search(item => item.type === type, false, false) !== null; | ||
return this._root.search(item => item.type === type, false, false) !== null; | ||
} | ||
@@ -112,3 +123,3 @@ | ||
getIsSevere() { | ||
return this._head.search(item => item.type.severe, false, false) !== null; | ||
return this._root.search(item => item.type.severe, false, false) !== null; | ||
} | ||
@@ -124,3 +135,3 @@ | ||
getErrorCode() { | ||
const node = this._head.search(item => item.type.error !== null, true, false); | ||
const node = this._root.search(item => item.type.error !== null, true, false); | ||
@@ -177,3 +188,3 @@ if (node !== null) { | ||
reason._head.walk((item) => { | ||
reason._root.walk((item) => { | ||
let code = FailureType.getHttpStatusCode(item.type); | ||
@@ -180,0 +191,0 @@ |
{ | ||
"name": "@barchart/common-js", | ||
"version": "4.28.1", | ||
"version": "4.29.0", | ||
"description": "Library of common JavaScript utilities", | ||
@@ -5,0 +5,0 @@ "author": { |
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
287927
10718