@barchart/portfolio-api-common 1.0.232 → 1.0.236

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.
@@ -61,7 +61,7 @@ module.exports = (() => {
61
61
  }
62
62
 
63
63
  /**
64
- * Indicates if the trade was a purchase.
64
+ * Indicates if the transaction was a purchase.
65
65
  *
66
66
  * @public
67
67
  * @returns {Boolean}
@@ -71,7 +71,7 @@ module.exports = (() => {
71
71
  }
72
72
 
73
73
  /**
74
- * Indicates if the trade was a sale.
74
+ * Indicates if the transaction was a sale.
75
75
  *
76
76
  * @public
77
77
  * @returns {Boolean}
@@ -91,7 +91,7 @@ module.exports = (() => {
91
91
  }
92
92
 
93
93
  /**
94
- * Indicates if the transactions opens the position (i.e. increases its
94
+ * Indicates if the transaction opens the position (i.e. increases its
95
95
  * magnitude).
96
96
  *
97
97
  * @public
@@ -102,7 +102,7 @@ module.exports = (() => {
102
102
  }
103
103
 
104
104
  /**
105
- * Indicates if the transactions closes the position (i.e. decreases its
105
+ * Indicates if the transaction closes the position (i.e. decreases its
106
106
  * magnitude).
107
107
  *
108
108
  * @public
@@ -112,6 +112,17 @@ module.exports = (() => {
112
112
  return this._closing;
113
113
  }
114
114
 
115
+ /**
116
+ * Indicates if the transaction is a chart that neither opens nor
117
+ * closes the position.
118
+ *
119
+ * @public
120
+ * @returns {Boolean}
121
+ */
122
+ get fee() {
123
+ return this._fee;
124
+ }
125
+
115
126
  /**
116
127
  * A purchase.
117
128
  *
@@ -323,7 +334,7 @@ module.exports = (() => {
323
334
  const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
324
335
  const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
325
336
  const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
326
- const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, true, false, true);
337
+ const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
327
338
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
328
339
 
329
340
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
@@ -170,6 +170,7 @@ module.exports = (() => {
170
170
 
171
171
  formatters.set(TransactionType.FEE, (t) => {
172
172
  return {
173
+ fee: t.charge.amount,
173
174
  total: t.charge.amount
174
175
  };
175
176
  });
@@ -73,7 +73,7 @@ module.exports = (() => {
73
73
  }, { });
74
74
 
75
75
  this._previousSummaryFrame = PositionSummaryFrame.YEARLY;
76
- this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(0);
76
+ this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(1);
77
77
 
78
78
  this._summariesPrevious = summaries.reduce((map, summary) => {
79
79
  addSummaryPrevious(map, summary, this._previousSummaryFrame, this._previousSummaryRanges);
@@ -127,6 +127,7 @@ module.exports = (() => {
127
127
  this._dataActual.total = null;
128
128
  this._dataActual.summaryTotalCurrent = null;
129
129
  this._dataActual.summaryTotalPrevious = null;
130
+ this._dataActual.summaryTotalPrevious2 = null;
130
131
  this._dataActual.cashTotal = null;
131
132
 
132
133
  this._dataFormat.currentPrice = null;
@@ -148,6 +149,8 @@ module.exports = (() => {
148
149
  this._dataActual.summaryTotalCurrentNegative = false;
149
150
  this._dataFormat.summaryTotalPrevious = null;
150
151
  this._dataFormat.summaryTotalPreviousNegative = false;
152
+ this._dataFormat.summaryTotalPrevious2 = null;
153
+ this._dataFormat.summaryTotalPrevious2Negative = false;
151
154
  this._dataFormat.cashTotal = null;
152
155
  this._dataFormat.portfolioType = null;
153
156
 
@@ -595,6 +598,7 @@ module.exports = (() => {
595
598
  updates.income = updates.income.add(translate(item, item.data.income));
596
599
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
597
600
  updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
601
+ updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
598
602
 
599
603
  if (item.position.instrument.type === InstrumentType.CASH) {
600
604
  updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
@@ -608,6 +612,7 @@ module.exports = (() => {
608
612
  income: Decimal.ZERO,
609
613
  summaryTotalCurrent: Decimal.ZERO,
610
614
  summaryTotalPrevious: Decimal.ZERO,
615
+ summaryTotalPrevious2: Decimal.ZERO,
611
616
  cashTotal: Decimal.ZERO
612
617
  });
613
618
 
@@ -617,6 +622,7 @@ module.exports = (() => {
617
622
  actual.income = updates.income;
618
623
  actual.summaryTotalCurrent = updates.summaryTotalCurrent;
619
624
  actual.summaryTotalPrevious = updates.summaryTotalPrevious;
625
+ actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
620
626
  actual.cashTotal = updates.cashTotal;
621
627
 
622
628
  format.basis = formatCurrency(actual.basis, currency);
@@ -626,6 +632,8 @@ module.exports = (() => {
626
632
  format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
627
633
  format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
628
634
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
635
+ format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
636
+ format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
629
637
  format.cashTotal = formatCurrency(updates.cashTotal, currency);
630
638
 
631
639
  calculateUnrealizedPercent(group);
@@ -1,5 +1,4 @@
1
- const array = require('@barchart/common-js/lang/array'),
2
- assert = require('@barchart/common-js/lang/assert'),
1
+ const assert = require('@barchart/common-js/lang/assert'),
3
2
  Currency = require('@barchart/common-js/lang/Currency'),
4
3
  Decimal = require('@barchart/common-js/lang/Decimal'),
5
4
  Disposable = require('@barchart/common-js/lang/Disposable'),
@@ -59,6 +58,7 @@ module.exports = (() => {
59
58
  this._data.summaryTotalCurrentChange = null;
60
59
 
61
60
  this._data.summaryTotalPrevious = null;
61
+ this._data.summaryTotalPrevious2 = null;
62
62
 
63
63
  this._data.realized = null;
64
64
  this._data.income = null;
@@ -318,7 +318,8 @@ module.exports = (() => {
318
318
  data.income = snapshot.income;
319
319
 
320
320
  data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary);
321
- data.summaryTotalPrevious = calculateSummaryTotal(array.last(previousSummaries));
321
+ data.summaryTotalPrevious = calculateSummaryTotal(getPreviousSummary(previousSummaries, 1));
322
+ data.summaryTotalPrevious2 = calculateSummaryTotal(getPreviousSummary(previousSummaries, 2));
322
323
 
323
324
  if (snapshot.open.getIsZero()) {
324
325
  data.basisPrice = Decimal.ZERO;
@@ -439,5 +440,19 @@ module.exports = (() => {
439
440
  return returnRef;
440
441
  }
441
442
 
443
+ function getPreviousSummary(previousSummaries, count) {
444
+ const index = previousSummaries.length - count;
445
+
446
+ let summary;
447
+
448
+ if (!(index < 0)) {
449
+ summary = previousSummaries[index];
450
+ } else {
451
+ summary = null;
452
+ }
453
+
454
+ return summary;
455
+ }
456
+
442
457
  return PositionItem;
443
458
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.232",
3
+ "version": "1.0.236",
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 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){
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'),
@@ -506,7 +506,7 @@ module.exports = (() => {
506
506
  }
507
507
 
508
508
  /**
509
- * Indicates if the trade was a purchase.
509
+ * Indicates if the transaction was a purchase.
510
510
  *
511
511
  * @public
512
512
  * @returns {Boolean}
@@ -516,7 +516,7 @@ module.exports = (() => {
516
516
  }
517
517
 
518
518
  /**
519
- * Indicates if the trade was a sale.
519
+ * Indicates if the transaction was a sale.
520
520
  *
521
521
  * @public
522
522
  * @returns {Boolean}
@@ -536,7 +536,7 @@ module.exports = (() => {
536
536
  }
537
537
 
538
538
  /**
539
- * Indicates if the transactions opens the position (i.e. increases its
539
+ * Indicates if the transaction opens the position (i.e. increases its
540
540
  * magnitude).
541
541
  *
542
542
  * @public
@@ -547,7 +547,7 @@ module.exports = (() => {
547
547
  }
548
548
 
549
549
  /**
550
- * Indicates if the transactions closes the position (i.e. decreases its
550
+ * Indicates if the transaction closes the position (i.e. decreases its
551
551
  * magnitude).
552
552
  *
553
553
  * @public
@@ -557,6 +557,17 @@ module.exports = (() => {
557
557
  return this._closing;
558
558
  }
559
559
 
560
+ /**
561
+ * Indicates if the transaction is a chart that neither opens nor
562
+ * closes the position.
563
+ *
564
+ * @public
565
+ * @returns {Boolean}
566
+ */
567
+ get fee() {
568
+ return this._fee;
569
+ }
570
+
560
571
  /**
561
572
  * A purchase.
562
573
  *
@@ -768,7 +779,7 @@ module.exports = (() => {
768
779
  const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
769
780
  const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
770
781
  const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
771
- const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, true, false, true);
782
+ const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
772
783
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
773
784
 
774
785
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
@@ -861,7 +872,7 @@ module.exports = (() => {
861
872
  }, { });
862
873
 
863
874
  this._previousSummaryFrame = PositionSummaryFrame.YEARLY;
864
- this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(0);
875
+ this._previousSummaryRanges = this._previousSummaryFrame.getRecentRanges(1);
865
876
 
866
877
  this._summariesPrevious = summaries.reduce((map, summary) => {
867
878
  addSummaryPrevious(map, summary, this._previousSummaryFrame, this._previousSummaryRanges);
@@ -1810,6 +1821,7 @@ module.exports = (() => {
1810
1821
  this._dataActual.total = null;
1811
1822
  this._dataActual.summaryTotalCurrent = null;
1812
1823
  this._dataActual.summaryTotalPrevious = null;
1824
+ this._dataActual.summaryTotalPrevious2 = null;
1813
1825
  this._dataActual.cashTotal = null;
1814
1826
 
1815
1827
  this._dataFormat.currentPrice = null;
@@ -1831,6 +1843,8 @@ module.exports = (() => {
1831
1843
  this._dataActual.summaryTotalCurrentNegative = false;
1832
1844
  this._dataFormat.summaryTotalPrevious = null;
1833
1845
  this._dataFormat.summaryTotalPreviousNegative = false;
1846
+ this._dataFormat.summaryTotalPrevious2 = null;
1847
+ this._dataFormat.summaryTotalPrevious2Negative = false;
1834
1848
  this._dataFormat.cashTotal = null;
1835
1849
  this._dataFormat.portfolioType = null;
1836
1850
 
@@ -2278,6 +2292,7 @@ module.exports = (() => {
2278
2292
  updates.income = updates.income.add(translate(item, item.data.income));
2279
2293
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
2280
2294
  updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
2295
+ updates.summaryTotalPrevious2 = updates.summaryTotalPrevious2.add(translate(item, item.data.summaryTotalPrevious2));
2281
2296
 
2282
2297
  if (item.position.instrument.type === InstrumentType.CASH) {
2283
2298
  updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
@@ -2291,6 +2306,7 @@ module.exports = (() => {
2291
2306
  income: Decimal.ZERO,
2292
2307
  summaryTotalCurrent: Decimal.ZERO,
2293
2308
  summaryTotalPrevious: Decimal.ZERO,
2309
+ summaryTotalPrevious2: Decimal.ZERO,
2294
2310
  cashTotal: Decimal.ZERO
2295
2311
  });
2296
2312
 
@@ -2300,6 +2316,7 @@ module.exports = (() => {
2300
2316
  actual.income = updates.income;
2301
2317
  actual.summaryTotalCurrent = updates.summaryTotalCurrent;
2302
2318
  actual.summaryTotalPrevious = updates.summaryTotalPrevious;
2319
+ actual.summaryTotalPrevious2 = updates.summaryTotalPrevious2;
2303
2320
  actual.cashTotal = updates.cashTotal;
2304
2321
 
2305
2322
  format.basis = formatCurrency(actual.basis, currency);
@@ -2309,6 +2326,8 @@ module.exports = (() => {
2309
2326
  format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
2310
2327
  format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
2311
2328
  format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
2329
+ format.summaryTotalPrevious2 = formatCurrency(updates.summaryTotalPrevious2, currency);
2330
+ format.summaryTotalPrevious2Negative = updates.summaryTotalPrevious2.getIsNegative();
2312
2331
  format.cashTotal = formatCurrency(updates.cashTotal, currency);
2313
2332
 
2314
2333
  calculateUnrealizedPercent(group);
@@ -2492,8 +2511,7 @@ module.exports = (() => {
2492
2511
  })();
2493
2512
 
2494
2513
  },{"./../data/InstrumentType":1,"./definitions/PositionLevelDefinition":7,"./definitions/PositionLevelType":8,"@barchart/common-js/collections/specialized/DisposableStack":14,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/Rate":20,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/formatter":23,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],6:[function(require,module,exports){
2495
- const array = require('@barchart/common-js/lang/array'),
2496
- assert = require('@barchart/common-js/lang/assert'),
2514
+ const assert = require('@barchart/common-js/lang/assert'),
2497
2515
  Currency = require('@barchart/common-js/lang/Currency'),
2498
2516
  Decimal = require('@barchart/common-js/lang/Decimal'),
2499
2517
  Disposable = require('@barchart/common-js/lang/Disposable'),
@@ -2553,6 +2571,7 @@ module.exports = (() => {
2553
2571
  this._data.summaryTotalCurrentChange = null;
2554
2572
 
2555
2573
  this._data.summaryTotalPrevious = null;
2574
+ this._data.summaryTotalPrevious2 = null;
2556
2575
 
2557
2576
  this._data.realized = null;
2558
2577
  this._data.income = null;
@@ -2812,7 +2831,8 @@ module.exports = (() => {
2812
2831
  data.income = snapshot.income;
2813
2832
 
2814
2833
  data.summaryTotalCurrent = calculateSummaryTotal(item.currentSummary);
2815
- data.summaryTotalPrevious = calculateSummaryTotal(array.last(previousSummaries));
2834
+ data.summaryTotalPrevious = calculateSummaryTotal(getPreviousSummary(previousSummaries, 1));
2835
+ data.summaryTotalPrevious2 = calculateSummaryTotal(getPreviousSummary(previousSummaries, 2));
2816
2836
 
2817
2837
  if (snapshot.open.getIsZero()) {
2818
2838
  data.basisPrice = Decimal.ZERO;
@@ -2933,10 +2953,24 @@ module.exports = (() => {
2933
2953
  return returnRef;
2934
2954
  }
2935
2955
 
2956
+ function getPreviousSummary(previousSummaries, count) {
2957
+ const index = previousSummaries.length - count;
2958
+
2959
+ let summary;
2960
+
2961
+ if (!(index < 0)) {
2962
+ summary = previousSummaries[index];
2963
+ } else {
2964
+ summary = null;
2965
+ }
2966
+
2967
+ return summary;
2968
+ }
2969
+
2936
2970
  return PositionItem;
2937
2971
  })();
2938
2972
 
2939
- },{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/array":21,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],7:[function(require,module,exports){
2973
+ },{"./../data/InstrumentType":1,"@barchart/common-js/lang/Currency":15,"@barchart/common-js/lang/Decimal":17,"@barchart/common-js/lang/Disposable":18,"@barchart/common-js/lang/assert":22,"@barchart/common-js/lang/is":24,"@barchart/common-js/messaging/Event":26}],7:[function(require,module,exports){
2940
2974
  const assert = require('@barchart/common-js/lang/assert'),
2941
2975
  Currency = require('@barchart/common-js/lang/Currency'),
2942
2976
  is = require('@barchart/common-js/lang/is');
@@ -3482,14 +3516,31 @@ module.exports = function () {
3482
3516
  }
3483
3517
 
3484
3518
  /**
3485
- * Returns the parent node. If this is the root node, a null value is returned.
3519
+ * Gets the root node.
3486
3520
  *
3487
3521
  * @public
3488
- * @returns {Tree|null}
3522
+ * @returns {Tree}
3489
3523
  */
3490
3524
 
3491
3525
 
3492
3526
  _createClass(Tree, [{
3527
+ key: 'getRoot',
3528
+ value: function getRoot() {
3529
+ if (this.getIsRoot()) {
3530
+ return this;
3531
+ } else {
3532
+ return this._parent.getRoot();
3533
+ }
3534
+ }
3535
+
3536
+ /**
3537
+ * Returns the parent node. If this is the root node, a null value is returned.
3538
+ *
3539
+ * @public
3540
+ * @returns {Tree|null}
3541
+ */
3542
+
3543
+ }, {
3493
3544
  key: 'getParent',
3494
3545
  value: function getParent() {
3495
3546
  return this._parent;
@@ -3590,6 +3641,23 @@ module.exports = function () {
3590
3641
  }
3591
3642
  }
3592
3643
 
3644
+ /**
3645
+ * Removes the current node from the parent tree. Use on a root node
3646
+ * has no effect.
3647
+ *
3648
+ * @public
3649
+ */
3650
+
3651
+ }, {
3652
+ key: 'sever',
3653
+ value: function sever() {
3654
+ if (this.getIsRoot()) {
3655
+ return;
3656
+ }
3657
+
3658
+ this.getParent().removeChild(this);
3659
+ }
3660
+
3593
3661
  /**
3594
3662
  * Searches the children nodes for the first child node that matches the
3595
3663
  * predicate.
@@ -4984,6 +5052,20 @@ module.exports = function () {
4984
5052
  return this._big.gt(getBig(other));
4985
5053
  }
4986
5054
 
5055
+ /**
5056
+ * Returns true if the current instance is greater than or equal to the value.
5057
+ *
5058
+ * @public
5059
+ * @param {Decimal|Number|String} other - The value to compare.
5060
+ * @returns {Boolean}
5061
+ */
5062
+
5063
+ }, {
5064
+ key: 'getIsGreaterThanOrEqual',
5065
+ value: function getIsGreaterThanOrEqual(other) {
5066
+ return this._big.gte(getBig(other));
5067
+ }
5068
+
4987
5069
  /**
4988
5070
  * Returns true if the current instance is less than the value.
4989
5071
  *
@@ -4998,6 +5080,20 @@ module.exports = function () {
4998
5080
  return this._big.lt(getBig(other));
4999
5081
  }
5000
5082
 
5083
+ /**
5084
+ * Returns true if the current instance is less than or equal to the value.
5085
+ *
5086
+ * @public
5087
+ * @param {Decimal|Number|String} other - The value to compare.
5088
+ * @returns {Boolean}
5089
+ */
5090
+
5091
+ }, {
5092
+ key: 'getIsLessThanOrEqual',
5093
+ value: function getIsLessThanOrEqual(other) {
5094
+ return this._big.lte(getBig(other));
5095
+ }
5096
+
5001
5097
  /**
5002
5098
  * Returns true if the current instance is equal to the value.
5003
5099
  *
@@ -5197,9 +5293,9 @@ module.exports = function () {
5197
5293
  assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
5198
5294
  assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
5199
5295
 
5200
- if (a._big.gt(b)) {
5296
+ if (a._big.gt(b._big)) {
5201
5297
  return 1;
5202
- } else if (a._big.lt(b)) {
5298
+ } else if (a._big.lt(b._big)) {
5203
5299
  return -1;
5204
5300
  } else {
5205
5301
  return 0;
@@ -5660,12 +5756,10 @@ var _createClass = function () { function defineProperties(target, props) { for
5660
5756
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5661
5757
 
5662
5758
  var assert = require('./assert'),
5663
- is = require('./is'),
5664
5759
  memoize = require('./memoize');
5665
5760
 
5666
5761
  var Currency = require('./Currency'),
5667
- Decimal = require('./Decimal'),
5668
- Enum = require('./Enum');
5762
+ Decimal = require('./Decimal');
5669
5763
 
5670
5764
  module.exports = function () {
5671
5765
  'use strict';
@@ -5845,12 +5939,7 @@ module.exports = function () {
5845
5939
  assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
5846
5940
  assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
5847
5941
  assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
5848
-
5849
- for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
5850
- rates[_key - 3] = arguments[_key];
5851
- }
5852
-
5853
- assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
5942
+ //assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
5854
5943
 
5855
5944
  var converted = void 0;
5856
5945
 
@@ -5860,6 +5949,10 @@ module.exports = function () {
5860
5949
  var numerator = desiredCurrency;
5861
5950
  var denominator = currency;
5862
5951
 
5952
+ for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
5953
+ rates[_key - 3] = arguments[_key];
5954
+ }
5955
+
5863
5956
  var rate = rates.find(function (r) {
5864
5957
  return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
5865
5958
  });
@@ -5910,7 +6003,7 @@ module.exports = function () {
5910
6003
  return Rate;
5911
6004
  }();
5912
6005
 
5913
- },{"./Currency":15,"./Decimal":17,"./Enum":19,"./assert":22,"./is":24,"./memoize":25}],21:[function(require,module,exports){
6006
+ },{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
5914
6007
  'use strict';
5915
6008
 
5916
6009
  var assert = require('./assert'),
@@ -6287,6 +6380,26 @@ module.exports = function () {
6287
6380
  });
6288
6381
 
6289
6382
  return returnRef;
6383
+ },
6384
+
6385
+
6386
+ /**
6387
+ * Removes the first item from an array which matches a predicate.
6388
+ *
6389
+ * @static
6390
+ * @public
6391
+ * @param {Array} a
6392
+ * @param {Function} predicate
6393
+ */
6394
+ remove: function remove(a, predicate) {
6395
+ assert.argumentIsArray(a, 'a');
6396
+ assert.argumentIsRequired(predicate, 'predicate', Function);
6397
+
6398
+ var index = a.findIndex(predicate);
6399
+
6400
+ if (!(index < 0)) {
6401
+ a.splice(index, 1);
6402
+ }
6290
6403
  }
6291
6404
  };
6292
6405
  }();