@barchart/portfolio-api-common 1.0.271 → 1.1.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/test/SpecRunner.js +15 -121
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.271",
3
+ "version": "1.1.0",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1,4 +1,4 @@
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){
1
+ (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
2
2
  const uuid = require('uuid');
3
3
 
4
4
  const assert = require('@barchart/common-js/lang/assert'),
@@ -3951,31 +3951,14 @@ module.exports = function () {
3951
3951
  }
3952
3952
 
3953
3953
  /**
3954
- * Gets the root node.
3954
+ * Returns the parent node. If this is the root node, a null value is returned.
3955
3955
  *
3956
3956
  * @public
3957
- * @returns {Tree}
3957
+ * @returns {Tree|null}
3958
3958
  */
3959
3959
 
3960
3960
 
3961
3961
  _createClass(Tree, [{
3962
- key: 'getRoot',
3963
- value: function getRoot() {
3964
- if (this.getIsRoot()) {
3965
- return this;
3966
- } else {
3967
- return this._parent.getRoot();
3968
- }
3969
- }
3970
-
3971
- /**
3972
- * Returns the parent node. If this is the root node, a null value is returned.
3973
- *
3974
- * @public
3975
- * @returns {Tree|null}
3976
- */
3977
-
3978
- }, {
3979
3962
  key: 'getParent',
3980
3963
  value: function getParent() {
3981
3964
  return this._parent;
@@ -4076,23 +4059,6 @@ module.exports = function () {
4076
4059
  }
4077
4060
  }
4078
4061
 
4079
- /**
4080
- * Removes the current node from the parent tree. Use on a root node
4081
- * has no effect.
4082
- *
4083
- * @public
4084
- */
4085
-
4086
- }, {
4087
- key: 'sever',
4088
- value: function sever() {
4089
- if (this.getIsRoot()) {
4090
- return;
4091
- }
4092
-
4093
- this.getParent().removeChild(this);
4094
- }
4095
-
4096
4062
  /**
4097
4063
  * Searches the children nodes for the first child node that matches the
4098
4064
  * predicate.
@@ -4197,33 +4163,6 @@ module.exports = function () {
4197
4163
  }
4198
4164
  }
4199
4165
 
4200
- /**
4201
- * Climbs the tree, evaluating each parent until a predicate is matched. Once matched,
4202
- * the {@link Tree} node is returned. Otherwise, if the predicate cannot be matched,
4203
- * a null value is returned.
4204
- *
4205
- * @public
4206
- * @param {Tree~nodePredicate} predicate - A predicate that tests each child node. The predicate takes two arguments -- the node's value, and the node itself.
4207
- * @param {boolean=} includeCurrentNode - If true, the predicate will be applied to the current node.
4208
- * @returns {Tree|null}
4209
- */
4210
-
4211
- }, {
4212
- key: 'findParent',
4213
- value: function findParent(predicate, includeCurrentNode) {
4214
- var returnRef = void 0;
4215
-
4216
- if (is.boolean(includeCurrentNode) && includeCurrentNode && predicate(this.getValue(), this)) {
4217
- returnRef = this;
4218
- } else if (this._parent !== null) {
4219
- returnRef = this._parent.findParent(predicate, true);
4220
- } else {
4221
- returnRef = null;
4222
- }
4223
-
4224
- return returnRef;
4225
- }
4226
-
4227
4166
  /**
4228
4167
  * Creates a representation of the tree using JavaScript objects and arrays.
4229
4168
  *
@@ -5514,20 +5453,6 @@ module.exports = function () {
5514
5453
  return this._big.gt(getBig(other));
5515
5454
  }
5516
5455
 
5517
- /**
5518
- * Returns true if the current instance is greater than or equal to the value.
5519
- *
5520
- * @public
5521
- * @param {Decimal|Number|String} other - The value to compare.
5522
- * @returns {Boolean}
5523
- */
5524
-
5525
- }, {
5526
- key: 'getIsGreaterThanOrEqual',
5527
- value: function getIsGreaterThanOrEqual(other) {
5528
- return this._big.gte(getBig(other));
5529
- }
5530
-
5531
5456
  /**
5532
5457
  * Returns true if the current instance is less than the value.
5533
5458
  *
@@ -5542,20 +5467,6 @@ module.exports = function () {
5542
5467
  return this._big.lt(getBig(other));
5543
5468
  }
5544
5469
 
5545
- /**
5546
- * Returns true if the current instance is less than or equal to the value.
5547
- *
5548
- * @public
5549
- * @param {Decimal|Number|String} other - The value to compare.
5550
- * @returns {Boolean}
5551
- */
5552
-
5553
- }, {
5554
- key: 'getIsLessThanOrEqual',
5555
- value: function getIsLessThanOrEqual(other) {
5556
- return this._big.lte(getBig(other));
5557
- }
5558
-
5559
5470
  /**
5560
5471
  * Returns true if the current instance is equal to the value.
5561
5472
  *
@@ -5755,9 +5666,9 @@ module.exports = function () {
5755
5666
  assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
5756
5667
  assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
5757
5668
 
5758
- if (a._big.gt(b._big)) {
5669
+ if (a._big.gt(b)) {
5759
5670
  return 1;
5760
- } else if (a._big.lt(b._big)) {
5671
+ } else if (a._big.lt(b)) {
5761
5672
  return -1;
5762
5673
  } else {
5763
5674
  return 0;
@@ -6218,10 +6129,12 @@ var _createClass = function () { function defineProperties(target, props) { for
6218
6129
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6219
6130
 
6220
6131
  var assert = require('./assert'),
6132
+ is = require('./is'),
6221
6133
  memoize = require('./memoize');
6222
6134
 
6223
6135
  var Currency = require('./Currency'),
6224
- Decimal = require('./Decimal');
6136
+ Decimal = require('./Decimal'),
6137
+ Enum = require('./Enum');
6225
6138
 
6226
6139
  module.exports = function () {
6227
6140
  'use strict';
@@ -6401,7 +6314,12 @@ module.exports = function () {
6401
6314
  assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
6402
6315
  assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
6403
6316
  assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
6404
- //assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
6317
+
6318
+ for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
6319
+ rates[_key - 3] = arguments[_key];
6320
+ }
6321
+
6322
+ assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
6405
6323
 
6406
6324
  var converted = void 0;
6407
6325
 
@@ -6411,10 +6329,6 @@ module.exports = function () {
6411
6329
  var numerator = desiredCurrency;
6412
6330
  var denominator = currency;
6413
6331
 
6414
- for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
6415
- rates[_key - 3] = arguments[_key];
6416
- }
6417
-
6418
6332
  var rate = rates.find(function (r) {
6419
6333
  return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
6420
6334
  });
@@ -6465,7 +6379,7 @@ module.exports = function () {
6465
6379
  return Rate;
6466
6380
  }();
6467
6381
 
6468
- },{"./Currency":17,"./Decimal":19,"./assert":24,"./memoize":27}],23:[function(require,module,exports){
6382
+ },{"./Currency":17,"./Decimal":19,"./Enum":21,"./assert":24,"./is":26,"./memoize":27}],23:[function(require,module,exports){
6469
6383
  'use strict';
6470
6384
 
6471
6385
  var assert = require('./assert'),
@@ -6842,26 +6756,6 @@ module.exports = function () {
6842
6756
  });
6843
6757
 
6844
6758
  return returnRef;
6845
- },
6846
-
6847
-
6848
- /**
6849
- * Removes the first item from an array which matches a predicate.
6850
- *
6851
- * @static
6852
- * @public
6853
- * @param {Array} a
6854
- * @param {Function} predicate
6855
- */
6856
- remove: function remove(a, predicate) {
6857
- assert.argumentIsArray(a, 'a');
6858
- assert.argumentIsRequired(predicate, 'predicate', Function);
6859
-
6860
- var index = a.findIndex(predicate);
6861
-
6862
- if (!(index < 0)) {
6863
- a.splice(index, 1);
6864
- }
6865
6759
  }
6866
6760
  };
6867
6761
  }();