@barchart/portfolio-api-common 1.2.147 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/test/SpecRunner.js +112 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barchart/portfolio-api-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Common classes used by the Portfolio system",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bryan Ingle",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@barchart/common-js": "~3.
|
|
12
|
+
"@barchart/common-js": "~3.3.0",
|
|
13
13
|
"uuid": "3.1.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
package/test/SpecRunner.js
CHANGED
|
@@ -5285,7 +5285,7 @@ module.exports = function () {
|
|
|
5285
5285
|
*
|
|
5286
5286
|
* @public
|
|
5287
5287
|
* @param {*} value - The value of the node.
|
|
5288
|
-
* @param {Tree} parent - The parent node. If not supplied, this will be the root node.
|
|
5288
|
+
* @param {Tree=} parent - The parent node. If not supplied, this will be the root node.
|
|
5289
5289
|
*/
|
|
5290
5290
|
|
|
5291
5291
|
var Tree = function () {
|
|
@@ -6431,7 +6431,20 @@ module.exports = function () {
|
|
|
6431
6431
|
}
|
|
6432
6432
|
|
|
6433
6433
|
/**
|
|
6434
|
-
* Returns a new Day instance for the
|
|
6434
|
+
* Returns a new {@link Day} instance for the start of the month referenced by the current instance.
|
|
6435
|
+
*
|
|
6436
|
+
* @public
|
|
6437
|
+
* @returns {Day}
|
|
6438
|
+
*/
|
|
6439
|
+
|
|
6440
|
+
}, {
|
|
6441
|
+
key: 'getStartOfMonth',
|
|
6442
|
+
value: function getStartOfMonth() {
|
|
6443
|
+
return new Day(this.year, this.month, 1);
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6446
|
+
/**
|
|
6447
|
+
* Returns a new instance for the {@link Day} end of the month referenced by the current instance.
|
|
6435
6448
|
*
|
|
6436
6449
|
* @public
|
|
6437
6450
|
* @returns {Day}
|
|
@@ -6583,7 +6596,7 @@ module.exports = function () {
|
|
|
6583
6596
|
return this._month;
|
|
6584
6597
|
}
|
|
6585
6598
|
|
|
6586
|
-
/**
|
|
6599
|
+
/**day
|
|
6587
6600
|
* The day of the month.
|
|
6588
6601
|
*
|
|
6589
6602
|
* @public
|
|
@@ -6604,7 +6617,7 @@ module.exports = function () {
|
|
|
6604
6617
|
}
|
|
6605
6618
|
|
|
6606
6619
|
/**
|
|
6607
|
-
* Converts a string (which matches the output of {@link Day#format} into
|
|
6620
|
+
* Converts a string (which matches the output of {@link Day#format}) into
|
|
6608
6621
|
* a {@link Day} instance.
|
|
6609
6622
|
*
|
|
6610
6623
|
* @public
|
|
@@ -6875,6 +6888,24 @@ module.exports = function () {
|
|
|
6875
6888
|
return new Decimal(this._big.div(getBig(other)));
|
|
6876
6889
|
}
|
|
6877
6890
|
|
|
6891
|
+
/**
|
|
6892
|
+
* Returns a new {@link Decimal} instance with a value that results
|
|
6893
|
+
* from raising the current instance to the power of the exponent
|
|
6894
|
+
* provided.
|
|
6895
|
+
*
|
|
6896
|
+
* @public
|
|
6897
|
+
* @param {Decimal|Number|String} exponent
|
|
6898
|
+
* @returns {Decimal}
|
|
6899
|
+
*/
|
|
6900
|
+
|
|
6901
|
+
}, {
|
|
6902
|
+
key: 'raise',
|
|
6903
|
+
value: function raise(exponent) {
|
|
6904
|
+
assert.argumentIsRequired(exponent, 'exponent', Number);
|
|
6905
|
+
|
|
6906
|
+
return new Decimal(this._big.pow(exponent));
|
|
6907
|
+
}
|
|
6908
|
+
|
|
6878
6909
|
/**
|
|
6879
6910
|
* Returns a new {@link Decimal} with a value resulting from a rounding
|
|
6880
6911
|
* operation on the current value.
|
|
@@ -7039,6 +7070,28 @@ module.exports = function () {
|
|
|
7039
7070
|
return this._big.eq(getBig(other));
|
|
7040
7071
|
}
|
|
7041
7072
|
|
|
7073
|
+
/**
|
|
7074
|
+
* Returns true is close to another value.
|
|
7075
|
+
*
|
|
7076
|
+
* @public
|
|
7077
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
7078
|
+
* @param {Number} places - The significant digits.
|
|
7079
|
+
* @returns {Boolean}
|
|
7080
|
+
*/
|
|
7081
|
+
|
|
7082
|
+
}, {
|
|
7083
|
+
key: 'getIsApproximate',
|
|
7084
|
+
value: function getIsApproximate(other, places) {
|
|
7085
|
+
if (places === 0) {
|
|
7086
|
+
return this.getIsEqual(other);
|
|
7087
|
+
}
|
|
7088
|
+
|
|
7089
|
+
var difference = this.subtract(other).absolute();
|
|
7090
|
+
var tolerance = Decimal.ONE.divide(new Decimal(10).raise(places));
|
|
7091
|
+
|
|
7092
|
+
return difference.getIsLessThan(tolerance);
|
|
7093
|
+
}
|
|
7094
|
+
|
|
7042
7095
|
/**
|
|
7043
7096
|
* Returns true if the current instance is an integer (i.e. has no decimal
|
|
7044
7097
|
* component).
|
|
@@ -8722,8 +8775,62 @@ module.exports = function () {
|
|
|
8722
8775
|
}
|
|
8723
8776
|
|
|
8724
8777
|
return found;
|
|
8778
|
+
},
|
|
8779
|
+
|
|
8780
|
+
|
|
8781
|
+
/**
|
|
8782
|
+
* Inserts an item into an array using a binary search is used to determine the
|
|
8783
|
+
* proper point for insertion and returns the same array.
|
|
8784
|
+
*
|
|
8785
|
+
* @static
|
|
8786
|
+
* @public
|
|
8787
|
+
* @param {Array} a
|
|
8788
|
+
* @param {*} item
|
|
8789
|
+
* @param {Function} comparator
|
|
8790
|
+
* @returns {Array}
|
|
8791
|
+
*/
|
|
8792
|
+
insert: function insert(a, item, comparator) {
|
|
8793
|
+
assert.argumentIsArray(a, 'a');
|
|
8794
|
+
assert.argumentIsRequired(comparator, 'comparator', Function);
|
|
8795
|
+
|
|
8796
|
+
if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
|
|
8797
|
+
a.push(item);
|
|
8798
|
+
} else if (comparator(item, a[0]) < 0) {
|
|
8799
|
+
a.unshift(item);
|
|
8800
|
+
} else {
|
|
8801
|
+
a.splice(binarySearch(a, item, comparator, 0, a.length - 1), 0, item);
|
|
8802
|
+
}
|
|
8803
|
+
|
|
8804
|
+
return a;
|
|
8725
8805
|
}
|
|
8726
8806
|
};
|
|
8807
|
+
|
|
8808
|
+
function binarySearch(array, item, comparator, start, end) {
|
|
8809
|
+
var size = end - start;
|
|
8810
|
+
|
|
8811
|
+
var midpointIndex = start + Math.floor(size / 2);
|
|
8812
|
+
var midpointItem = array[midpointIndex];
|
|
8813
|
+
|
|
8814
|
+
var comparison = comparator(item, midpointItem) > 0;
|
|
8815
|
+
|
|
8816
|
+
if (size < 2) {
|
|
8817
|
+
if (comparison > 0) {
|
|
8818
|
+
var finalIndex = array.length - 1;
|
|
8819
|
+
|
|
8820
|
+
if (end === finalIndex && comparator(item, array[finalIndex]) > 0) {
|
|
8821
|
+
return end + 1;
|
|
8822
|
+
} else {
|
|
8823
|
+
return end;
|
|
8824
|
+
}
|
|
8825
|
+
} else {
|
|
8826
|
+
return start;
|
|
8827
|
+
}
|
|
8828
|
+
} else if (comparison > 0) {
|
|
8829
|
+
return binarySearch(array, item, comparator, midpointIndex, end);
|
|
8830
|
+
} else {
|
|
8831
|
+
return binarySearch(array, item, comparator, start, midpointIndex);
|
|
8832
|
+
}
|
|
8833
|
+
}
|
|
8727
8834
|
}();
|
|
8728
8835
|
|
|
8729
8836
|
},{"./assert":29,"./is":33}],29:[function(require,module,exports){
|
|
@@ -9244,7 +9351,7 @@ module.exports = function () {
|
|
|
9244
9351
|
* @static
|
|
9245
9352
|
* @public
|
|
9246
9353
|
* @param {*} candidate
|
|
9247
|
-
* @returns {
|
|
9354
|
+
* @returns {boolean}
|
|
9248
9355
|
*/
|
|
9249
9356
|
negative: function negative(candidate) {
|
|
9250
9357
|
return this.number(candidate) && candidate < 0;
|