@barchart/portfolio-api-common 1.0.259 → 1.0.260
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/lib/serialization/TransactionSchema.js +1 -1
- package/package.json +1 -1
- package/test/SpecRunner.js +121 -15
|
@@ -233,7 +233,6 @@ module.exports = (() => {
|
|
|
233
233
|
.withField('dividend.effective', DataType.DAY, true)
|
|
234
234
|
.withField('dividend.price', DataType.DECIMAL, true)
|
|
235
235
|
.withField('dividend.amount', DataType.DECIMAL, true)
|
|
236
|
-
.withField('dividend.reference', DataType.STRING, true)
|
|
237
236
|
.withField('split.numerator', DataType.DECIMAL, true)
|
|
238
237
|
.withField('split.denominator', DataType.DECIMAL, true)
|
|
239
238
|
.withField('split.effective', DataType.DAY, true)
|
|
@@ -283,6 +282,7 @@ module.exports = (() => {
|
|
|
283
282
|
.withField('quantity', DataType.DECIMAL)
|
|
284
283
|
.withField('fee', DataType.DECIMAL, true)
|
|
285
284
|
.withField('force', DataType.BOOLEAN, true)
|
|
285
|
+
.withField('force', DataType.BOOLEAN, true)
|
|
286
286
|
.schema
|
|
287
287
|
);
|
|
288
288
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){function e
|
|
1
|
+
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
2
|
const uuid = require('uuid');
|
|
3
3
|
|
|
4
4
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
@@ -3635,14 +3635,31 @@ module.exports = function () {
|
|
|
3635
3635
|
}
|
|
3636
3636
|
|
|
3637
3637
|
/**
|
|
3638
|
-
*
|
|
3638
|
+
* Gets the root node.
|
|
3639
3639
|
*
|
|
3640
3640
|
* @public
|
|
3641
|
-
* @returns {Tree
|
|
3641
|
+
* @returns {Tree}
|
|
3642
3642
|
*/
|
|
3643
3643
|
|
|
3644
3644
|
|
|
3645
3645
|
_createClass(Tree, [{
|
|
3646
|
+
key: 'getRoot',
|
|
3647
|
+
value: function getRoot() {
|
|
3648
|
+
if (this.getIsRoot()) {
|
|
3649
|
+
return this;
|
|
3650
|
+
} else {
|
|
3651
|
+
return this._parent.getRoot();
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
/**
|
|
3656
|
+
* Returns the parent node. If this is the root node, a null value is returned.
|
|
3657
|
+
*
|
|
3658
|
+
* @public
|
|
3659
|
+
* @returns {Tree|null}
|
|
3660
|
+
*/
|
|
3661
|
+
|
|
3662
|
+
}, {
|
|
3646
3663
|
key: 'getParent',
|
|
3647
3664
|
value: function getParent() {
|
|
3648
3665
|
return this._parent;
|
|
@@ -3743,6 +3760,23 @@ module.exports = function () {
|
|
|
3743
3760
|
}
|
|
3744
3761
|
}
|
|
3745
3762
|
|
|
3763
|
+
/**
|
|
3764
|
+
* Removes the current node from the parent tree. Use on a root node
|
|
3765
|
+
* has no effect.
|
|
3766
|
+
*
|
|
3767
|
+
* @public
|
|
3768
|
+
*/
|
|
3769
|
+
|
|
3770
|
+
}, {
|
|
3771
|
+
key: 'sever',
|
|
3772
|
+
value: function sever() {
|
|
3773
|
+
if (this.getIsRoot()) {
|
|
3774
|
+
return;
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
this.getParent().removeChild(this);
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3746
3780
|
/**
|
|
3747
3781
|
* Searches the children nodes for the first child node that matches the
|
|
3748
3782
|
* predicate.
|
|
@@ -3847,6 +3881,33 @@ module.exports = function () {
|
|
|
3847
3881
|
}
|
|
3848
3882
|
}
|
|
3849
3883
|
|
|
3884
|
+
/**
|
|
3885
|
+
* Climbs the tree, evaluating each parent until a predicate is matched. Once matched,
|
|
3886
|
+
* the {@link Tree} node is returned. Otherwise, if the predicate cannot be matched,
|
|
3887
|
+
* a null value is returned.
|
|
3888
|
+
*
|
|
3889
|
+
* @public
|
|
3890
|
+
* @param {Tree~nodePredicate} predicate - A predicate that tests each child node. The predicate takes two arguments -- the node's value, and the node itself.
|
|
3891
|
+
* @param {boolean=} includeCurrentNode - If true, the predicate will be applied to the current node.
|
|
3892
|
+
* @returns {Tree|null}
|
|
3893
|
+
*/
|
|
3894
|
+
|
|
3895
|
+
}, {
|
|
3896
|
+
key: 'findParent',
|
|
3897
|
+
value: function findParent(predicate, includeCurrentNode) {
|
|
3898
|
+
var returnRef = void 0;
|
|
3899
|
+
|
|
3900
|
+
if (is.boolean(includeCurrentNode) && includeCurrentNode && predicate(this.getValue(), this)) {
|
|
3901
|
+
returnRef = this;
|
|
3902
|
+
} else if (this._parent !== null) {
|
|
3903
|
+
returnRef = this._parent.findParent(predicate, true);
|
|
3904
|
+
} else {
|
|
3905
|
+
returnRef = null;
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
return returnRef;
|
|
3909
|
+
}
|
|
3910
|
+
|
|
3850
3911
|
/**
|
|
3851
3912
|
* Creates a representation of the tree using JavaScript objects and arrays.
|
|
3852
3913
|
*
|
|
@@ -5137,6 +5198,20 @@ module.exports = function () {
|
|
|
5137
5198
|
return this._big.gt(getBig(other));
|
|
5138
5199
|
}
|
|
5139
5200
|
|
|
5201
|
+
/**
|
|
5202
|
+
* Returns true if the current instance is greater than or equal to the value.
|
|
5203
|
+
*
|
|
5204
|
+
* @public
|
|
5205
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
5206
|
+
* @returns {Boolean}
|
|
5207
|
+
*/
|
|
5208
|
+
|
|
5209
|
+
}, {
|
|
5210
|
+
key: 'getIsGreaterThanOrEqual',
|
|
5211
|
+
value: function getIsGreaterThanOrEqual(other) {
|
|
5212
|
+
return this._big.gte(getBig(other));
|
|
5213
|
+
}
|
|
5214
|
+
|
|
5140
5215
|
/**
|
|
5141
5216
|
* Returns true if the current instance is less than the value.
|
|
5142
5217
|
*
|
|
@@ -5151,6 +5226,20 @@ module.exports = function () {
|
|
|
5151
5226
|
return this._big.lt(getBig(other));
|
|
5152
5227
|
}
|
|
5153
5228
|
|
|
5229
|
+
/**
|
|
5230
|
+
* Returns true if the current instance is less than or equal to the value.
|
|
5231
|
+
*
|
|
5232
|
+
* @public
|
|
5233
|
+
* @param {Decimal|Number|String} other - The value to compare.
|
|
5234
|
+
* @returns {Boolean}
|
|
5235
|
+
*/
|
|
5236
|
+
|
|
5237
|
+
}, {
|
|
5238
|
+
key: 'getIsLessThanOrEqual',
|
|
5239
|
+
value: function getIsLessThanOrEqual(other) {
|
|
5240
|
+
return this._big.lte(getBig(other));
|
|
5241
|
+
}
|
|
5242
|
+
|
|
5154
5243
|
/**
|
|
5155
5244
|
* Returns true if the current instance is equal to the value.
|
|
5156
5245
|
*
|
|
@@ -5350,9 +5439,9 @@ module.exports = function () {
|
|
|
5350
5439
|
assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
|
|
5351
5440
|
assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
|
|
5352
5441
|
|
|
5353
|
-
if (a._big.gt(b)) {
|
|
5442
|
+
if (a._big.gt(b._big)) {
|
|
5354
5443
|
return 1;
|
|
5355
|
-
} else if (a._big.lt(b)) {
|
|
5444
|
+
} else if (a._big.lt(b._big)) {
|
|
5356
5445
|
return -1;
|
|
5357
5446
|
} else {
|
|
5358
5447
|
return 0;
|
|
@@ -5813,12 +5902,10 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
5813
5902
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5814
5903
|
|
|
5815
5904
|
var assert = require('./assert'),
|
|
5816
|
-
is = require('./is'),
|
|
5817
5905
|
memoize = require('./memoize');
|
|
5818
5906
|
|
|
5819
5907
|
var Currency = require('./Currency'),
|
|
5820
|
-
Decimal = require('./Decimal')
|
|
5821
|
-
Enum = require('./Enum');
|
|
5908
|
+
Decimal = require('./Decimal');
|
|
5822
5909
|
|
|
5823
5910
|
module.exports = function () {
|
|
5824
5911
|
'use strict';
|
|
@@ -5998,12 +6085,7 @@ module.exports = function () {
|
|
|
5998
6085
|
assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
|
|
5999
6086
|
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
6000
6087
|
assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
|
|
6001
|
-
|
|
6002
|
-
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
6003
|
-
rates[_key - 3] = arguments[_key];
|
|
6004
|
-
}
|
|
6005
|
-
|
|
6006
|
-
assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
6088
|
+
//assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
6007
6089
|
|
|
6008
6090
|
var converted = void 0;
|
|
6009
6091
|
|
|
@@ -6013,6 +6095,10 @@ module.exports = function () {
|
|
|
6013
6095
|
var numerator = desiredCurrency;
|
|
6014
6096
|
var denominator = currency;
|
|
6015
6097
|
|
|
6098
|
+
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
6099
|
+
rates[_key - 3] = arguments[_key];
|
|
6100
|
+
}
|
|
6101
|
+
|
|
6016
6102
|
var rate = rates.find(function (r) {
|
|
6017
6103
|
return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
|
|
6018
6104
|
});
|
|
@@ -6063,7 +6149,7 @@ module.exports = function () {
|
|
|
6063
6149
|
return Rate;
|
|
6064
6150
|
}();
|
|
6065
6151
|
|
|
6066
|
-
},{"./Currency":15,"./Decimal":17,"./
|
|
6152
|
+
},{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
|
|
6067
6153
|
'use strict';
|
|
6068
6154
|
|
|
6069
6155
|
var assert = require('./assert'),
|
|
@@ -6440,6 +6526,26 @@ module.exports = function () {
|
|
|
6440
6526
|
});
|
|
6441
6527
|
|
|
6442
6528
|
return returnRef;
|
|
6529
|
+
},
|
|
6530
|
+
|
|
6531
|
+
|
|
6532
|
+
/**
|
|
6533
|
+
* Removes the first item from an array which matches a predicate.
|
|
6534
|
+
*
|
|
6535
|
+
* @static
|
|
6536
|
+
* @public
|
|
6537
|
+
* @param {Array} a
|
|
6538
|
+
* @param {Function} predicate
|
|
6539
|
+
*/
|
|
6540
|
+
remove: function remove(a, predicate) {
|
|
6541
|
+
assert.argumentIsArray(a, 'a');
|
|
6542
|
+
assert.argumentIsRequired(predicate, 'predicate', Function);
|
|
6543
|
+
|
|
6544
|
+
var index = a.findIndex(predicate);
|
|
6545
|
+
|
|
6546
|
+
if (!(index < 0)) {
|
|
6547
|
+
a.splice(index, 1);
|
|
6548
|
+
}
|
|
6443
6549
|
}
|
|
6444
6550
|
};
|
|
6445
6551
|
}();
|