@barchart/portfolio-client-js 1.3.13 → 1.3.14

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.
@@ -158,7 +158,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
158
158
 
159
159
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
160
160
 
161
- var assert = require('@barchart/common-js/lang/assert'),
161
+ var array = require('@barchart/common-js/lang/array'),
162
+ assert = require('@barchart/common-js/lang/assert'),
162
163
  Day = require('@barchart/common-js/lang/Day'),
163
164
  Disposable = require('@barchart/common-js/lang/Disposable'),
164
165
  Enum = require('@barchart/common-js/lang/Enum'),
@@ -1200,7 +1201,16 @@ module.exports = function () {
1200
1201
  return JSON.parse(s, PositionSummarySchema.CLIENT.schema.getReviver());
1201
1202
  });
1202
1203
 
1204
+ var created = array.differenceBy(saved, deleted, extractInstrumentId);
1205
+ var removed = array.differenceBy(deleted, saved, extractInstrumentId);
1206
+ var edited = array.intersectionBy(saved, deleted, extractInstrumentId);
1207
+
1203
1208
  var returnRef = {
1209
+ actions: {
1210
+ created: created,
1211
+ removed: removed,
1212
+ edited: edited
1213
+ },
1204
1214
  positions: {
1205
1215
  saved: saved,
1206
1216
  deleted: deleted
@@ -1234,6 +1244,10 @@ module.exports = function () {
1234
1244
  }
1235
1245
  }
1236
1246
 
1247
+ function extractInstrumentId(position) {
1248
+ return position.instrument.id;
1249
+ }
1250
+
1237
1251
  /**
1238
1252
  * The result of transaction create operation.
1239
1253
  *
@@ -1247,7 +1261,7 @@ module.exports = function () {
1247
1261
  return PortfolioGateway;
1248
1262
  }();
1249
1263
 
1250
- },{"./../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/ErrorInterceptor":20,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/lang/promise":42,"@barchart/portfolio-api-common/lib/data/PositionSummaryFrame":53,"@barchart/portfolio-api-common/lib/data/TransactionType":54,"@barchart/portfolio-api-common/lib/serialization/PortfolioSchema":56,"@barchart/portfolio-api-common/lib/serialization/PositionSchema":57,"@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema":58,"@barchart/portfolio-api-common/lib/serialization/TransactionSchema":59,"@barchart/portfolio-api-common/lib/serialization/reports/BrokerageReportAvailabilitySchema":60}],4:[function(require,module,exports){
1264
+ },{"./../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/ErrorInterceptor":20,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/array":36,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/lang/promise":42,"@barchart/portfolio-api-common/lib/data/PositionSummaryFrame":53,"@barchart/portfolio-api-common/lib/data/TransactionType":54,"@barchart/portfolio-api-common/lib/serialization/PortfolioSchema":56,"@barchart/portfolio-api-common/lib/serialization/PositionSchema":57,"@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema":58,"@barchart/portfolio-api-common/lib/serialization/TransactionSchema":59,"@barchart/portfolio-api-common/lib/serialization/reports/BrokerageReportAvailabilitySchema":60}],4:[function(require,module,exports){
1251
1265
  'use strict';
1252
1266
 
1253
1267
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -1685,7 +1699,7 @@ module.exports = function () {
1685
1699
  return {
1686
1700
  JwtGateway: JwtGateway,
1687
1701
  PortfolioGateway: PortfolioGateway,
1688
- version: '1.3.13'
1702
+ version: '1.3.14'
1689
1703
  };
1690
1704
  }();
1691
1705
 
@@ -1807,6 +1821,22 @@ module.exports = function () {
1807
1821
  return item.type === type;
1808
1822
  }, false, false) !== null;
1809
1823
  }
1824
+
1825
+ /**
1826
+ * Indicates if the tree of {@link FailureReasonItem} instances contains
1827
+ * at least one item that is considered to be severe.
1828
+ *
1829
+ * @public
1830
+ * @returns {Boolean}
1831
+ */
1832
+
1833
+ }, {
1834
+ key: 'getIsSevere',
1835
+ value: function getIsSevere() {
1836
+ return this._head.search(function (item) {
1837
+ return item.type.severe;
1838
+ }, false, false) !== null;
1839
+ }
1810
1840
  }, {
1811
1841
  key: 'toJSON',
1812
1842
  value: function toJSON() {
@@ -1837,6 +1867,8 @@ module.exports = function () {
1837
1867
  * Returns an HTTP status code that would be suitable for use with the
1838
1868
  * failure reason.
1839
1869
  *
1870
+ * @public
1871
+ * @static
1840
1872
  * @param {FailureReason} reason
1841
1873
  * @returns {Number}
1842
1874
  */
@@ -1861,7 +1893,9 @@ module.exports = function () {
1861
1893
 
1862
1894
  /**
1863
1895
  * Validates that a candidate conforms to a schema
1864
- *
1896
+ *
1897
+ * @public
1898
+ * @static
1865
1899
  * @param {Schema} schema
1866
1900
  * @param {Object} candidate
1867
1901
  */
@@ -1940,6 +1974,7 @@ module.exports = function () {
1940
1974
  /**
1941
1975
  * The {@link FailureType} of the item.
1942
1976
  *
1977
+ * @public
1943
1978
  * @returns {FailureType}
1944
1979
  */
1945
1980
 
@@ -2022,7 +2057,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
2022
2057
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2023
2058
 
2024
2059
  var assert = require('./../../lang/assert'),
2025
- Enum = require('./../../lang/Enum');
2060
+ Enum = require('./../../lang/Enum'),
2061
+ is = require('./../../lang/is');
2026
2062
 
2027
2063
  module.exports = function () {
2028
2064
  'use strict';
@@ -2032,21 +2068,29 @@ module.exports = function () {
2032
2068
  *
2033
2069
  * @public
2034
2070
  * @extends {Enum}
2035
- * @param {String} code - The enumeration code (and description)
2071
+ * @param {String} code - The enumeration code (and description).
2036
2072
  * @param {String} template - The template string for formatting human-readable messages.
2073
+ * @param {Boolean=} severe - Indicates if the failure is severe (default is true).
2037
2074
  */
2038
2075
 
2039
2076
  var FailureType = function (_Enum) {
2040
2077
  _inherits(FailureType, _Enum);
2041
2078
 
2042
- function FailureType(code, template) {
2079
+ function FailureType(code, template, severe) {
2043
2080
  _classCallCheck(this, FailureType);
2044
2081
 
2045
2082
  var _this = _possibleConstructorReturn(this, (FailureType.__proto__ || Object.getPrototypeOf(FailureType)).call(this, code, code));
2046
2083
 
2047
2084
  assert.argumentIsRequired(template, 'template', String);
2085
+ assert.argumentIsOptional(severe, 'severe', Boolean);
2048
2086
 
2049
2087
  _this._template = template;
2088
+
2089
+ if (is.boolean(severe)) {
2090
+ _this._severe = severe;
2091
+ } else {
2092
+ _this._severe = true;
2093
+ }
2050
2094
  return _this;
2051
2095
  }
2052
2096
 
@@ -2069,9 +2113,23 @@ module.exports = function () {
2069
2113
  return this._template;
2070
2114
  }
2071
2115
 
2116
+ /**
2117
+ * Indicates if the failure is serious.
2118
+ *
2119
+ * @public
2120
+ * @return {Boolean}
2121
+ */
2122
+
2123
+ }, {
2124
+ key: 'severe',
2125
+ get: function get() {
2126
+ return this._severe;
2127
+ }
2128
+
2072
2129
  /**
2073
2130
  * One or more data points is missing.
2074
2131
  *
2132
+ * @public
2075
2133
  * @static
2076
2134
  * @returns {FailureType}
2077
2135
  */
@@ -2084,6 +2142,8 @@ module.exports = function () {
2084
2142
  * Returns an HTTP status code that would be suitable for use with the
2085
2143
  * failure type.
2086
2144
  *
2145
+ * @public
2146
+ * @static
2087
2147
  * @param {FailureType} type
2088
2148
  * @returns {Number}
2089
2149
  */
@@ -2111,6 +2171,7 @@ module.exports = function () {
2111
2171
  /**
2112
2172
  * A data point is missing.
2113
2173
  *
2174
+ * @public
2114
2175
  * @static
2115
2176
  * @returns {FailureType}
2116
2177
  */
@@ -2124,6 +2185,7 @@ module.exports = function () {
2124
2185
  /**
2125
2186
  * A data point is malformed.
2126
2187
  *
2188
+ * @public
2127
2189
  * @static
2128
2190
  * @returns {FailureType}
2129
2191
  */
@@ -2137,6 +2199,7 @@ module.exports = function () {
2137
2199
  /**
2138
2200
  * User identity could not be determined.
2139
2201
  *
2202
+ * @public
2140
2203
  * @static
2141
2204
  * @returns {FailureType}
2142
2205
  */
@@ -2150,6 +2213,7 @@ module.exports = function () {
2150
2213
  /**
2151
2214
  * User authorization failed.
2152
2215
  *
2216
+ * @public
2153
2217
  * @static
2154
2218
  * @returns {FailureType}
2155
2219
  */
@@ -2163,6 +2227,7 @@ module.exports = function () {
2163
2227
  /**
2164
2228
  * The request data cannot be parsed or interpreted.
2165
2229
  *
2230
+ * @public
2166
2231
  * @static
2167
2232
  * @returns {FailureType}
2168
2233
  */
@@ -2176,6 +2241,7 @@ module.exports = function () {
2176
2241
  /**
2177
2242
  * The request failed for unspecified reasons.
2178
2243
  *
2244
+ * @public
2179
2245
  * @static
2180
2246
  * @returns {FailureType}
2181
2247
  */
@@ -2189,6 +2255,7 @@ module.exports = function () {
2189
2255
  /**
2190
2256
  * The request failed for unspecified reasons.
2191
2257
  *
2258
+ * @public
2192
2259
  * @static
2193
2260
  * @returns {FailureType}
2194
2261
  */
@@ -2215,7 +2282,7 @@ module.exports = function () {
2215
2282
  return FailureType;
2216
2283
  }();
2217
2284
 
2218
- },{"./../../lang/Enum":32,"./../../lang/assert":37}],9:[function(require,module,exports){
2285
+ },{"./../../lang/Enum":32,"./../../lang/assert":37,"./../../lang/is":40}],9:[function(require,module,exports){
2219
2286
  'use strict';
2220
2287
 
2221
2288
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -2256,7 +2323,7 @@ module.exports = function () {
2256
2323
  * @static
2257
2324
  * @param {Endpoint} endpoint
2258
2325
  * @param {*=} payload
2259
- * @returns {Promise.<Object>}
2326
+ * @returns {Promise<Object>}
2260
2327
  */
2261
2328
 
2262
2329
 
@@ -3388,7 +3455,7 @@ module.exports = function () {
3388
3455
  *
3389
3456
  * @callback Parameter~parameterValueCallback
3390
3457
  * @param {Object} payload
3391
- * @returns {Promise.<String>}
3458
+ * @returns {Promise<String>}
3392
3459
  */
3393
3460
 
3394
3461
  return Parameter;
@@ -3934,7 +4001,7 @@ module.exports = function () {
3934
4001
  * @public
3935
4002
  * @param {Object} error
3936
4003
  * @param {Endpoint} endpoint - The endpoint which is originating the request.
3937
- * @returns {Promise.<TResult>}
4004
+ * @returns {Promise<TResult>}
3938
4005
  */
3939
4006
 
3940
4007
 
@@ -4091,7 +4158,7 @@ module.exports = function () {
4091
4158
  * @public
4092
4159
  * @param {Object} request
4093
4160
  * @param {Endpoint} endpoint - The endpoint which is originating the request.
4094
- * @returns {Promise.<TResult>}
4161
+ * @returns {Promise<TResult>}
4095
4162
  */
4096
4163
 
4097
4164
 
@@ -4242,7 +4309,7 @@ module.exports = function () {
4242
4309
  * @public
4243
4310
  * @param {Object} request
4244
4311
  * @param {Endpoint} endpoint - The endpoint which is originating the request.
4245
- * @returns {Promise.<TResult>}
4312
+ * @returns {Promise<TResult>}
4246
4313
  */
4247
4314
 
4248
4315
 
@@ -4473,7 +4540,7 @@ module.exports = function () {
4473
4540
  *
4474
4541
  * @public
4475
4542
  * @param {*} value - The value of the node.
4476
- * @param {Tree} parent - The parent node. If not supplied, this will be the root node.
4543
+ * @param {Tree=} parent - The parent node. If not supplied, this will be the root node.
4477
4544
  */
4478
4545
 
4479
4546
  var Tree = function () {
@@ -5029,6 +5096,27 @@ module.exports = function () {
5029
5096
  return a.localeCompare(b);
5030
5097
  },
5031
5098
 
5099
+ /**
5100
+ * Compares two boolean values (in ascending order -- false first, true second).
5101
+ *
5102
+ * @static
5103
+ * @param {Boolean} a
5104
+ * @param {Boolean} b
5105
+ * @returns {Number}
5106
+ */
5107
+ compareBooleans: function compareBooleans(a, b) {
5108
+ assert.argumentIsRequired(a, 'a', Boolean);
5109
+ assert.argumentIsRequired(b, 'b', Boolean);
5110
+
5111
+ if (a === b) {
5112
+ return 0;
5113
+ } else if (a) {
5114
+ return 1;
5115
+ } else {
5116
+ return -1;
5117
+ }
5118
+ },
5119
+
5032
5120
  /**
5033
5121
  * Compares two objects, always returning zero.
5034
5122
  *
@@ -5510,6 +5598,32 @@ module.exports = function () {
5510
5598
  return this.addYears(years, true);
5511
5599
  }
5512
5600
 
5601
+ /**
5602
+ * Returns a new {@link Day} instance for the start of the month referenced by the current instance.
5603
+ *
5604
+ * @public
5605
+ * @returns {Day}
5606
+ */
5607
+
5608
+ }, {
5609
+ key: 'getStartOfMonth',
5610
+ value: function getStartOfMonth() {
5611
+ return new Day(this.year, this.month, 1);
5612
+ }
5613
+
5614
+ /**
5615
+ * Returns a new instance for the {@link Day} end of the month referenced by the current instance.
5616
+ *
5617
+ * @public
5618
+ * @returns {Day}
5619
+ */
5620
+
5621
+ }, {
5622
+ key: 'getEndOfMonth',
5623
+ value: function getEndOfMonth() {
5624
+ return new Day(this.year, this.month, Day.getDaysInMonth(this.year, this.month));
5625
+ }
5626
+
5513
5627
  /**
5514
5628
  * Indicates if another {@link Day} occurs before the current instance.
5515
5629
  *
@@ -5671,7 +5785,7 @@ module.exports = function () {
5671
5785
  }
5672
5786
 
5673
5787
  /**
5674
- * Converts a string (which matches the output of {@link Day#format} into
5788
+ * Converts a string (which matches the output of {@link Day#format}) into
5675
5789
  * a {@link Day} instance.
5676
5790
  *
5677
5791
  * @public
@@ -5942,6 +6056,24 @@ module.exports = function () {
5942
6056
  return new Decimal(this._big.div(getBig(other)));
5943
6057
  }
5944
6058
 
6059
+ /**
6060
+ * Returns a new {@link Decimal} instance with a value that results
6061
+ * from raising the current instance to the power of the exponent
6062
+ * provided.
6063
+ *
6064
+ * @public
6065
+ * @param {Decimal|Number|String} exponent
6066
+ * @returns {Decimal}
6067
+ */
6068
+
6069
+ }, {
6070
+ key: 'raise',
6071
+ value: function raise(exponent) {
6072
+ assert.argumentIsRequired(exponent, 'exponent', Number);
6073
+
6074
+ return new Decimal(this._big.pow(exponent));
6075
+ }
6076
+
5945
6077
  /**
5946
6078
  * Returns a new {@link Decimal} with a value resulting from a rounding
5947
6079
  * operation on the current value.
@@ -6106,6 +6238,28 @@ module.exports = function () {
6106
6238
  return this._big.eq(getBig(other));
6107
6239
  }
6108
6240
 
6241
+ /**
6242
+ * Returns true is close to another value.
6243
+ *
6244
+ * @public
6245
+ * @param {Decimal|Number|String} other - The value to compare.
6246
+ * @param {Number} places - The significant digits.
6247
+ * @returns {Boolean}
6248
+ */
6249
+
6250
+ }, {
6251
+ key: 'getIsApproximate',
6252
+ value: function getIsApproximate(other, places) {
6253
+ if (places === 0) {
6254
+ return this.getIsEqual(other);
6255
+ }
6256
+
6257
+ var difference = this.subtract(other).absolute();
6258
+ var tolerance = Decimal.ONE.divide(new Decimal(10).raise(places));
6259
+
6260
+ return difference.getIsLessThan(tolerance);
6261
+ }
6262
+
6109
6263
  /**
6110
6264
  * Returns true if the current instance is an integer (i.e. has no decimal
6111
6265
  * component).
@@ -7478,8 +7632,10 @@ module.exports = function () {
7478
7632
  var returnRef = [];
7479
7633
 
7480
7634
  a.forEach(function (candidate) {
7635
+ var candidateKey = keySelector(candidate);
7636
+
7481
7637
  var exclude = b.some(function (comparison) {
7482
- return keySelector(candidate) === keySelector(comparison);
7638
+ return candidateKey === keySelector(comparison);
7483
7639
  });
7484
7640
 
7485
7641
  if (!exclude) {
@@ -7554,8 +7710,10 @@ module.exports = function () {
7554
7710
  var returnRef = a.slice();
7555
7711
 
7556
7712
  b.forEach(function (candidate) {
7713
+ var candidateKey = keySelector(candidate);
7714
+
7557
7715
  var exclude = returnRef.some(function (comparison) {
7558
- return keySelector(candidate) === keySelector(comparison);
7716
+ return candidateKey === keySelector(comparison);
7559
7717
  });
7560
7718
 
7561
7719
  if (!exclude) {
@@ -7598,8 +7756,10 @@ module.exports = function () {
7598
7756
  var returnRef = [];
7599
7757
 
7600
7758
  a.forEach(function (candidate) {
7759
+ var candidateKey = keySelector(candidate);
7760
+
7601
7761
  var include = b.some(function (comparison) {
7602
- return keySelector(candidate) === comparison;
7762
+ return candidateKey === keySelector(comparison);
7603
7763
  });
7604
7764
 
7605
7765
  if (include) {
@@ -7632,8 +7792,62 @@ module.exports = function () {
7632
7792
  }
7633
7793
 
7634
7794
  return found;
7795
+ },
7796
+
7797
+
7798
+ /**
7799
+ * Inserts an item into an array using a binary search is used to determine the
7800
+ * proper point for insertion and returns the same array.
7801
+ *
7802
+ * @static
7803
+ * @public
7804
+ * @param {Array} a
7805
+ * @param {*} item
7806
+ * @param {Function} comparator
7807
+ * @returns {Array}
7808
+ */
7809
+ insert: function insert(a, item, comparator) {
7810
+ assert.argumentIsArray(a, 'a');
7811
+ assert.argumentIsRequired(comparator, 'comparator', Function);
7812
+
7813
+ if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
7814
+ a.push(item);
7815
+ } else if (comparator(item, a[0]) < 0) {
7816
+ a.unshift(item);
7817
+ } else {
7818
+ a.splice(binarySearch(a, item, comparator, 0, a.length - 1), 0, item);
7819
+ }
7820
+
7821
+ return a;
7635
7822
  }
7636
7823
  };
7824
+
7825
+ function binarySearch(array, item, comparator, start, end) {
7826
+ var size = end - start;
7827
+
7828
+ var midpointIndex = start + Math.floor(size / 2);
7829
+ var midpointItem = array[midpointIndex];
7830
+
7831
+ var comparison = comparator(item, midpointItem) > 0;
7832
+
7833
+ if (size < 2) {
7834
+ if (comparison > 0) {
7835
+ var finalIndex = array.length - 1;
7836
+
7837
+ if (end === finalIndex && comparator(item, array[finalIndex]) > 0) {
7838
+ return end + 1;
7839
+ } else {
7840
+ return end;
7841
+ }
7842
+ } else {
7843
+ return start;
7844
+ }
7845
+ } else if (comparison > 0) {
7846
+ return binarySearch(array, item, comparator, midpointIndex, end);
7847
+ } else {
7848
+ return binarySearch(array, item, comparator, start, midpointIndex);
7849
+ }
7850
+ }
7637
7851
  }();
7638
7852
 
7639
7853
  },{"./assert":37,"./is":40}],37:[function(require,module,exports){
@@ -7849,9 +8063,10 @@ module.exports = function () {
7849
8063
  /**
7850
8064
  * Checks to see if an attribute exists on the target object.
7851
8065
  *
8066
+ * @public
7852
8067
  * @static
7853
8068
  * @param {Object} target - The object to check for existence of the property.
7854
- * @param {String|Array.<String>} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
8069
+ * @param {String|String[]} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
7855
8070
  * @param {String=} separator - The separator (defaults to a period character).
7856
8071
  * @returns {boolean}
7857
8072
  */
@@ -7875,9 +8090,10 @@ module.exports = function () {
7875
8090
  * Returns a value from the target object. If the property doesn't exist; undefined
7876
8091
  * is returned.
7877
8092
  *
8093
+ * @public
7878
8094
  * @static
7879
8095
  * @param {Object} target - The object to read from.
7880
- * @param {String|Array.<String>} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
8096
+ * @param {String|String[]} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
7881
8097
  * @param {String=} separator - The separator (defaults to a period character).
7882
8098
  * @returns {*}
7883
8099
  */
@@ -7910,9 +8126,10 @@ module.exports = function () {
7910
8126
  /**
7911
8127
  * Writes a value to the target object.
7912
8128
  *
8129
+ * @public
7913
8130
  * @static
7914
8131
  * @param {Object} target - The object to write to.
7915
- * @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
8132
+ * @param {String|String[]} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
7916
8133
  * @param {*} value - The value to assign.
7917
8134
  * @param {String=} separator - The separator (defaults to a period character).
7918
8135
  */
@@ -7937,9 +8154,10 @@ module.exports = function () {
7937
8154
  /**
7938
8155
  * Erases a property from the target object.
7939
8156
  *
8157
+ * @public
7940
8158
  * @static
7941
8159
  * @param {Object} target - The object to erase a property from.
7942
- * @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
8160
+ * @param {String|String} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
7943
8161
  * @param {String=} separator - The separator (defaults to a period character).
7944
8162
  */
7945
8163
  erase: function erase(target, propertyNames, separator) {
@@ -8089,7 +8307,7 @@ module.exports = function () {
8089
8307
  * @static
8090
8308
  * @public
8091
8309
  * @param {*} candidate
8092
- * @returns {*|boolean}
8310
+ * @returns {boolean}
8093
8311
  */
8094
8312
  negative: function negative(candidate) {
8095
8313
  return this.number(candidate) && candidate < 0;
@@ -8440,10 +8658,12 @@ module.exports = function () {
8440
8658
  * a mapping function, which can return a promise. Then, this function returns a single promise
8441
8659
  * which is the result of each mapped promise.
8442
8660
  *
8661
+ * @public
8662
+ * @static
8443
8663
  * @param {Array} items - The items to map
8444
8664
  * @param {Function} mapper - The mapping function (e.g. given an item, return a promise).
8445
8665
  * @param {Number} concurrency - The maximum number of promises that are allowed to run at once.
8446
- * @returns {Promise.<Array>}
8666
+ * @returns {Promise<Array>}
8447
8667
  */
8448
8668
  map: function map(items, mapper, concurrency) {
8449
8669
  var _this2 = this;
@@ -8530,7 +8750,7 @@ module.exports = function () {
8530
8750
  * @public
8531
8751
  * @param {Function[]} functions - An array of functions, each expecting a single argument.
8532
8752
  * @param input - The argument to pass the first function.
8533
- * @returns {Promise.<TResult>}
8753
+ * @returns {Promise<TResult>}
8534
8754
  */
8535
8755
  pipeline: function pipeline(functions, input) {
8536
8756
  return Promise.resolve().then(function () {
@@ -8552,8 +8772,8 @@ module.exports = function () {
8552
8772
  * is caught and the resulting promise is rejected (instead of letting the
8553
8773
  * error bubble up to the top-level handler).
8554
8774
  *
8555
- * @static
8556
8775
  * @public
8776
+ * @static
8557
8777
  * @param {Function} executor - A function which has two callback parameters. The first is used to resolve the promise, the second rejects it.
8558
8778
  * @returns {Promise}
8559
8779
  */
@@ -8956,6 +9176,20 @@ module.exports = function () {
8956
9176
  return dataTypeObject;
8957
9177
  }
8958
9178
 
9179
+ /**
9180
+ * References an array.
9181
+ *
9182
+ * @public
9183
+ * @static
9184
+ * @returns {DataType}
9185
+ */
9186
+
9187
+ }, {
9188
+ key: 'ARRAY',
9189
+ get: function get() {
9190
+ return dataTypeArray;
9191
+ }
9192
+
8959
9193
  /**
8960
9194
  * References a {@link Decimal} instance.
8961
9195
  *
@@ -9024,6 +9258,7 @@ module.exports = function () {
9024
9258
  var dataTypeNumber = new DataType('Number', null, null, is.number);
9025
9259
  var dataTypeBoolean = new DataType('Boolean', null, null, is.boolean);
9026
9260
  var dataTypeObject = new DataType('Object', null, null, is.object);
9261
+ var dataTypeArray = new DataType('Array', null, null, is.array);
9027
9262
 
9028
9263
  var dataTypeDecimal = new DataType('Decimal', null, function (x) {
9029
9264
  return Decimal.parse(x);
@@ -9046,7 +9281,7 @@ module.exports = function () {
9046
9281
  return x instanceof AdHoc;
9047
9282
  }, getBuilder(buildAdHoc));
9048
9283
 
9049
- var dataTypes = [dataTypeString, dataTypeNumber, dataTypeBoolean, dataTypeObject, dataTypeDecimal, dataTypeDay, dataTypeTimestamp, dataTypeAdHoc];
9284
+ var dataTypes = [dataTypeString, dataTypeNumber, dataTypeBoolean, dataTypeObject, dataTypeArray, dataTypeDecimal, dataTypeDay, dataTypeTimestamp, dataTypeAdHoc];
9050
9285
 
9051
9286
  function getBuilder(builder) {
9052
9287
  return function (data) {
@@ -9916,11 +10151,11 @@ module.exports = function () {
9916
10151
  *
9917
10152
  * @public
9918
10153
  * @param {Function} actionToBackoff - The action to attempt. If it fails -- because an error is thrown, a promise is rejected, or the function returns a falsey value -- the action will be invoked again.
9919
- * @param {number=} millisecondDelay - The amount of time to wait to execute the action. Subsequent failures are multiply this value by 2 ^ [number of failures]. So, a 1000 millisecond backoff would schedule attempts using the following delays: 0, 1000, 2000, 4000, 8000, etc. If not specified, the first attemopt will execute immediately, then a value of 1000 will be used.
10154
+ * @param {number=} millisecondDelay - The amount of time to wait to execute the action. Subsequent failures are multiply this value by 2 ^ [number of failures]. So, a 1000 millisecond backoff would schedule attempts using the following delays: 0, 1000, 2000, 4000, 8000, etc. If not specified, the first attempt will execute immediately, then a value of 1000 will be used.
9920
10155
  * @param {string=} actionDescription - Description of the action to attempt, used for logging purposes.
9921
10156
  * @param {number=} maximumAttempts - The number of attempts to before giving up.
9922
10157
  * @param {Function=} failureCallback - If provided, will be invoked if a function is considered to be failing.
9923
- * @param {Object=} failureValue - If provided, will consider the result to have failed, if this value is returned (a deep equality check is used). If not provided, a "falsey" value will trigger a retry.
10158
+ * @param {Object=} failureValue - If provided, will consider the result to have failed, if this value is returned (a deep equality check is used). If not provided, an undefined value will trigger a retry.
9924
10159
  * @returns {Promise}
9925
10160
  */
9926
10161
 
@@ -9940,59 +10175,61 @@ module.exports = function () {
9940
10175
  throw new Error('The Scheduler has been disposed.');
9941
10176
  }
9942
10177
 
9943
- var scheduleBackoff = function scheduleBackoff(failureCount, e) {
9944
- if (failureCount > 0 && is.fn(failureCallback)) {
9945
- failureCallback(failureCount);
9946
- }
10178
+ var processAction = function processAction(attempts) {
10179
+ return Promise.resolve().then(function () {
10180
+ var delay = void 0;
9947
10181
 
9948
- if (maximumAttempts > 0 && failureCount > maximumAttempts) {
9949
- var message = 'Maximum failures reached for ' + actionDescription;
9950
-
9951
- var rejection = void 0;
10182
+ if (attempts === 0) {
10183
+ delay = 0;
10184
+ } else {
10185
+ delay = (millisecondDelay || 1000) * Math.pow(2, attempts - 1);
10186
+ }
9952
10187
 
9953
- if (e) {
9954
- e.backoff = message;
10188
+ return _this4.schedule(actionToBackoff, delay, 'Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ]');
10189
+ }).then(function (result) {
10190
+ var resultPromise = void 0;
9955
10191
 
9956
- rejection = e;
10192
+ if (!is.undefined(failureValue) && object.equals(result, failureValue)) {
10193
+ resultPromise = Promise.reject('Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ] failed due to invalid result');
9957
10194
  } else {
9958
- rejection = message;
10195
+ resultPromise = Promise.resolve(result);
9959
10196
  }
9960
10197
 
9961
- return Promise.reject(rejection);
9962
- }
10198
+ return resultPromise;
10199
+ }).catch(function (e) {
10200
+ if (is.fn(failureCallback)) {
10201
+ failureCallback(attempts);
10202
+ }
9963
10203
 
9964
- var backoffDelay = void 0;
10204
+ return Promise.reject(e);
10205
+ });
10206
+ };
9965
10207
 
9966
- if (failureCount === 0) {
9967
- backoffDelay = millisecondDelay || 0;
9968
- } else {
9969
- backoffDelay = (millisecondDelay || 1000) * Math.pow(2, failureCount);
9970
- }
10208
+ var attempts = 0;
9971
10209
 
9972
- var successPredicate = void 0;
10210
+ var processActionRecursive = function processActionRecursive() {
10211
+ return processAction(attempts++).catch(function (e) {
10212
+ if (maximumAttempts > 0 && attempts === maximumAttempts) {
10213
+ var message = 'Maximum failures reached for ' + (actionDescription || 'unnamed action');
9973
10214
 
9974
- if (is.undefined(failureValue)) {
9975
- successPredicate = function successPredicate(value) {
9976
- return value;
9977
- };
9978
- } else {
9979
- successPredicate = function successPredicate(value) {
9980
- return !object.equals(value, failureValue);
9981
- };
9982
- }
10215
+ var rejectPromise = void 0;
10216
+
10217
+ if (is.object(e)) {
10218
+ e.backoff = message;
10219
+
10220
+ rejectPromise = Promise.reject(e);
10221
+ } else {
10222
+ rejectPromise = Promise.reject(message);
10223
+ }
9983
10224
 
9984
- return _this4.schedule(actionToBackoff, backoffDelay, (actionDescription || 'unspecified') + ', attempt ' + (failureCount + 1)).then(function (result) {
9985
- if (successPredicate(result)) {
9986
- return result;
10225
+ return rejectPromise;
9987
10226
  } else {
9988
- return scheduleBackoff(++failureCount);
10227
+ return processActionRecursive();
9989
10228
  }
9990
- }).catch(function (e) {
9991
- return scheduleBackoff(++failureCount, e);
9992
10229
  });
9993
10230
  };
9994
10231
 
9995
- return scheduleBackoff(0);
10232
+ return processActionRecursive();
9996
10233
  });
9997
10234
  }
9998
10235
  }, {
@@ -10053,9 +10290,10 @@ module.exports = (() => {
10053
10290
  *
10054
10291
  * @public
10055
10292
  * @extends {Enum}
10293
+ * @param {String} code
10056
10294
  * @param {String} description
10057
10295
  * @param {String} alternateDescription
10058
- * @param {String} code
10296
+ * @param {Boolean} canExistEmpty
10059
10297
  * @param {Boolean} canReinvest
10060
10298
  * @param {Boolean} canShort
10061
10299
  * @param {Boolean} canSwitchDirection
@@ -10067,10 +10305,11 @@ module.exports = (() => {
10067
10305
  * @param {Function} generator
10068
10306
  */
10069
10307
  class InstrumentType extends Enum {
10070
- constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
10308
+ constructor(code, description, alternateDescription, canExistEmpty, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
10071
10309
  super(code, description);
10072
10310
 
10073
10311
  assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
10312
+ assert.argumentIsRequired(canExistEmpty, 'canExistEmpty', Boolean);
10074
10313
  assert.argumentIsRequired(canReinvest, 'canReinvest', Boolean);
10075
10314
  assert.argumentIsRequired(canShort, 'canShort', Boolean);
10076
10315
  assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
@@ -10082,6 +10321,8 @@ module.exports = (() => {
10082
10321
  assert.argumentIsRequired(generator, 'generator', Function);
10083
10322
 
10084
10323
  this._alternateDescription = alternateDescription;
10324
+
10325
+ this._canExistEmpty = canExistEmpty;
10085
10326
  this._canReinvest = canReinvest;
10086
10327
  this._canShort = canShort;
10087
10328
  this._canSwitchDirection = canSwitchDirection;
@@ -10104,6 +10345,16 @@ module.exports = (() => {
10104
10345
  return this._alternateDescription;
10105
10346
  }
10106
10347
 
10348
+ /**
10349
+ * Indicates if the position can exist without any associated transactions.
10350
+ *
10351
+ * @public
10352
+ * @returns {Boolean}
10353
+ */
10354
+ get canExistEmpty() {
10355
+ return this._canExistEmpty;
10356
+ }
10357
+
10107
10358
  /**
10108
10359
  * Indicates if the instrument type allows automatic reinvestment.
10109
10360
  *
@@ -10284,10 +10535,10 @@ module.exports = (() => {
10284
10535
  }
10285
10536
  }
10286
10537
 
10287
- const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10288
- const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10289
- const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10290
- const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10538
+ const cash = new InstrumentType('CASH', 'cash', 'Cash', true, false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10539
+ const equity = new InstrumentType('EQUITY', 'equity', 'Equities', false, true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10540
+ const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', false, true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10541
+ const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10291
10542
 
10292
10543
  const map = { };
10293
10544
 
@@ -10496,7 +10747,7 @@ module.exports = (() => {
10496
10747
  *
10497
10748
  * @public
10498
10749
  * @param {Number} periods
10499
- * @returns {Array.<PositionSummaryRange>}
10750
+ * @returns {PositionSummaryRange[]}
10500
10751
  */
10501
10752
  getRecentRanges(periods) {
10502
10753
  const startDate = this.getStartDate(periods);
@@ -10509,8 +10760,8 @@ module.exports = (() => {
10509
10760
  * Returns the ranges for the set of {@link Transaction} objects.
10510
10761
  *
10511
10762
  * @public
10512
- * @param {Array.<Transaction>} transactions
10513
- * @returns {Array.<PositionSummaryRange>}
10763
+ * @param {Transaction[]} transactions
10764
+ * @returns {PositionSummaryRange[]}
10514
10765
  */
10515
10766
  getRanges(transactions) {
10516
10767
  assert.argumentIsArray(transactions, 'transactions');
@@ -10523,7 +10774,7 @@ module.exports = (() => {
10523
10774
  *
10524
10775
  * @public
10525
10776
  * @param {Day} date
10526
- * @return {Array.<PositionSummaryRange>}
10777
+ * @return {PositionSummaryRange[]}
10527
10778
  */
10528
10779
  getRangesFromDate(date) {
10529
10780
  assert.argumentIsRequired(date, 'date', Day, 'Day');
@@ -10612,8 +10863,8 @@ module.exports = (() => {
10612
10863
  }
10613
10864
 
10614
10865
  const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
10615
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10616
- const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10866
+ const quarterly = new PositionSummaryFrame('QUARTERLY', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10867
+ const monthly = new PositionSummaryFrame('MONTHLY', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10617
10868
  const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
10618
10869
 
10619
10870
  /**
@@ -10673,7 +10924,36 @@ module.exports = (() => {
10673
10924
  }
10674
10925
 
10675
10926
  function getMonthlyRanges(transactions) {
10676
- return [ ];
10927
+ const ranges = [ ];
10928
+
10929
+ if (transactions.length !== 0) {
10930
+ const today = Day.getToday();
10931
+
10932
+ const first = array.first(transactions);
10933
+ const last = array.last(transactions);
10934
+
10935
+ const firstDate = first.date;
10936
+
10937
+ let lastDate;
10938
+
10939
+ if (last.snapshot.open.getIsZero()) {
10940
+ lastDate = last.date;
10941
+ } else {
10942
+ lastDate = today;
10943
+ }
10944
+
10945
+ if (today.month === lastDate.month && today.year === lastDate.year) {
10946
+ lastDate = lastDate.subtractMonths(1);
10947
+ }
10948
+
10949
+ lastDate = lastDate.getEndOfMonth();
10950
+
10951
+ for (let end = firstDate.getEndOfMonth(); !end.getIsAfter(lastDate); end = end.addMonths(1).getEndOfMonth()) {
10952
+ ranges.push(getRange(end.subtractMonths(1).getEndOfMonth(), end));
10953
+ }
10954
+ }
10955
+
10956
+ return ranges;
10677
10957
  }
10678
10958
 
10679
10959
  function getYearToDateRanges(transactions) {
@@ -10710,7 +10990,11 @@ module.exports = (() => {
10710
10990
  }
10711
10991
 
10712
10992
  function getMonthlyStartDate(periods, date) {
10713
- return null;
10993
+ const today = date || Day.getToday();
10994
+
10995
+ return today
10996
+ .subtractMonths(periods)
10997
+ .subtractDays(today.day);
10714
10998
  }
10715
10999
 
10716
11000
  function getYearToDateStartDate(periods, date) {
@@ -10718,7 +11002,7 @@ module.exports = (() => {
10718
11002
  }
10719
11003
 
10720
11004
  function getYearlyRangeDescription(start, end) {
10721
- return `Year ended ${end.year.toString()}`;
11005
+ return `Year ended ${end.format()}`;
10722
11006
  }
10723
11007
 
10724
11008
  function getQuarterlyRangeDescription(start, end) {
@@ -10726,7 +11010,7 @@ module.exports = (() => {
10726
11010
  }
10727
11011
 
10728
11012
  function getMonthlyRangeDescription(start, end) {
10729
- return '';
11013
+ return `Month ended ${end.format()}`;
10730
11014
  }
10731
11015
 
10732
11016
  function getYearToDateRangeDescription(start, end) {
@@ -10771,7 +11055,7 @@ module.exports = (() => {
10771
11055
  * @param {Boolean} corporateAction
10772
11056
  * @param {Boolean} initial
10773
11057
  * @param {Boolean} significant
10774
- * @param {Boolean} eod
11058
+ * @param {Boolean} system
10775
11059
  */
10776
11060
  class TransactionType extends Enum {
10777
11061
  constructor(code, description, display, sequence, purchase, sale, income, opening, closing, fee, corporateAction, initial, significant) {
@@ -11101,6 +11385,17 @@ module.exports = (() => {
11101
11385
  static get DEBIT() {
11102
11386
  return debit;
11103
11387
  }
11388
+
11389
+ /**
11390
+ * A system-generated transaction, indicating the security has stopped active trading.
11391
+ *
11392
+ * @public
11393
+ * @static
11394
+ * @returns {TransactionType}
11395
+ */
11396
+ static get DELIST() {
11397
+ return delist;
11398
+ }
11104
11399
 
11105
11400
  /**
11106
11401
  * A system-generated deposit, arising from another transaction.
@@ -11150,6 +11445,7 @@ module.exports = (() => {
11150
11445
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
11151
11446
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
11152
11447
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', 0, false, false, false, false, true, false, false, false, false);
11448
+ const delist = new TransactionType('DL', 'Delist', 'Delist', 1, false, false, false, false, false, false, true, false, false);
11153
11449
 
11154
11450
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
11155
11451
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -11785,6 +12081,10 @@ module.exports = (() => {
11785
12081
  static get VALUATION() {
11786
12082
  return valuation;
11787
12083
  }
12084
+
12085
+ static get DELIST() {
12086
+ return delist;
12087
+ }
11788
12088
 
11789
12089
  static get INCOME() {
11790
12090
  return income;
@@ -11989,12 +12289,23 @@ module.exports = (() => {
11989
12289
  .withField('sequence', DataType.NUMBER, true)
11990
12290
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
11991
12291
  .withField('date', DataType.DAY)
11992
- .withField('value', DataType.DECIMAL)
12292
+ .withField('rate', DataType.DECIMAL, true)
12293
+ .withField('value', DataType.DECIMAL, true)
11993
12294
  .withField('force', DataType.BOOLEAN, true)
11994
12295
  .schema
11995
12296
  );
11996
-
11997
- const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
12297
+
12298
+ const delist = new TransactionSchema(SchemaBuilder.withName(TransactionType.DELIST.code)
12299
+ .withField('portfolio', DataType.STRING)
12300
+ .withField('position', DataType.STRING)
12301
+ .withField('sequence', DataType.NUMBER, true)
12302
+ .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
12303
+ .withField('date', DataType.DAY)
12304
+ .withField('force', DataType.BOOLEAN, true)
12305
+ .schema
12306
+ );
12307
+
12308
+ const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
11998
12309
  .withField('portfolio', DataType.STRING)
11999
12310
  .withField('position', DataType.STRING)
12000
12311
  .withField('sequence', DataType.NUMBER, true)
@@ -12020,6 +12331,7 @@ module.exports = (() => {
12020
12331
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
12021
12332
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
12022
12333
  addSchemaToMap(TransactionType.VALUATION, valuation);
12334
+ addSchemaToMap(TransactionType.DELIST, delist);
12023
12335
  addSchemaToMap(TransactionType.INCOME, income);
12024
12336
 
12025
12337
  return TransactionSchema;
@@ -12152,7 +12464,7 @@ module.exports = function () {
12152
12464
  * containing the current instance
12153
12465
  *
12154
12466
  * @public
12155
- * @returns {Promise.<JwtGateway>}
12467
+ * @returns {Promise<JwtGateway>}
12156
12468
  */
12157
12469
 
12158
12470
 
@@ -12182,7 +12494,7 @@ module.exports = function () {
12182
12494
  * Retrieves a JWT token from the remote server.
12183
12495
  *
12184
12496
  * @public
12185
- * @returns {Promise.<String>}
12497
+ * @returns {Promise<String>}
12186
12498
  */
12187
12499
 
12188
12500
  }, {
@@ -12222,7 +12534,7 @@ module.exports = function () {
12222
12534
  var refreshToken = function refreshToken() {
12223
12535
  var refreshPromise = scheduler.backoff(function () {
12224
12536
  return _this4.readToken();
12225
- }, 100, 'Read JWT token', 3).then(function (token) {
12537
+ }, 750, 'Read JWT token', 3).then(function (token) {
12226
12538
  if (_this4._refreshInterval > 0) {
12227
12539
  cachePromise = refreshPromise;
12228
12540
 
@@ -12290,8 +12602,8 @@ module.exports = function () {
12290
12602
  *
12291
12603
  * @public
12292
12604
  * @static
12293
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12294
- * @returns {Promise.<JwtGateway>}
12605
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12606
+ * @returns {Promise<JwtGateway>}
12295
12607
  */
12296
12608
 
12297
12609
  }, {
@@ -12319,8 +12631,8 @@ module.exports = function () {
12319
12631
  *
12320
12632
  * @public
12321
12633
  * @static
12322
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12323
- * @returns {Promise.<RequestInterceptor>}
12634
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12635
+ * @returns {Promise<RequestInterceptor>}
12324
12636
  */
12325
12637
 
12326
12638
  }, {
@@ -12336,7 +12648,7 @@ module.exports = function () {
12336
12648
  *
12337
12649
  * @public
12338
12650
  * @static
12339
- * @returns {Promise.<JwtGateway>}
12651
+ * @returns {Promise<JwtGateway>}
12340
12652
  */
12341
12653
 
12342
12654
  }, {
@@ -12350,7 +12662,7 @@ module.exports = function () {
12350
12662
  *
12351
12663
  * @public
12352
12664
  * @static
12353
- * @returns {Promise.<RequestInterceptor>}
12665
+ * @returns {Promise<RequestInterceptor>}
12354
12666
  */
12355
12667
 
12356
12668
  }, {
@@ -12366,7 +12678,7 @@ module.exports = function () {
12366
12678
  *
12367
12679
  * @public
12368
12680
  * @static
12369
- * @returns {Promise.<JwtGateway>}
12681
+ * @returns {Promise<JwtGateway>}
12370
12682
  */
12371
12683
 
12372
12684
  }, {
@@ -12380,7 +12692,7 @@ module.exports = function () {
12380
12692
  *
12381
12693
  * @public
12382
12694
  * @static
12383
- * @returns {Promise.<RequestInterceptor>}
12695
+ * @returns {Promise<RequestInterceptor>}
12384
12696
  */
12385
12697
 
12386
12698
  }, {
@@ -12397,7 +12709,7 @@ module.exports = function () {
12397
12709
  * @public
12398
12710
  * @static
12399
12711
  * @param {Function} tokenGenerator - A function which returns the JWT token.
12400
- * @returns {Promise.<JwtGateway>}
12712
+ * @returns {Promise<JwtGateway>}
12401
12713
  */
12402
12714
 
12403
12715
  }, {
@@ -12414,7 +12726,7 @@ module.exports = function () {
12414
12726
  * @public
12415
12727
  * @static
12416
12728
  * @param {JwtGateway~tokenGenerator} tokenGenerator - A function which returns the JWT token.
12417
- * @returns {Promise.<RequestInterceptor>}
12729
+ * @returns {Promise<RequestInterceptor>}
12418
12730
  */
12419
12731
 
12420
12732
  }, {
@@ -12477,7 +12789,7 @@ module.exports = function () {
12477
12789
  * A function returns a JWT token (or a promise for a JWT token).
12478
12790
  *
12479
12791
  * @callback JwtGateway~tokenGenerator
12480
- * @returns {String|Promise.<String>}
12792
+ * @returns {String|Promise<String>}
12481
12793
  */
12482
12794
 
12483
12795
  return JwtGateway;
@@ -12490,14 +12802,13 @@ module.exports = function () {
12490
12802
  'use strict';
12491
12803
 
12492
12804
  return {
12493
- version: '1.0.42'
12805
+ version: '1.3.3'
12494
12806
  };
12495
12807
  }();
12496
12808
 
12497
12809
  },{}],63:[function(require,module,exports){
12498
12810
  module.exports = require('./lib/axios');
12499
12811
  },{"./lib/axios":65}],64:[function(require,module,exports){
12500
- (function (process){
12501
12812
  'use strict';
12502
12813
 
12503
12814
  var utils = require('./../utils');
@@ -12506,7 +12817,6 @@ var buildURL = require('./../helpers/buildURL');
12506
12817
  var parseHeaders = require('./../helpers/parseHeaders');
12507
12818
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
12508
12819
  var createError = require('../core/createError');
12509
- var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
12510
12820
 
12511
12821
  module.exports = function xhrAdapter(config) {
12512
12822
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -12518,22 +12828,6 @@ module.exports = function xhrAdapter(config) {
12518
12828
  }
12519
12829
 
12520
12830
  var request = new XMLHttpRequest();
12521
- var loadEvent = 'onreadystatechange';
12522
- var xDomain = false;
12523
-
12524
- // For IE 8/9 CORS support
12525
- // Only supports POST and GET calls and doesn't returns the response headers.
12526
- // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
12527
- if (process.env.NODE_ENV !== 'test' &&
12528
- typeof window !== 'undefined' &&
12529
- window.XDomainRequest && !('withCredentials' in request) &&
12530
- !isURLSameOrigin(config.url)) {
12531
- request = new window.XDomainRequest();
12532
- loadEvent = 'onload';
12533
- xDomain = true;
12534
- request.onprogress = function handleProgress() {};
12535
- request.ontimeout = function handleTimeout() {};
12536
- }
12537
12831
 
12538
12832
  // HTTP basic authentication
12539
12833
  if (config.auth) {
@@ -12548,8 +12842,8 @@ module.exports = function xhrAdapter(config) {
12548
12842
  request.timeout = config.timeout;
12549
12843
 
12550
12844
  // Listen for ready state
12551
- request[loadEvent] = function handleLoad() {
12552
- if (!request || (request.readyState !== 4 && !xDomain)) {
12845
+ request.onreadystatechange = function handleLoad() {
12846
+ if (!request || request.readyState !== 4) {
12553
12847
  return;
12554
12848
  }
12555
12849
 
@@ -12566,9 +12860,8 @@ module.exports = function xhrAdapter(config) {
12566
12860
  var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
12567
12861
  var response = {
12568
12862
  data: responseData,
12569
- // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
12570
- status: request.status === 1223 ? 204 : request.status,
12571
- statusText: request.status === 1223 ? 'No Content' : request.statusText,
12863
+ status: request.status,
12864
+ statusText: request.statusText,
12572
12865
  headers: responseHeaders,
12573
12866
  config: config,
12574
12867
  request: request
@@ -12580,6 +12873,18 @@ module.exports = function xhrAdapter(config) {
12580
12873
  request = null;
12581
12874
  };
12582
12875
 
12876
+ // Handle browser request cancellation (as opposed to a manual cancellation)
12877
+ request.onabort = function handleAbort() {
12878
+ if (!request) {
12879
+ return;
12880
+ }
12881
+
12882
+ reject(createError('Request aborted', config, 'ECONNABORTED', request));
12883
+
12884
+ // Clean up request
12885
+ request = null;
12886
+ };
12887
+
12583
12888
  // Handle low level network errors
12584
12889
  request.onerror = function handleError() {
12585
12890
  // Real errors are hidden from us by the browser
@@ -12607,8 +12912,8 @@ module.exports = function xhrAdapter(config) {
12607
12912
 
12608
12913
  // Add xsrf header
12609
12914
  var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
12610
- cookies.read(config.xsrfCookieName) :
12611
- undefined;
12915
+ cookies.read(config.xsrfCookieName) :
12916
+ undefined;
12612
12917
 
12613
12918
  if (xsrfValue) {
12614
12919
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
@@ -12679,13 +12984,13 @@ module.exports = function xhrAdapter(config) {
12679
12984
  });
12680
12985
  };
12681
12986
 
12682
- }).call(this,require('_process'))
12683
- },{"../core/createError":71,"./../core/settle":74,"./../helpers/btoa":78,"./../helpers/buildURL":79,"./../helpers/cookies":81,"./../helpers/isURLSameOrigin":83,"./../helpers/parseHeaders":85,"./../utils":87,"_process":89}],65:[function(require,module,exports){
12987
+ },{"../core/createError":71,"./../core/settle":75,"./../helpers/buildURL":79,"./../helpers/cookies":81,"./../helpers/isURLSameOrigin":83,"./../helpers/parseHeaders":85,"./../utils":87}],65:[function(require,module,exports){
12684
12988
  'use strict';
12685
12989
 
12686
12990
  var utils = require('./utils');
12687
12991
  var bind = require('./helpers/bind');
12688
12992
  var Axios = require('./core/Axios');
12993
+ var mergeConfig = require('./core/mergeConfig');
12689
12994
  var defaults = require('./defaults');
12690
12995
 
12691
12996
  /**
@@ -12715,7 +13020,7 @@ axios.Axios = Axios;
12715
13020
 
12716
13021
  // Factory for creating new instances
12717
13022
  axios.create = function create(instanceConfig) {
12718
- return createInstance(utils.merge(defaults, instanceConfig));
13023
+ return createInstance(mergeConfig(axios.defaults, instanceConfig));
12719
13024
  };
12720
13025
 
12721
13026
  // Expose Cancel & CancelToken
@@ -12734,7 +13039,7 @@ module.exports = axios;
12734
13039
  // Allow use of default import syntax in TypeScript
12735
13040
  module.exports.default = axios;
12736
13041
 
12737
- },{"./cancel/Cancel":66,"./cancel/CancelToken":67,"./cancel/isCancel":68,"./core/Axios":69,"./defaults":76,"./helpers/bind":77,"./helpers/spread":86,"./utils":87}],66:[function(require,module,exports){
13042
+ },{"./cancel/Cancel":66,"./cancel/CancelToken":67,"./cancel/isCancel":68,"./core/Axios":69,"./core/mergeConfig":74,"./defaults":77,"./helpers/bind":78,"./helpers/spread":86,"./utils":87}],66:[function(require,module,exports){
12738
13043
  'use strict';
12739
13044
 
12740
13045
  /**
@@ -12824,10 +13129,11 @@ module.exports = function isCancel(value) {
12824
13129
  },{}],69:[function(require,module,exports){
12825
13130
  'use strict';
12826
13131
 
12827
- var defaults = require('./../defaults');
12828
13132
  var utils = require('./../utils');
13133
+ var buildURL = require('../helpers/buildURL');
12829
13134
  var InterceptorManager = require('./InterceptorManager');
12830
13135
  var dispatchRequest = require('./dispatchRequest');
13136
+ var mergeConfig = require('./mergeConfig');
12831
13137
 
12832
13138
  /**
12833
13139
  * Create a new instance of Axios
@@ -12851,13 +13157,14 @@ Axios.prototype.request = function request(config) {
12851
13157
  /*eslint no-param-reassign:0*/
12852
13158
  // Allow for axios('example/url'[, config]) a la fetch API
12853
13159
  if (typeof config === 'string') {
12854
- config = utils.merge({
12855
- url: arguments[0]
12856
- }, arguments[1]);
13160
+ config = arguments[1] || {};
13161
+ config.url = arguments[0];
13162
+ } else {
13163
+ config = config || {};
12857
13164
  }
12858
13165
 
12859
- config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
12860
- config.method = config.method.toLowerCase();
13166
+ config = mergeConfig(this.defaults, config);
13167
+ config.method = config.method ? config.method.toLowerCase() : 'get';
12861
13168
 
12862
13169
  // Hook up interceptors middleware
12863
13170
  var chain = [dispatchRequest, undefined];
@@ -12878,6 +13185,11 @@ Axios.prototype.request = function request(config) {
12878
13185
  return promise;
12879
13186
  };
12880
13187
 
13188
+ Axios.prototype.getUri = function getUri(config) {
13189
+ config = mergeConfig(this.defaults, config);
13190
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
13191
+ };
13192
+
12881
13193
  // Provide aliases for supported request methods
12882
13194
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
12883
13195
  /*eslint func-names:0*/
@@ -12902,7 +13214,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
12902
13214
 
12903
13215
  module.exports = Axios;
12904
13216
 
12905
- },{"./../defaults":76,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72}],70:[function(require,module,exports){
13217
+ },{"../helpers/buildURL":79,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72,"./mergeConfig":74}],70:[function(require,module,exports){
12906
13218
  'use strict';
12907
13219
 
12908
13220
  var utils = require('./../utils');
@@ -13064,7 +13376,7 @@ module.exports = function dispatchRequest(config) {
13064
13376
  });
13065
13377
  };
13066
13378
 
13067
- },{"../cancel/isCancel":68,"../defaults":76,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":75}],73:[function(require,module,exports){
13379
+ },{"../cancel/isCancel":68,"../defaults":77,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":76}],73:[function(require,module,exports){
13068
13380
  'use strict';
13069
13381
 
13070
13382
  /**
@@ -13082,14 +13394,88 @@ module.exports = function enhanceError(error, config, code, request, response) {
13082
13394
  if (code) {
13083
13395
  error.code = code;
13084
13396
  }
13397
+
13085
13398
  error.request = request;
13086
13399
  error.response = response;
13400
+ error.isAxiosError = true;
13401
+
13402
+ error.toJSON = function() {
13403
+ return {
13404
+ // Standard
13405
+ message: this.message,
13406
+ name: this.name,
13407
+ // Microsoft
13408
+ description: this.description,
13409
+ number: this.number,
13410
+ // Mozilla
13411
+ fileName: this.fileName,
13412
+ lineNumber: this.lineNumber,
13413
+ columnNumber: this.columnNumber,
13414
+ stack: this.stack,
13415
+ // Axios
13416
+ config: this.config,
13417
+ code: this.code
13418
+ };
13419
+ };
13087
13420
  return error;
13088
13421
  };
13089
13422
 
13090
13423
  },{}],74:[function(require,module,exports){
13091
13424
  'use strict';
13092
13425
 
13426
+ var utils = require('../utils');
13427
+
13428
+ /**
13429
+ * Config-specific merge-function which creates a new config-object
13430
+ * by merging two configuration objects together.
13431
+ *
13432
+ * @param {Object} config1
13433
+ * @param {Object} config2
13434
+ * @returns {Object} New object resulting from merging config2 to config1
13435
+ */
13436
+ module.exports = function mergeConfig(config1, config2) {
13437
+ // eslint-disable-next-line no-param-reassign
13438
+ config2 = config2 || {};
13439
+ var config = {};
13440
+
13441
+ utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
13442
+ if (typeof config2[prop] !== 'undefined') {
13443
+ config[prop] = config2[prop];
13444
+ }
13445
+ });
13446
+
13447
+ utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
13448
+ if (utils.isObject(config2[prop])) {
13449
+ config[prop] = utils.deepMerge(config1[prop], config2[prop]);
13450
+ } else if (typeof config2[prop] !== 'undefined') {
13451
+ config[prop] = config2[prop];
13452
+ } else if (utils.isObject(config1[prop])) {
13453
+ config[prop] = utils.deepMerge(config1[prop]);
13454
+ } else if (typeof config1[prop] !== 'undefined') {
13455
+ config[prop] = config1[prop];
13456
+ }
13457
+ });
13458
+
13459
+ utils.forEach([
13460
+ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
13461
+ 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
13462
+ 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
13463
+ 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
13464
+ 'socketPath'
13465
+ ], function defaultToConfig2(prop) {
13466
+ if (typeof config2[prop] !== 'undefined') {
13467
+ config[prop] = config2[prop];
13468
+ } else if (typeof config1[prop] !== 'undefined') {
13469
+ config[prop] = config1[prop];
13470
+ }
13471
+ });
13472
+
13473
+ return config;
13474
+ };
13475
+
13476
+ },{"../utils":87}],75:[function(require,module,exports){
13477
+ 'use strict';
13478
+
13093
13479
  var createError = require('./createError');
13094
13480
 
13095
13481
  /**
@@ -13101,8 +13487,7 @@ var createError = require('./createError');
13101
13487
  */
13102
13488
  module.exports = function settle(resolve, reject, response) {
13103
13489
  var validateStatus = response.config.validateStatus;
13104
- // Note: status is not exposed by XDomainRequest
13105
- if (!response.status || !validateStatus || validateStatus(response.status)) {
13490
+ if (!validateStatus || validateStatus(response.status)) {
13106
13491
  resolve(response);
13107
13492
  } else {
13108
13493
  reject(createError(
@@ -13115,7 +13500,7 @@ module.exports = function settle(resolve, reject, response) {
13115
13500
  }
13116
13501
  };
13117
13502
 
13118
- },{"./createError":71}],75:[function(require,module,exports){
13503
+ },{"./createError":71}],76:[function(require,module,exports){
13119
13504
  'use strict';
13120
13505
 
13121
13506
  var utils = require('./../utils');
@@ -13137,7 +13522,7 @@ module.exports = function transformData(data, headers, fns) {
13137
13522
  return data;
13138
13523
  };
13139
13524
 
13140
- },{"./../utils":87}],76:[function(require,module,exports){
13525
+ },{"./../utils":87}],77:[function(require,module,exports){
13141
13526
  (function (process){
13142
13527
  'use strict';
13143
13528
 
@@ -13156,12 +13541,13 @@ function setContentTypeIfUnset(headers, value) {
13156
13541
 
13157
13542
  function getDefaultAdapter() {
13158
13543
  var adapter;
13159
- if (typeof XMLHttpRequest !== 'undefined') {
13160
- // For browsers use XHR adapter
13161
- adapter = require('./adapters/xhr');
13162
- } else if (typeof process !== 'undefined') {
13544
+ // Only Node.JS has a process variable that is of [[Class]] process
13545
+ if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
13163
13546
  // For node use HTTP adapter
13164
13547
  adapter = require('./adapters/http');
13548
+ } else if (typeof XMLHttpRequest !== 'undefined') {
13549
+ // For browsers use XHR adapter
13550
+ adapter = require('./adapters/xhr');
13165
13551
  }
13166
13552
  return adapter;
13167
13553
  }
@@ -13170,6 +13556,7 @@ var defaults = {
13170
13556
  adapter: getDefaultAdapter(),
13171
13557
 
13172
13558
  transformRequest: [function transformRequest(data, headers) {
13559
+ normalizeHeaderName(headers, 'Accept');
13173
13560
  normalizeHeaderName(headers, 'Content-Type');
13174
13561
  if (utils.isFormData(data) ||
13175
13562
  utils.isArrayBuffer(data) ||
@@ -13204,6 +13591,10 @@ var defaults = {
13204
13591
  return data;
13205
13592
  }],
13206
13593
 
13594
+ /**
13595
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
13596
+ * timeout is not created.
13597
+ */
13207
13598
  timeout: 0,
13208
13599
 
13209
13600
  xsrfCookieName: 'XSRF-TOKEN',
@@ -13233,7 +13624,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
13233
13624
  module.exports = defaults;
13234
13625
 
13235
13626
  }).call(this,require('_process'))
13236
- },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],77:[function(require,module,exports){
13627
+ },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],78:[function(require,module,exports){
13237
13628
  'use strict';
13238
13629
 
13239
13630
  module.exports = function bind(fn, thisArg) {
@@ -13246,44 +13637,6 @@ module.exports = function bind(fn, thisArg) {
13246
13637
  };
13247
13638
  };
13248
13639
 
13249
- },{}],78:[function(require,module,exports){
13250
- 'use strict';
13251
-
13252
- // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
13253
-
13254
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
13255
-
13256
- function E() {
13257
- this.message = 'String contains an invalid character';
13258
- }
13259
- E.prototype = new Error;
13260
- E.prototype.code = 5;
13261
- E.prototype.name = 'InvalidCharacterError';
13262
-
13263
- function btoa(input) {
13264
- var str = String(input);
13265
- var output = '';
13266
- for (
13267
- // initialize result and counter
13268
- var block, charCode, idx = 0, map = chars;
13269
- // if the next str index does not exist:
13270
- // change the mapping table to "="
13271
- // check if d has no fractional digits
13272
- str.charAt(idx | 0) || (map = '=', idx % 1);
13273
- // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
13274
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
13275
- ) {
13276
- charCode = str.charCodeAt(idx += 3 / 4);
13277
- if (charCode > 0xFF) {
13278
- throw new E();
13279
- }
13280
- block = block << 8 | charCode;
13281
- }
13282
- return output;
13283
- }
13284
-
13285
- module.exports = btoa;
13286
-
13287
13640
  },{}],79:[function(require,module,exports){
13288
13641
  'use strict';
13289
13642
 
@@ -13328,9 +13681,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13328
13681
 
13329
13682
  if (utils.isArray(val)) {
13330
13683
  key = key + '[]';
13331
- }
13332
-
13333
- if (!utils.isArray(val)) {
13684
+ } else {
13334
13685
  val = [val];
13335
13686
  }
13336
13687
 
@@ -13348,6 +13699,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13348
13699
  }
13349
13700
 
13350
13701
  if (serializedParams) {
13702
+ var hashmarkIndex = url.indexOf('#');
13703
+ if (hashmarkIndex !== -1) {
13704
+ url = url.slice(0, hashmarkIndex);
13705
+ }
13706
+
13351
13707
  url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
13352
13708
  }
13353
13709
 
@@ -13379,50 +13735,50 @@ module.exports = (
13379
13735
  utils.isStandardBrowserEnv() ?
13380
13736
 
13381
13737
  // Standard browser envs support document.cookie
13382
- (function standardBrowserEnv() {
13383
- return {
13384
- write: function write(name, value, expires, path, domain, secure) {
13385
- var cookie = [];
13386
- cookie.push(name + '=' + encodeURIComponent(value));
13738
+ (function standardBrowserEnv() {
13739
+ return {
13740
+ write: function write(name, value, expires, path, domain, secure) {
13741
+ var cookie = [];
13742
+ cookie.push(name + '=' + encodeURIComponent(value));
13387
13743
 
13388
- if (utils.isNumber(expires)) {
13389
- cookie.push('expires=' + new Date(expires).toGMTString());
13390
- }
13744
+ if (utils.isNumber(expires)) {
13745
+ cookie.push('expires=' + new Date(expires).toGMTString());
13746
+ }
13391
13747
 
13392
- if (utils.isString(path)) {
13393
- cookie.push('path=' + path);
13394
- }
13748
+ if (utils.isString(path)) {
13749
+ cookie.push('path=' + path);
13750
+ }
13395
13751
 
13396
- if (utils.isString(domain)) {
13397
- cookie.push('domain=' + domain);
13398
- }
13752
+ if (utils.isString(domain)) {
13753
+ cookie.push('domain=' + domain);
13754
+ }
13399
13755
 
13400
- if (secure === true) {
13401
- cookie.push('secure');
13402
- }
13756
+ if (secure === true) {
13757
+ cookie.push('secure');
13758
+ }
13403
13759
 
13404
- document.cookie = cookie.join('; ');
13405
- },
13760
+ document.cookie = cookie.join('; ');
13761
+ },
13406
13762
 
13407
- read: function read(name) {
13408
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13409
- return (match ? decodeURIComponent(match[3]) : null);
13410
- },
13763
+ read: function read(name) {
13764
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13765
+ return (match ? decodeURIComponent(match[3]) : null);
13766
+ },
13411
13767
 
13412
- remove: function remove(name) {
13413
- this.write(name, '', Date.now() - 86400000);
13414
- }
13415
- };
13416
- })() :
13768
+ remove: function remove(name) {
13769
+ this.write(name, '', Date.now() - 86400000);
13770
+ }
13771
+ };
13772
+ })() :
13417
13773
 
13418
13774
  // Non standard browser env (web workers, react-native) lack needed support.
13419
- (function nonStandardBrowserEnv() {
13420
- return {
13421
- write: function write() {},
13422
- read: function read() { return null; },
13423
- remove: function remove() {}
13424
- };
13425
- })()
13775
+ (function nonStandardBrowserEnv() {
13776
+ return {
13777
+ write: function write() {},
13778
+ read: function read() { return null; },
13779
+ remove: function remove() {}
13780
+ };
13781
+ })()
13426
13782
  );
13427
13783
 
13428
13784
  },{"./../utils":87}],82:[function(require,module,exports){
@@ -13451,64 +13807,64 @@ module.exports = (
13451
13807
 
13452
13808
  // Standard browser envs have full support of the APIs needed to test
13453
13809
  // whether the request URL is of the same origin as current location.
13454
- (function standardBrowserEnv() {
13455
- var msie = /(msie|trident)/i.test(navigator.userAgent);
13456
- var urlParsingNode = document.createElement('a');
13457
- var originURL;
13810
+ (function standardBrowserEnv() {
13811
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
13812
+ var urlParsingNode = document.createElement('a');
13813
+ var originURL;
13458
13814
 
13459
- /**
13815
+ /**
13460
13816
  * Parse a URL to discover it's components
13461
13817
  *
13462
13818
  * @param {String} url The URL to be parsed
13463
13819
  * @returns {Object}
13464
13820
  */
13465
- function resolveURL(url) {
13466
- var href = url;
13821
+ function resolveURL(url) {
13822
+ var href = url;
13467
13823
 
13468
- if (msie) {
13824
+ if (msie) {
13469
13825
  // IE needs attribute set twice to normalize properties
13470
- urlParsingNode.setAttribute('href', href);
13471
- href = urlParsingNode.href;
13472
- }
13826
+ urlParsingNode.setAttribute('href', href);
13827
+ href = urlParsingNode.href;
13828
+ }
13473
13829
 
13474
- urlParsingNode.setAttribute('href', href);
13830
+ urlParsingNode.setAttribute('href', href);
13475
13831
 
13476
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13477
- return {
13478
- href: urlParsingNode.href,
13479
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13480
- host: urlParsingNode.host,
13481
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13482
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13483
- hostname: urlParsingNode.hostname,
13484
- port: urlParsingNode.port,
13485
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13486
- urlParsingNode.pathname :
13487
- '/' + urlParsingNode.pathname
13488
- };
13489
- }
13832
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13833
+ return {
13834
+ href: urlParsingNode.href,
13835
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13836
+ host: urlParsingNode.host,
13837
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13838
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13839
+ hostname: urlParsingNode.hostname,
13840
+ port: urlParsingNode.port,
13841
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13842
+ urlParsingNode.pathname :
13843
+ '/' + urlParsingNode.pathname
13844
+ };
13845
+ }
13490
13846
 
13491
- originURL = resolveURL(window.location.href);
13847
+ originURL = resolveURL(window.location.href);
13492
13848
 
13493
- /**
13849
+ /**
13494
13850
  * Determine if a URL shares the same origin as the current location
13495
13851
  *
13496
13852
  * @param {String} requestURL The URL to test
13497
13853
  * @returns {boolean} True if URL shares the same origin, otherwise false
13498
13854
  */
13499
- return function isURLSameOrigin(requestURL) {
13500
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13501
- return (parsed.protocol === originURL.protocol &&
13855
+ return function isURLSameOrigin(requestURL) {
13856
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13857
+ return (parsed.protocol === originURL.protocol &&
13502
13858
  parsed.host === originURL.host);
13503
- };
13504
- })() :
13859
+ };
13860
+ })() :
13505
13861
 
13506
13862
  // Non standard browser envs (web workers, react-native) lack needed support.
13507
- (function nonStandardBrowserEnv() {
13508
- return function isURLSameOrigin() {
13509
- return true;
13510
- };
13511
- })()
13863
+ (function nonStandardBrowserEnv() {
13864
+ return function isURLSameOrigin() {
13865
+ return true;
13866
+ };
13867
+ })()
13512
13868
  );
13513
13869
 
13514
13870
  },{"./../utils":87}],84:[function(require,module,exports){
@@ -13789,9 +14145,13 @@ function trim(str) {
13789
14145
  *
13790
14146
  * react-native:
13791
14147
  * navigator.product -> 'ReactNative'
14148
+ * nativescript
14149
+ * navigator.product -> 'NativeScript' or 'NS'
13792
14150
  */
13793
14151
  function isStandardBrowserEnv() {
13794
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
14152
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
14153
+ navigator.product === 'NativeScript' ||
14154
+ navigator.product === 'NS')) {
13795
14155
  return false;
13796
14156
  }
13797
14157
  return (
@@ -13872,6 +14232,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
13872
14232
  return result;
13873
14233
  }
13874
14234
 
14235
+ /**
14236
+ * Function equal to merge with the difference being that no reference
14237
+ * to original objects is kept.
14238
+ *
14239
+ * @see merge
14240
+ * @param {Object} obj1 Object to merge
14241
+ * @returns {Object} Result of all merge properties
14242
+ */
14243
+ function deepMerge(/* obj1, obj2, obj3, ... */) {
14244
+ var result = {};
14245
+ function assignValue(val, key) {
14246
+ if (typeof result[key] === 'object' && typeof val === 'object') {
14247
+ result[key] = deepMerge(result[key], val);
14248
+ } else if (typeof val === 'object') {
14249
+ result[key] = deepMerge({}, val);
14250
+ } else {
14251
+ result[key] = val;
14252
+ }
14253
+ }
14254
+
14255
+ for (var i = 0, l = arguments.length; i < l; i++) {
14256
+ forEach(arguments[i], assignValue);
14257
+ }
14258
+ return result;
14259
+ }
14260
+
13875
14261
  /**
13876
14262
  * Extends object a by mutably adding to it the properties of object b.
13877
14263
  *
@@ -13910,11 +14296,12 @@ module.exports = {
13910
14296
  isStandardBrowserEnv: isStandardBrowserEnv,
13911
14297
  forEach: forEach,
13912
14298
  merge: merge,
14299
+ deepMerge: deepMerge,
13913
14300
  extend: extend,
13914
14301
  trim: trim
13915
14302
  };
13916
14303
 
13917
- },{"./helpers/bind":77,"is-buffer":90}],88:[function(require,module,exports){
14304
+ },{"./helpers/bind":78,"is-buffer":90}],88:[function(require,module,exports){
13918
14305
  /*
13919
14306
  * big.js v5.0.3
13920
14307
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -15049,19 +15436,9 @@ process.umask = function() { return 0; };
15049
15436
  * @license MIT
15050
15437
  */
15051
15438
 
15052
- // The _isBuffer check is for Safari 5-7 support, because it's missing
15053
- // Object.prototype.constructor. Remove this eventually
15054
- module.exports = function (obj) {
15055
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
15056
- }
15057
-
15058
- function isBuffer (obj) {
15059
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
15060
- }
15061
-
15062
- // For Node v0.10 support. Remove this eventually.
15063
- function isSlowBuffer (obj) {
15064
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
15439
+ module.exports = function isBuffer (obj) {
15440
+ return obj != null && obj.constructor != null &&
15441
+ typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
15065
15442
  }
15066
15443
 
15067
15444
  },{}],91:[function(require,module,exports){
@@ -18618,22 +18995,36 @@ moment.tz.load(require('./data/packed/latest.json'));
18618
18995
  function createDate (y, m, d, h, M, s, ms) {
18619
18996
  // can't just apply() to create a date:
18620
18997
  // https://stackoverflow.com/q/181348
18621
- var date = new Date(y, m, d, h, M, s, ms);
18622
-
18998
+ var date;
18623
18999
  // the date constructor remaps years 0-99 to 1900-1999
18624
- if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
18625
- date.setFullYear(y);
19000
+ if (y < 100 && y >= 0) {
19001
+ // preserve leap years using a full 400 year cycle, then reset
19002
+ date = new Date(y + 400, m, d, h, M, s, ms);
19003
+ if (isFinite(date.getFullYear())) {
19004
+ date.setFullYear(y);
19005
+ }
19006
+ } else {
19007
+ date = new Date(y, m, d, h, M, s, ms);
18626
19008
  }
19009
+
18627
19010
  return date;
18628
19011
  }
18629
19012
 
18630
19013
  function createUTCDate (y) {
18631
- var date = new Date(Date.UTC.apply(null, arguments));
18632
-
19014
+ var date;
18633
19015
  // the Date.UTC function remaps years 0-99 to 1900-1999
18634
- if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
18635
- date.setUTCFullYear(y);
19016
+ if (y < 100 && y >= 0) {
19017
+ var args = Array.prototype.slice.call(arguments);
19018
+ // preserve leap years using a full 400 year cycle, then reset
19019
+ args[0] = y + 400;
19020
+ date = new Date(Date.UTC.apply(null, args));
19021
+ if (isFinite(date.getUTCFullYear())) {
19022
+ date.setUTCFullYear(y);
19023
+ }
19024
+ } else {
19025
+ date = new Date(Date.UTC.apply(null, arguments));
18636
19026
  }
19027
+
18637
19028
  return date;
18638
19029
  }
18639
19030
 
@@ -18735,7 +19126,7 @@ moment.tz.load(require('./data/packed/latest.json'));
18735
19126
 
18736
19127
  var defaultLocaleWeek = {
18737
19128
  dow : 0, // Sunday is the first day of the week.
18738
- doy : 6 // The week that contains Jan 1st is the first week of the year.
19129
+ doy : 6 // The week that contains Jan 6th is the first week of the year.
18739
19130
  };
18740
19131
 
18741
19132
  function localeFirstDayOfWeek () {
@@ -18844,25 +19235,28 @@ moment.tz.load(require('./data/packed/latest.json'));
18844
19235
  }
18845
19236
 
18846
19237
  // LOCALES
19238
+ function shiftWeekdays (ws, n) {
19239
+ return ws.slice(n, 7).concat(ws.slice(0, n));
19240
+ }
18847
19241
 
18848
19242
  var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
18849
19243
  function localeWeekdays (m, format) {
18850
- if (!m) {
18851
- return isArray(this._weekdays) ? this._weekdays :
18852
- this._weekdays['standalone'];
18853
- }
18854
- return isArray(this._weekdays) ? this._weekdays[m.day()] :
18855
- this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
19244
+ var weekdays = isArray(this._weekdays) ? this._weekdays :
19245
+ this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
19246
+ return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
19247
+ : (m) ? weekdays[m.day()] : weekdays;
18856
19248
  }
18857
19249
 
18858
19250
  var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
18859
19251
  function localeWeekdaysShort (m) {
18860
- return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
19252
+ return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
19253
+ : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
18861
19254
  }
18862
19255
 
18863
19256
  var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
18864
19257
  function localeWeekdaysMin (m) {
18865
- return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
19258
+ return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
19259
+ : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
18866
19260
  }
18867
19261
 
18868
19262
  function handleStrictParse$1(weekdayName, format, strict) {
@@ -19611,13 +20005,13 @@ moment.tz.load(require('./data/packed/latest.json'));
19611
20005
  weekdayOverflow = true;
19612
20006
  }
19613
20007
  } else if (w.e != null) {
19614
- // local weekday -- counting starts from begining of week
20008
+ // local weekday -- counting starts from beginning of week
19615
20009
  weekday = w.e + dow;
19616
20010
  if (w.e < 0 || w.e > 6) {
19617
20011
  weekdayOverflow = true;
19618
20012
  }
19619
20013
  } else {
19620
- // default to begining of week
20014
+ // default to beginning of week
19621
20015
  weekday = dow;
19622
20016
  }
19623
20017
  }
@@ -20211,7 +20605,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20211
20605
  years = normalizedInput.year || 0,
20212
20606
  quarters = normalizedInput.quarter || 0,
20213
20607
  months = normalizedInput.month || 0,
20214
- weeks = normalizedInput.week || 0,
20608
+ weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
20215
20609
  days = normalizedInput.day || 0,
20216
20610
  hours = normalizedInput.hour || 0,
20217
20611
  minutes = normalizedInput.minute || 0,
@@ -20515,7 +20909,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20515
20909
  ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
20516
20910
  };
20517
20911
  } else if (!!(match = isoRegex.exec(input))) {
20518
- sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
20912
+ sign = (match[1] === '-') ? -1 : 1;
20519
20913
  duration = {
20520
20914
  y : parseIso(match[2], sign),
20521
20915
  M : parseIso(match[3], sign),
@@ -20557,7 +20951,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20557
20951
  }
20558
20952
 
20559
20953
  function positiveMomentsDifference(base, other) {
20560
- var res = {milliseconds: 0, months: 0};
20954
+ var res = {};
20561
20955
 
20562
20956
  res.months = other.month() - base.month() +
20563
20957
  (other.year() - base.year()) * 12;
@@ -20666,7 +21060,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20666
21060
  if (!(this.isValid() && localInput.isValid())) {
20667
21061
  return false;
20668
21062
  }
20669
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
21063
+ units = normalizeUnits(units) || 'millisecond';
20670
21064
  if (units === 'millisecond') {
20671
21065
  return this.valueOf() > localInput.valueOf();
20672
21066
  } else {
@@ -20679,7 +21073,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20679
21073
  if (!(this.isValid() && localInput.isValid())) {
20680
21074
  return false;
20681
21075
  }
20682
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
21076
+ units = normalizeUnits(units) || 'millisecond';
20683
21077
  if (units === 'millisecond') {
20684
21078
  return this.valueOf() < localInput.valueOf();
20685
21079
  } else {
@@ -20688,9 +21082,14 @@ moment.tz.load(require('./data/packed/latest.json'));
20688
21082
  }
20689
21083
 
20690
21084
  function isBetween (from, to, units, inclusivity) {
21085
+ var localFrom = isMoment(from) ? from : createLocal(from),
21086
+ localTo = isMoment(to) ? to : createLocal(to);
21087
+ if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
21088
+ return false;
21089
+ }
20691
21090
  inclusivity = inclusivity || '()';
20692
- return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
20693
- (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
21091
+ return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
21092
+ (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
20694
21093
  }
20695
21094
 
20696
21095
  function isSame (input, units) {
@@ -20699,7 +21098,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20699
21098
  if (!(this.isValid() && localInput.isValid())) {
20700
21099
  return false;
20701
21100
  }
20702
- units = normalizeUnits(units || 'millisecond');
21101
+ units = normalizeUnits(units) || 'millisecond';
20703
21102
  if (units === 'millisecond') {
20704
21103
  return this.valueOf() === localInput.valueOf();
20705
21104
  } else {
@@ -20709,11 +21108,11 @@ moment.tz.load(require('./data/packed/latest.json'));
20709
21108
  }
20710
21109
 
20711
21110
  function isSameOrAfter (input, units) {
20712
- return this.isSame(input, units) || this.isAfter(input,units);
21111
+ return this.isSame(input, units) || this.isAfter(input, units);
20713
21112
  }
20714
21113
 
20715
21114
  function isSameOrBefore (input, units) {
20716
- return this.isSame(input, units) || this.isBefore(input,units);
21115
+ return this.isSame(input, units) || this.isBefore(input, units);
20717
21116
  }
20718
21117
 
20719
21118
  function diff (input, units, asFloat) {
@@ -20890,62 +21289,130 @@ moment.tz.load(require('./data/packed/latest.json'));
20890
21289
  return this._locale;
20891
21290
  }
20892
21291
 
21292
+ var MS_PER_SECOND = 1000;
21293
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
21294
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
21295
+ var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
21296
+
21297
+ // actual modulo - handles negative numbers (for dates before 1970):
21298
+ function mod$1(dividend, divisor) {
21299
+ return (dividend % divisor + divisor) % divisor;
21300
+ }
21301
+
21302
+ function localStartOfDate(y, m, d) {
21303
+ // the date constructor remaps years 0-99 to 1900-1999
21304
+ if (y < 100 && y >= 0) {
21305
+ // preserve leap years using a full 400 year cycle, then reset
21306
+ return new Date(y + 400, m, d) - MS_PER_400_YEARS;
21307
+ } else {
21308
+ return new Date(y, m, d).valueOf();
21309
+ }
21310
+ }
21311
+
21312
+ function utcStartOfDate(y, m, d) {
21313
+ // Date.UTC remaps years 0-99 to 1900-1999
21314
+ if (y < 100 && y >= 0) {
21315
+ // preserve leap years using a full 400 year cycle, then reset
21316
+ return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
21317
+ } else {
21318
+ return Date.UTC(y, m, d);
21319
+ }
21320
+ }
21321
+
20893
21322
  function startOf (units) {
21323
+ var time;
20894
21324
  units = normalizeUnits(units);
20895
- // the following switch intentionally omits break keywords
20896
- // to utilize falling through the cases.
21325
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
21326
+ return this;
21327
+ }
21328
+
21329
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21330
+
20897
21331
  switch (units) {
20898
21332
  case 'year':
20899
- this.month(0);
20900
- /* falls through */
21333
+ time = startOfDate(this.year(), 0, 1);
21334
+ break;
20901
21335
  case 'quarter':
21336
+ time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
21337
+ break;
20902
21338
  case 'month':
20903
- this.date(1);
20904
- /* falls through */
21339
+ time = startOfDate(this.year(), this.month(), 1);
21340
+ break;
20905
21341
  case 'week':
21342
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
21343
+ break;
20906
21344
  case 'isoWeek':
21345
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
21346
+ break;
20907
21347
  case 'day':
20908
21348
  case 'date':
20909
- this.hours(0);
20910
- /* falls through */
21349
+ time = startOfDate(this.year(), this.month(), this.date());
21350
+ break;
20911
21351
  case 'hour':
20912
- this.minutes(0);
20913
- /* falls through */
21352
+ time = this._d.valueOf();
21353
+ time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
21354
+ break;
20914
21355
  case 'minute':
20915
- this.seconds(0);
20916
- /* falls through */
21356
+ time = this._d.valueOf();
21357
+ time -= mod$1(time, MS_PER_MINUTE);
21358
+ break;
20917
21359
  case 'second':
20918
- this.milliseconds(0);
20919
- }
20920
-
20921
- // weeks are a special case
20922
- if (units === 'week') {
20923
- this.weekday(0);
20924
- }
20925
- if (units === 'isoWeek') {
20926
- this.isoWeekday(1);
20927
- }
20928
-
20929
- // quarters are also special
20930
- if (units === 'quarter') {
20931
- this.month(Math.floor(this.month() / 3) * 3);
21360
+ time = this._d.valueOf();
21361
+ time -= mod$1(time, MS_PER_SECOND);
21362
+ break;
20932
21363
  }
20933
21364
 
21365
+ this._d.setTime(time);
21366
+ hooks.updateOffset(this, true);
20934
21367
  return this;
20935
21368
  }
20936
21369
 
20937
21370
  function endOf (units) {
21371
+ var time;
20938
21372
  units = normalizeUnits(units);
20939
- if (units === undefined || units === 'millisecond') {
21373
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
20940
21374
  return this;
20941
21375
  }
20942
21376
 
20943
- // 'date' is an alias for 'day', so it should be considered as such.
20944
- if (units === 'date') {
20945
- units = 'day';
21377
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21378
+
21379
+ switch (units) {
21380
+ case 'year':
21381
+ time = startOfDate(this.year() + 1, 0, 1) - 1;
21382
+ break;
21383
+ case 'quarter':
21384
+ time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
21385
+ break;
21386
+ case 'month':
21387
+ time = startOfDate(this.year(), this.month() + 1, 1) - 1;
21388
+ break;
21389
+ case 'week':
21390
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
21391
+ break;
21392
+ case 'isoWeek':
21393
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
21394
+ break;
21395
+ case 'day':
21396
+ case 'date':
21397
+ time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
21398
+ break;
21399
+ case 'hour':
21400
+ time = this._d.valueOf();
21401
+ time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
21402
+ break;
21403
+ case 'minute':
21404
+ time = this._d.valueOf();
21405
+ time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
21406
+ break;
21407
+ case 'second':
21408
+ time = this._d.valueOf();
21409
+ time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
21410
+ break;
20946
21411
  }
20947
21412
 
20948
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
21413
+ this._d.setTime(time);
21414
+ hooks.updateOffset(this, true);
21415
+ return this;
20949
21416
  }
20950
21417
 
20951
21418
  function valueOf () {
@@ -21651,10 +22118,14 @@ moment.tz.load(require('./data/packed/latest.json'));
21651
22118
 
21652
22119
  units = normalizeUnits(units);
21653
22120
 
21654
- if (units === 'month' || units === 'year') {
21655
- days = this._days + milliseconds / 864e5;
22121
+ if (units === 'month' || units === 'quarter' || units === 'year') {
22122
+ days = this._days + milliseconds / 864e5;
21656
22123
  months = this._months + daysToMonths(days);
21657
- return units === 'month' ? months : months / 12;
22124
+ switch (units) {
22125
+ case 'month': return months;
22126
+ case 'quarter': return months / 3;
22127
+ case 'year': return months / 12;
22128
+ }
21658
22129
  } else {
21659
22130
  // handle milliseconds separately because of floating point math errors (issue #1867)
21660
22131
  days = this._days + Math.round(monthsToDays(this._months));
@@ -21697,6 +22168,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21697
22168
  var asDays = makeAs('d');
21698
22169
  var asWeeks = makeAs('w');
21699
22170
  var asMonths = makeAs('M');
22171
+ var asQuarters = makeAs('Q');
21700
22172
  var asYears = makeAs('y');
21701
22173
 
21702
22174
  function clone$1 () {
@@ -21888,6 +22360,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21888
22360
  proto$2.asDays = asDays;
21889
22361
  proto$2.asWeeks = asWeeks;
21890
22362
  proto$2.asMonths = asMonths;
22363
+ proto$2.asQuarters = asQuarters;
21891
22364
  proto$2.asYears = asYears;
21892
22365
  proto$2.valueOf = valueOf$1;
21893
22366
  proto$2._bubble = bubble;
@@ -21932,7 +22405,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21932
22405
  // Side effect imports
21933
22406
 
21934
22407
 
21935
- hooks.version = '2.22.2';
22408
+ hooks.version = '2.24.0';
21936
22409
 
21937
22410
  setHookCallback(createLocal);
21938
22411
 
@@ -21973,7 +22446,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21973
22446
  TIME: 'HH:mm', // <input type="time" />
21974
22447
  TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
21975
22448
  TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
21976
- WEEK: 'YYYY-[W]WW', // <input type="week" />
22449
+ WEEK: 'GGGG-[W]WW', // <input type="week" />
21977
22450
  MONTH: 'YYYY-MM' // <input type="month" />
21978
22451
  };
21979
22452