@barchart/portfolio-client-js 1.3.13 → 1.3.16

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'),
@@ -252,7 +253,7 @@ module.exports = function () {
252
253
 
253
254
  _this._deletePositionEndpoint = EndpointBuilder.for('delete-position', 'delete position').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
254
255
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
255
- }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
256
+ }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserializationForRemoval).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
256
257
 
257
258
  _this._readPositionSummariesEndpoint = EndpointBuilder.for('read-position-summaries', 'read position summaries').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
258
259
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withVariableParameter('position', 'position', 'position', false);
@@ -300,7 +301,7 @@ module.exports = function () {
300
301
  }).withVariableParameter('echoEnd', 'echoEnd', 'echoEnd', true, function (x) {
301
302
  return x.format();
302
303
  });
303
- }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
304
+ }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserializationForRemoval).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
304
305
 
305
306
  _this._readTransactionsReportEndpoint = EndpointBuilder.for('read-transaction-report', 'read transaction report').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
306
307
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', true).withLiteralParameter('transactions', 'transactions').withLiteralParameter('formatted', 'formatted');
@@ -1190,29 +1191,15 @@ module.exports = function () {
1190
1191
 
1191
1192
  var responseInterceptorForPositionMutateDeserialization = ResponseInterceptor.fromDelegate(function (response, ignored) {
1192
1193
  try {
1193
- var saved = response.data.positions.saved.map(function (p) {
1194
- return JSON.parse(p, PositionSchema.CLIENT.schema.getReviver());
1195
- });
1196
- var deleted = response.data.positions.deleted.map(function (p) {
1197
- return JSON.parse(p, PositionSchema.CLIENT.schema.getReviver());
1198
- });
1199
- var summaries = response.data.summaries.map(function (s) {
1200
- return JSON.parse(s, PositionSummarySchema.CLIENT.schema.getReviver());
1201
- });
1202
-
1203
- var returnRef = {
1204
- positions: {
1205
- saved: saved,
1206
- deleted: deleted
1207
- },
1208
- summaries: summaries
1209
- };
1210
-
1211
- if (response.data.transactions) {
1212
- returnRef.transactions = response.data.transactions;
1213
- }
1194
+ return deserializePositionMutateData(response.data, false);
1195
+ } catch (e) {
1196
+ console.error('Error deserializing position mutate data', e);
1197
+ }
1198
+ });
1214
1199
 
1215
- return returnRef;
1200
+ var responseInterceptorForPositionMutateDeserializationForRemoval = ResponseInterceptor.fromDelegate(function (response, ignored) {
1201
+ try {
1202
+ return deserializePositionMutateData(response.data, true);
1216
1203
  } catch (e) {
1217
1204
  console.error('Error deserializing position mutate data', e);
1218
1205
  }
@@ -1234,6 +1221,47 @@ module.exports = function () {
1234
1221
  }
1235
1222
  }
1236
1223
 
1224
+ function extractInstrumentId(position) {
1225
+ return position.instrument.id;
1226
+ }
1227
+
1228
+ function deserializePositionMutateData(data, removing) {
1229
+ var saved = data.positions.saved.map(function (p) {
1230
+ return JSON.parse(p, PositionSchema.CLIENT.schema.getReviver());
1231
+ });
1232
+ var deleted = data.positions.deleted.map(function (p) {
1233
+ return JSON.parse(p, PositionSchema.CLIENT.schema.getReviver());
1234
+ });
1235
+ var summaries = data.summaries.map(function (s) {
1236
+ return JSON.parse(s, PositionSummarySchema.CLIENT.schema.getReviver());
1237
+ });
1238
+
1239
+ var created = array.differenceBy(saved, deleted, extractInstrumentId).filter(function (p) {
1240
+ return p.transaction === 1 && !removing;
1241
+ });
1242
+ var removed = array.differenceBy(deleted, saved, extractInstrumentId);
1243
+ var edited = array.differenceBy(array.unionBy(saved, deleted, extractInstrumentId), array.unionBy(created, removed, extractInstrumentId), extractInstrumentId);
1244
+
1245
+ var returnRef = {
1246
+ actions: {
1247
+ created: created,
1248
+ removed: removed,
1249
+ edited: edited
1250
+ },
1251
+ positions: {
1252
+ saved: saved,
1253
+ deleted: deleted
1254
+ },
1255
+ summaries: summaries
1256
+ };
1257
+
1258
+ if (data.transactions) {
1259
+ returnRef.transactions = data.transactions;
1260
+ }
1261
+
1262
+ return returnRef;
1263
+ }
1264
+
1237
1265
  /**
1238
1266
  * The result of transaction create operation.
1239
1267
  *
@@ -1247,7 +1275,7 @@ module.exports = function () {
1247
1275
  return PortfolioGateway;
1248
1276
  }();
1249
1277
 
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){
1278
+ },{"./../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
1279
  'use strict';
1252
1280
 
1253
1281
  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 +1713,7 @@ module.exports = function () {
1685
1713
  return {
1686
1714
  JwtGateway: JwtGateway,
1687
1715
  PortfolioGateway: PortfolioGateway,
1688
- version: '1.3.13'
1716
+ version: '1.3.16'
1689
1717
  };
1690
1718
  }();
1691
1719
 
@@ -1807,6 +1835,22 @@ module.exports = function () {
1807
1835
  return item.type === type;
1808
1836
  }, false, false) !== null;
1809
1837
  }
1838
+
1839
+ /**
1840
+ * Indicates if the tree of {@link FailureReasonItem} instances contains
1841
+ * at least one item that is considered to be severe.
1842
+ *
1843
+ * @public
1844
+ * @returns {Boolean}
1845
+ */
1846
+
1847
+ }, {
1848
+ key: 'getIsSevere',
1849
+ value: function getIsSevere() {
1850
+ return this._head.search(function (item) {
1851
+ return item.type.severe;
1852
+ }, false, false) !== null;
1853
+ }
1810
1854
  }, {
1811
1855
  key: 'toJSON',
1812
1856
  value: function toJSON() {
@@ -1837,6 +1881,8 @@ module.exports = function () {
1837
1881
  * Returns an HTTP status code that would be suitable for use with the
1838
1882
  * failure reason.
1839
1883
  *
1884
+ * @public
1885
+ * @static
1840
1886
  * @param {FailureReason} reason
1841
1887
  * @returns {Number}
1842
1888
  */
@@ -1861,7 +1907,9 @@ module.exports = function () {
1861
1907
 
1862
1908
  /**
1863
1909
  * Validates that a candidate conforms to a schema
1864
- *
1910
+ *
1911
+ * @public
1912
+ * @static
1865
1913
  * @param {Schema} schema
1866
1914
  * @param {Object} candidate
1867
1915
  */
@@ -1940,6 +1988,7 @@ module.exports = function () {
1940
1988
  /**
1941
1989
  * The {@link FailureType} of the item.
1942
1990
  *
1991
+ * @public
1943
1992
  * @returns {FailureType}
1944
1993
  */
1945
1994
 
@@ -2022,7 +2071,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
2022
2071
  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
2072
 
2024
2073
  var assert = require('./../../lang/assert'),
2025
- Enum = require('./../../lang/Enum');
2074
+ Enum = require('./../../lang/Enum'),
2075
+ is = require('./../../lang/is');
2026
2076
 
2027
2077
  module.exports = function () {
2028
2078
  'use strict';
@@ -2032,21 +2082,29 @@ module.exports = function () {
2032
2082
  *
2033
2083
  * @public
2034
2084
  * @extends {Enum}
2035
- * @param {String} code - The enumeration code (and description)
2085
+ * @param {String} code - The enumeration code (and description).
2036
2086
  * @param {String} template - The template string for formatting human-readable messages.
2087
+ * @param {Boolean=} severe - Indicates if the failure is severe (default is true).
2037
2088
  */
2038
2089
 
2039
2090
  var FailureType = function (_Enum) {
2040
2091
  _inherits(FailureType, _Enum);
2041
2092
 
2042
- function FailureType(code, template) {
2093
+ function FailureType(code, template, severe) {
2043
2094
  _classCallCheck(this, FailureType);
2044
2095
 
2045
2096
  var _this = _possibleConstructorReturn(this, (FailureType.__proto__ || Object.getPrototypeOf(FailureType)).call(this, code, code));
2046
2097
 
2047
2098
  assert.argumentIsRequired(template, 'template', String);
2099
+ assert.argumentIsOptional(severe, 'severe', Boolean);
2048
2100
 
2049
2101
  _this._template = template;
2102
+
2103
+ if (is.boolean(severe)) {
2104
+ _this._severe = severe;
2105
+ } else {
2106
+ _this._severe = true;
2107
+ }
2050
2108
  return _this;
2051
2109
  }
2052
2110
 
@@ -2069,9 +2127,23 @@ module.exports = function () {
2069
2127
  return this._template;
2070
2128
  }
2071
2129
 
2130
+ /**
2131
+ * Indicates if the failure is serious.
2132
+ *
2133
+ * @public
2134
+ * @return {Boolean}
2135
+ */
2136
+
2137
+ }, {
2138
+ key: 'severe',
2139
+ get: function get() {
2140
+ return this._severe;
2141
+ }
2142
+
2072
2143
  /**
2073
2144
  * One or more data points is missing.
2074
2145
  *
2146
+ * @public
2075
2147
  * @static
2076
2148
  * @returns {FailureType}
2077
2149
  */
@@ -2084,6 +2156,8 @@ module.exports = function () {
2084
2156
  * Returns an HTTP status code that would be suitable for use with the
2085
2157
  * failure type.
2086
2158
  *
2159
+ * @public
2160
+ * @static
2087
2161
  * @param {FailureType} type
2088
2162
  * @returns {Number}
2089
2163
  */
@@ -2111,6 +2185,7 @@ module.exports = function () {
2111
2185
  /**
2112
2186
  * A data point is missing.
2113
2187
  *
2188
+ * @public
2114
2189
  * @static
2115
2190
  * @returns {FailureType}
2116
2191
  */
@@ -2124,6 +2199,7 @@ module.exports = function () {
2124
2199
  /**
2125
2200
  * A data point is malformed.
2126
2201
  *
2202
+ * @public
2127
2203
  * @static
2128
2204
  * @returns {FailureType}
2129
2205
  */
@@ -2137,6 +2213,7 @@ module.exports = function () {
2137
2213
  /**
2138
2214
  * User identity could not be determined.
2139
2215
  *
2216
+ * @public
2140
2217
  * @static
2141
2218
  * @returns {FailureType}
2142
2219
  */
@@ -2150,6 +2227,7 @@ module.exports = function () {
2150
2227
  /**
2151
2228
  * User authorization failed.
2152
2229
  *
2230
+ * @public
2153
2231
  * @static
2154
2232
  * @returns {FailureType}
2155
2233
  */
@@ -2163,6 +2241,7 @@ module.exports = function () {
2163
2241
  /**
2164
2242
  * The request data cannot be parsed or interpreted.
2165
2243
  *
2244
+ * @public
2166
2245
  * @static
2167
2246
  * @returns {FailureType}
2168
2247
  */
@@ -2176,6 +2255,7 @@ module.exports = function () {
2176
2255
  /**
2177
2256
  * The request failed for unspecified reasons.
2178
2257
  *
2258
+ * @public
2179
2259
  * @static
2180
2260
  * @returns {FailureType}
2181
2261
  */
@@ -2189,6 +2269,7 @@ module.exports = function () {
2189
2269
  /**
2190
2270
  * The request failed for unspecified reasons.
2191
2271
  *
2272
+ * @public
2192
2273
  * @static
2193
2274
  * @returns {FailureType}
2194
2275
  */
@@ -2215,7 +2296,7 @@ module.exports = function () {
2215
2296
  return FailureType;
2216
2297
  }();
2217
2298
 
2218
- },{"./../../lang/Enum":32,"./../../lang/assert":37}],9:[function(require,module,exports){
2299
+ },{"./../../lang/Enum":32,"./../../lang/assert":37,"./../../lang/is":40}],9:[function(require,module,exports){
2219
2300
  'use strict';
2220
2301
 
2221
2302
  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 +2337,7 @@ module.exports = function () {
2256
2337
  * @static
2257
2338
  * @param {Endpoint} endpoint
2258
2339
  * @param {*=} payload
2259
- * @returns {Promise.<Object>}
2340
+ * @returns {Promise<Object>}
2260
2341
  */
2261
2342
 
2262
2343
 
@@ -3388,7 +3469,7 @@ module.exports = function () {
3388
3469
  *
3389
3470
  * @callback Parameter~parameterValueCallback
3390
3471
  * @param {Object} payload
3391
- * @returns {Promise.<String>}
3472
+ * @returns {Promise<String>}
3392
3473
  */
3393
3474
 
3394
3475
  return Parameter;
@@ -3934,7 +4015,7 @@ module.exports = function () {
3934
4015
  * @public
3935
4016
  * @param {Object} error
3936
4017
  * @param {Endpoint} endpoint - The endpoint which is originating the request.
3937
- * @returns {Promise.<TResult>}
4018
+ * @returns {Promise<TResult>}
3938
4019
  */
3939
4020
 
3940
4021
 
@@ -4091,7 +4172,7 @@ module.exports = function () {
4091
4172
  * @public
4092
4173
  * @param {Object} request
4093
4174
  * @param {Endpoint} endpoint - The endpoint which is originating the request.
4094
- * @returns {Promise.<TResult>}
4175
+ * @returns {Promise<TResult>}
4095
4176
  */
4096
4177
 
4097
4178
 
@@ -4242,7 +4323,7 @@ module.exports = function () {
4242
4323
  * @public
4243
4324
  * @param {Object} request
4244
4325
  * @param {Endpoint} endpoint - The endpoint which is originating the request.
4245
- * @returns {Promise.<TResult>}
4326
+ * @returns {Promise<TResult>}
4246
4327
  */
4247
4328
 
4248
4329
 
@@ -4473,7 +4554,7 @@ module.exports = function () {
4473
4554
  *
4474
4555
  * @public
4475
4556
  * @param {*} value - The value of the node.
4476
- * @param {Tree} parent - The parent node. If not supplied, this will be the root node.
4557
+ * @param {Tree=} parent - The parent node. If not supplied, this will be the root node.
4477
4558
  */
4478
4559
 
4479
4560
  var Tree = function () {
@@ -5029,6 +5110,27 @@ module.exports = function () {
5029
5110
  return a.localeCompare(b);
5030
5111
  },
5031
5112
 
5113
+ /**
5114
+ * Compares two boolean values (in ascending order -- false first, true second).
5115
+ *
5116
+ * @static
5117
+ * @param {Boolean} a
5118
+ * @param {Boolean} b
5119
+ * @returns {Number}
5120
+ */
5121
+ compareBooleans: function compareBooleans(a, b) {
5122
+ assert.argumentIsRequired(a, 'a', Boolean);
5123
+ assert.argumentIsRequired(b, 'b', Boolean);
5124
+
5125
+ if (a === b) {
5126
+ return 0;
5127
+ } else if (a) {
5128
+ return 1;
5129
+ } else {
5130
+ return -1;
5131
+ }
5132
+ },
5133
+
5032
5134
  /**
5033
5135
  * Compares two objects, always returning zero.
5034
5136
  *
@@ -5510,6 +5612,32 @@ module.exports = function () {
5510
5612
  return this.addYears(years, true);
5511
5613
  }
5512
5614
 
5615
+ /**
5616
+ * Returns a new {@link Day} instance for the start of the month referenced by the current instance.
5617
+ *
5618
+ * @public
5619
+ * @returns {Day}
5620
+ */
5621
+
5622
+ }, {
5623
+ key: 'getStartOfMonth',
5624
+ value: function getStartOfMonth() {
5625
+ return new Day(this.year, this.month, 1);
5626
+ }
5627
+
5628
+ /**
5629
+ * Returns a new instance for the {@link Day} end of the month referenced by the current instance.
5630
+ *
5631
+ * @public
5632
+ * @returns {Day}
5633
+ */
5634
+
5635
+ }, {
5636
+ key: 'getEndOfMonth',
5637
+ value: function getEndOfMonth() {
5638
+ return new Day(this.year, this.month, Day.getDaysInMonth(this.year, this.month));
5639
+ }
5640
+
5513
5641
  /**
5514
5642
  * Indicates if another {@link Day} occurs before the current instance.
5515
5643
  *
@@ -5671,7 +5799,7 @@ module.exports = function () {
5671
5799
  }
5672
5800
 
5673
5801
  /**
5674
- * Converts a string (which matches the output of {@link Day#format} into
5802
+ * Converts a string (which matches the output of {@link Day#format}) into
5675
5803
  * a {@link Day} instance.
5676
5804
  *
5677
5805
  * @public
@@ -5942,6 +6070,24 @@ module.exports = function () {
5942
6070
  return new Decimal(this._big.div(getBig(other)));
5943
6071
  }
5944
6072
 
6073
+ /**
6074
+ * Returns a new {@link Decimal} instance with a value that results
6075
+ * from raising the current instance to the power of the exponent
6076
+ * provided.
6077
+ *
6078
+ * @public
6079
+ * @param {Decimal|Number|String} exponent
6080
+ * @returns {Decimal}
6081
+ */
6082
+
6083
+ }, {
6084
+ key: 'raise',
6085
+ value: function raise(exponent) {
6086
+ assert.argumentIsRequired(exponent, 'exponent', Number);
6087
+
6088
+ return new Decimal(this._big.pow(exponent));
6089
+ }
6090
+
5945
6091
  /**
5946
6092
  * Returns a new {@link Decimal} with a value resulting from a rounding
5947
6093
  * operation on the current value.
@@ -6106,6 +6252,28 @@ module.exports = function () {
6106
6252
  return this._big.eq(getBig(other));
6107
6253
  }
6108
6254
 
6255
+ /**
6256
+ * Returns true is close to another value.
6257
+ *
6258
+ * @public
6259
+ * @param {Decimal|Number|String} other - The value to compare.
6260
+ * @param {Number} places - The significant digits.
6261
+ * @returns {Boolean}
6262
+ */
6263
+
6264
+ }, {
6265
+ key: 'getIsApproximate',
6266
+ value: function getIsApproximate(other, places) {
6267
+ if (places === 0) {
6268
+ return this.getIsEqual(other);
6269
+ }
6270
+
6271
+ var difference = this.subtract(other).absolute();
6272
+ var tolerance = Decimal.ONE.divide(new Decimal(10).raise(places));
6273
+
6274
+ return difference.getIsLessThan(tolerance);
6275
+ }
6276
+
6109
6277
  /**
6110
6278
  * Returns true if the current instance is an integer (i.e. has no decimal
6111
6279
  * component).
@@ -7478,8 +7646,10 @@ module.exports = function () {
7478
7646
  var returnRef = [];
7479
7647
 
7480
7648
  a.forEach(function (candidate) {
7649
+ var candidateKey = keySelector(candidate);
7650
+
7481
7651
  var exclude = b.some(function (comparison) {
7482
- return keySelector(candidate) === keySelector(comparison);
7652
+ return candidateKey === keySelector(comparison);
7483
7653
  });
7484
7654
 
7485
7655
  if (!exclude) {
@@ -7554,8 +7724,10 @@ module.exports = function () {
7554
7724
  var returnRef = a.slice();
7555
7725
 
7556
7726
  b.forEach(function (candidate) {
7727
+ var candidateKey = keySelector(candidate);
7728
+
7557
7729
  var exclude = returnRef.some(function (comparison) {
7558
- return keySelector(candidate) === keySelector(comparison);
7730
+ return candidateKey === keySelector(comparison);
7559
7731
  });
7560
7732
 
7561
7733
  if (!exclude) {
@@ -7598,8 +7770,10 @@ module.exports = function () {
7598
7770
  var returnRef = [];
7599
7771
 
7600
7772
  a.forEach(function (candidate) {
7773
+ var candidateKey = keySelector(candidate);
7774
+
7601
7775
  var include = b.some(function (comparison) {
7602
- return keySelector(candidate) === comparison;
7776
+ return candidateKey === keySelector(comparison);
7603
7777
  });
7604
7778
 
7605
7779
  if (include) {
@@ -7632,8 +7806,62 @@ module.exports = function () {
7632
7806
  }
7633
7807
 
7634
7808
  return found;
7809
+ },
7810
+
7811
+
7812
+ /**
7813
+ * Inserts an item into an array using a binary search is used to determine the
7814
+ * proper point for insertion and returns the same array.
7815
+ *
7816
+ * @static
7817
+ * @public
7818
+ * @param {Array} a
7819
+ * @param {*} item
7820
+ * @param {Function} comparator
7821
+ * @returns {Array}
7822
+ */
7823
+ insert: function insert(a, item, comparator) {
7824
+ assert.argumentIsArray(a, 'a');
7825
+ assert.argumentIsRequired(comparator, 'comparator', Function);
7826
+
7827
+ if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
7828
+ a.push(item);
7829
+ } else if (comparator(item, a[0]) < 0) {
7830
+ a.unshift(item);
7831
+ } else {
7832
+ a.splice(binarySearch(a, item, comparator, 0, a.length - 1), 0, item);
7833
+ }
7834
+
7835
+ return a;
7635
7836
  }
7636
7837
  };
7838
+
7839
+ function binarySearch(array, item, comparator, start, end) {
7840
+ var size = end - start;
7841
+
7842
+ var midpointIndex = start + Math.floor(size / 2);
7843
+ var midpointItem = array[midpointIndex];
7844
+
7845
+ var comparison = comparator(item, midpointItem) > 0;
7846
+
7847
+ if (size < 2) {
7848
+ if (comparison > 0) {
7849
+ var finalIndex = array.length - 1;
7850
+
7851
+ if (end === finalIndex && comparator(item, array[finalIndex]) > 0) {
7852
+ return end + 1;
7853
+ } else {
7854
+ return end;
7855
+ }
7856
+ } else {
7857
+ return start;
7858
+ }
7859
+ } else if (comparison > 0) {
7860
+ return binarySearch(array, item, comparator, midpointIndex, end);
7861
+ } else {
7862
+ return binarySearch(array, item, comparator, start, midpointIndex);
7863
+ }
7864
+ }
7637
7865
  }();
7638
7866
 
7639
7867
  },{"./assert":37,"./is":40}],37:[function(require,module,exports){
@@ -7849,9 +8077,10 @@ module.exports = function () {
7849
8077
  /**
7850
8078
  * Checks to see if an attribute exists on the target object.
7851
8079
  *
8080
+ * @public
7852
8081
  * @static
7853
8082
  * @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).
8083
+ * @param {String|String[]} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
7855
8084
  * @param {String=} separator - The separator (defaults to a period character).
7856
8085
  * @returns {boolean}
7857
8086
  */
@@ -7875,9 +8104,10 @@ module.exports = function () {
7875
8104
  * Returns a value from the target object. If the property doesn't exist; undefined
7876
8105
  * is returned.
7877
8106
  *
8107
+ * @public
7878
8108
  * @static
7879
8109
  * @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).
8110
+ * @param {String|String[]} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
7881
8111
  * @param {String=} separator - The separator (defaults to a period character).
7882
8112
  * @returns {*}
7883
8113
  */
@@ -7910,9 +8140,10 @@ module.exports = function () {
7910
8140
  /**
7911
8141
  * Writes a value to the target object.
7912
8142
  *
8143
+ * @public
7913
8144
  * @static
7914
8145
  * @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).
8146
+ * @param {String|String[]} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
7916
8147
  * @param {*} value - The value to assign.
7917
8148
  * @param {String=} separator - The separator (defaults to a period character).
7918
8149
  */
@@ -7937,9 +8168,10 @@ module.exports = function () {
7937
8168
  /**
7938
8169
  * Erases a property from the target object.
7939
8170
  *
8171
+ * @public
7940
8172
  * @static
7941
8173
  * @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).
8174
+ * @param {String|String} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
7943
8175
  * @param {String=} separator - The separator (defaults to a period character).
7944
8176
  */
7945
8177
  erase: function erase(target, propertyNames, separator) {
@@ -8089,7 +8321,7 @@ module.exports = function () {
8089
8321
  * @static
8090
8322
  * @public
8091
8323
  * @param {*} candidate
8092
- * @returns {*|boolean}
8324
+ * @returns {boolean}
8093
8325
  */
8094
8326
  negative: function negative(candidate) {
8095
8327
  return this.number(candidate) && candidate < 0;
@@ -8440,10 +8672,12 @@ module.exports = function () {
8440
8672
  * a mapping function, which can return a promise. Then, this function returns a single promise
8441
8673
  * which is the result of each mapped promise.
8442
8674
  *
8675
+ * @public
8676
+ * @static
8443
8677
  * @param {Array} items - The items to map
8444
8678
  * @param {Function} mapper - The mapping function (e.g. given an item, return a promise).
8445
8679
  * @param {Number} concurrency - The maximum number of promises that are allowed to run at once.
8446
- * @returns {Promise.<Array>}
8680
+ * @returns {Promise<Array>}
8447
8681
  */
8448
8682
  map: function map(items, mapper, concurrency) {
8449
8683
  var _this2 = this;
@@ -8530,7 +8764,7 @@ module.exports = function () {
8530
8764
  * @public
8531
8765
  * @param {Function[]} functions - An array of functions, each expecting a single argument.
8532
8766
  * @param input - The argument to pass the first function.
8533
- * @returns {Promise.<TResult>}
8767
+ * @returns {Promise<TResult>}
8534
8768
  */
8535
8769
  pipeline: function pipeline(functions, input) {
8536
8770
  return Promise.resolve().then(function () {
@@ -8552,8 +8786,8 @@ module.exports = function () {
8552
8786
  * is caught and the resulting promise is rejected (instead of letting the
8553
8787
  * error bubble up to the top-level handler).
8554
8788
  *
8555
- * @static
8556
8789
  * @public
8790
+ * @static
8557
8791
  * @param {Function} executor - A function which has two callback parameters. The first is used to resolve the promise, the second rejects it.
8558
8792
  * @returns {Promise}
8559
8793
  */
@@ -8956,6 +9190,20 @@ module.exports = function () {
8956
9190
  return dataTypeObject;
8957
9191
  }
8958
9192
 
9193
+ /**
9194
+ * References an array.
9195
+ *
9196
+ * @public
9197
+ * @static
9198
+ * @returns {DataType}
9199
+ */
9200
+
9201
+ }, {
9202
+ key: 'ARRAY',
9203
+ get: function get() {
9204
+ return dataTypeArray;
9205
+ }
9206
+
8959
9207
  /**
8960
9208
  * References a {@link Decimal} instance.
8961
9209
  *
@@ -9024,6 +9272,7 @@ module.exports = function () {
9024
9272
  var dataTypeNumber = new DataType('Number', null, null, is.number);
9025
9273
  var dataTypeBoolean = new DataType('Boolean', null, null, is.boolean);
9026
9274
  var dataTypeObject = new DataType('Object', null, null, is.object);
9275
+ var dataTypeArray = new DataType('Array', null, null, is.array);
9027
9276
 
9028
9277
  var dataTypeDecimal = new DataType('Decimal', null, function (x) {
9029
9278
  return Decimal.parse(x);
@@ -9046,7 +9295,7 @@ module.exports = function () {
9046
9295
  return x instanceof AdHoc;
9047
9296
  }, getBuilder(buildAdHoc));
9048
9297
 
9049
- var dataTypes = [dataTypeString, dataTypeNumber, dataTypeBoolean, dataTypeObject, dataTypeDecimal, dataTypeDay, dataTypeTimestamp, dataTypeAdHoc];
9298
+ var dataTypes = [dataTypeString, dataTypeNumber, dataTypeBoolean, dataTypeObject, dataTypeArray, dataTypeDecimal, dataTypeDay, dataTypeTimestamp, dataTypeAdHoc];
9050
9299
 
9051
9300
  function getBuilder(builder) {
9052
9301
  return function (data) {
@@ -9916,11 +10165,11 @@ module.exports = function () {
9916
10165
  *
9917
10166
  * @public
9918
10167
  * @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.
10168
+ * @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
10169
  * @param {string=} actionDescription - Description of the action to attempt, used for logging purposes.
9921
10170
  * @param {number=} maximumAttempts - The number of attempts to before giving up.
9922
10171
  * @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.
10172
+ * @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
10173
  * @returns {Promise}
9925
10174
  */
9926
10175
 
@@ -9940,59 +10189,61 @@ module.exports = function () {
9940
10189
  throw new Error('The Scheduler has been disposed.');
9941
10190
  }
9942
10191
 
9943
- var scheduleBackoff = function scheduleBackoff(failureCount, e) {
9944
- if (failureCount > 0 && is.fn(failureCallback)) {
9945
- failureCallback(failureCount);
9946
- }
9947
-
9948
- if (maximumAttempts > 0 && failureCount > maximumAttempts) {
9949
- var message = 'Maximum failures reached for ' + actionDescription;
10192
+ var processAction = function processAction(attempts) {
10193
+ return Promise.resolve().then(function () {
10194
+ var delay = void 0;
9950
10195
 
9951
- var rejection = void 0;
10196
+ if (attempts === 0) {
10197
+ delay = 0;
10198
+ } else {
10199
+ delay = (millisecondDelay || 1000) * Math.pow(2, attempts - 1);
10200
+ }
9952
10201
 
9953
- if (e) {
9954
- e.backoff = message;
10202
+ return _this4.schedule(actionToBackoff, delay, 'Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ]');
10203
+ }).then(function (result) {
10204
+ var resultPromise = void 0;
9955
10205
 
9956
- rejection = e;
10206
+ if (!is.undefined(failureValue) && object.equals(result, failureValue)) {
10207
+ resultPromise = Promise.reject('Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ] failed due to invalid result');
9957
10208
  } else {
9958
- rejection = message;
10209
+ resultPromise = Promise.resolve(result);
9959
10210
  }
9960
10211
 
9961
- return Promise.reject(rejection);
9962
- }
10212
+ return resultPromise;
10213
+ }).catch(function (e) {
10214
+ if (is.fn(failureCallback)) {
10215
+ failureCallback(attempts);
10216
+ }
10217
+
10218
+ return Promise.reject(e);
10219
+ });
10220
+ };
9963
10221
 
9964
- var backoffDelay = void 0;
10222
+ var attempts = 0;
9965
10223
 
9966
- if (failureCount === 0) {
9967
- backoffDelay = millisecondDelay || 0;
9968
- } else {
9969
- backoffDelay = (millisecondDelay || 1000) * Math.pow(2, failureCount);
9970
- }
10224
+ var processActionRecursive = function processActionRecursive() {
10225
+ return processAction(attempts++).catch(function (e) {
10226
+ if (maximumAttempts > 0 && attempts === maximumAttempts) {
10227
+ var message = 'Maximum failures reached for ' + (actionDescription || 'unnamed action');
9971
10228
 
9972
- var successPredicate = void 0;
10229
+ var rejectPromise = void 0;
9973
10230
 
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
- }
10231
+ if (is.object(e)) {
10232
+ e.backoff = message;
9983
10233
 
9984
- return _this4.schedule(actionToBackoff, backoffDelay, (actionDescription || 'unspecified') + ', attempt ' + (failureCount + 1)).then(function (result) {
9985
- if (successPredicate(result)) {
9986
- return result;
10234
+ rejectPromise = Promise.reject(e);
10235
+ } else {
10236
+ rejectPromise = Promise.reject(message);
10237
+ }
10238
+
10239
+ return rejectPromise;
9987
10240
  } else {
9988
- return scheduleBackoff(++failureCount);
10241
+ return processActionRecursive();
9989
10242
  }
9990
- }).catch(function (e) {
9991
- return scheduleBackoff(++failureCount, e);
9992
10243
  });
9993
10244
  };
9994
10245
 
9995
- return scheduleBackoff(0);
10246
+ return processActionRecursive();
9996
10247
  });
9997
10248
  }
9998
10249
  }, {
@@ -10053,9 +10304,10 @@ module.exports = (() => {
10053
10304
  *
10054
10305
  * @public
10055
10306
  * @extends {Enum}
10307
+ * @param {String} code
10056
10308
  * @param {String} description
10057
10309
  * @param {String} alternateDescription
10058
- * @param {String} code
10310
+ * @param {Boolean} canExistEmpty
10059
10311
  * @param {Boolean} canReinvest
10060
10312
  * @param {Boolean} canShort
10061
10313
  * @param {Boolean} canSwitchDirection
@@ -10067,10 +10319,11 @@ module.exports = (() => {
10067
10319
  * @param {Function} generator
10068
10320
  */
10069
10321
  class InstrumentType extends Enum {
10070
- constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
10322
+ constructor(code, description, alternateDescription, canExistEmpty, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
10071
10323
  super(code, description);
10072
10324
 
10073
10325
  assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
10326
+ assert.argumentIsRequired(canExistEmpty, 'canExistEmpty', Boolean);
10074
10327
  assert.argumentIsRequired(canReinvest, 'canReinvest', Boolean);
10075
10328
  assert.argumentIsRequired(canShort, 'canShort', Boolean);
10076
10329
  assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
@@ -10082,6 +10335,8 @@ module.exports = (() => {
10082
10335
  assert.argumentIsRequired(generator, 'generator', Function);
10083
10336
 
10084
10337
  this._alternateDescription = alternateDescription;
10338
+
10339
+ this._canExistEmpty = canExistEmpty;
10085
10340
  this._canReinvest = canReinvest;
10086
10341
  this._canShort = canShort;
10087
10342
  this._canSwitchDirection = canSwitchDirection;
@@ -10104,6 +10359,16 @@ module.exports = (() => {
10104
10359
  return this._alternateDescription;
10105
10360
  }
10106
10361
 
10362
+ /**
10363
+ * Indicates if the position can exist without any associated transactions.
10364
+ *
10365
+ * @public
10366
+ * @returns {Boolean}
10367
+ */
10368
+ get canExistEmpty() {
10369
+ return this._canExistEmpty;
10370
+ }
10371
+
10107
10372
  /**
10108
10373
  * Indicates if the instrument type allows automatic reinvestment.
10109
10374
  *
@@ -10284,10 +10549,10 @@ module.exports = (() => {
10284
10549
  }
10285
10550
  }
10286
10551
 
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()}`);
10552
+ const cash = new InstrumentType('CASH', 'cash', 'Cash', true, false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10553
+ const equity = new InstrumentType('EQUITY', 'equity', 'Equities', false, true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10554
+ 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}`);
10555
+ const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10291
10556
 
10292
10557
  const map = { };
10293
10558
 
@@ -10496,7 +10761,7 @@ module.exports = (() => {
10496
10761
  *
10497
10762
  * @public
10498
10763
  * @param {Number} periods
10499
- * @returns {Array.<PositionSummaryRange>}
10764
+ * @returns {PositionSummaryRange[]}
10500
10765
  */
10501
10766
  getRecentRanges(periods) {
10502
10767
  const startDate = this.getStartDate(periods);
@@ -10509,8 +10774,8 @@ module.exports = (() => {
10509
10774
  * Returns the ranges for the set of {@link Transaction} objects.
10510
10775
  *
10511
10776
  * @public
10512
- * @param {Array.<Transaction>} transactions
10513
- * @returns {Array.<PositionSummaryRange>}
10777
+ * @param {Transaction[]} transactions
10778
+ * @returns {PositionSummaryRange[]}
10514
10779
  */
10515
10780
  getRanges(transactions) {
10516
10781
  assert.argumentIsArray(transactions, 'transactions');
@@ -10523,7 +10788,7 @@ module.exports = (() => {
10523
10788
  *
10524
10789
  * @public
10525
10790
  * @param {Day} date
10526
- * @return {Array.<PositionSummaryRange>}
10791
+ * @return {PositionSummaryRange[]}
10527
10792
  */
10528
10793
  getRangesFromDate(date) {
10529
10794
  assert.argumentIsRequired(date, 'date', Day, 'Day');
@@ -10612,8 +10877,8 @@ module.exports = (() => {
10612
10877
  }
10613
10878
 
10614
10879
  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);
10880
+ const quarterly = new PositionSummaryFrame('QUARTERLY', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10881
+ const monthly = new PositionSummaryFrame('MONTHLY', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10617
10882
  const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
10618
10883
 
10619
10884
  /**
@@ -10673,7 +10938,36 @@ module.exports = (() => {
10673
10938
  }
10674
10939
 
10675
10940
  function getMonthlyRanges(transactions) {
10676
- return [ ];
10941
+ const ranges = [ ];
10942
+
10943
+ if (transactions.length !== 0) {
10944
+ const today = Day.getToday();
10945
+
10946
+ const first = array.first(transactions);
10947
+ const last = array.last(transactions);
10948
+
10949
+ const firstDate = first.date;
10950
+
10951
+ let lastDate;
10952
+
10953
+ if (last.snapshot.open.getIsZero()) {
10954
+ lastDate = last.date;
10955
+ } else {
10956
+ lastDate = today;
10957
+ }
10958
+
10959
+ if (today.month === lastDate.month && today.year === lastDate.year) {
10960
+ lastDate = lastDate.subtractMonths(1);
10961
+ }
10962
+
10963
+ lastDate = lastDate.getEndOfMonth();
10964
+
10965
+ for (let end = firstDate.getEndOfMonth(); !end.getIsAfter(lastDate); end = end.addMonths(1).getEndOfMonth()) {
10966
+ ranges.push(getRange(end.subtractMonths(1).getEndOfMonth(), end));
10967
+ }
10968
+ }
10969
+
10970
+ return ranges;
10677
10971
  }
10678
10972
 
10679
10973
  function getYearToDateRanges(transactions) {
@@ -10710,7 +11004,11 @@ module.exports = (() => {
10710
11004
  }
10711
11005
 
10712
11006
  function getMonthlyStartDate(periods, date) {
10713
- return null;
11007
+ const today = date || Day.getToday();
11008
+
11009
+ return today
11010
+ .subtractMonths(periods)
11011
+ .subtractDays(today.day);
10714
11012
  }
10715
11013
 
10716
11014
  function getYearToDateStartDate(periods, date) {
@@ -10718,7 +11016,7 @@ module.exports = (() => {
10718
11016
  }
10719
11017
 
10720
11018
  function getYearlyRangeDescription(start, end) {
10721
- return `Year ended ${end.year.toString()}`;
11019
+ return `Year ended ${end.format()}`;
10722
11020
  }
10723
11021
 
10724
11022
  function getQuarterlyRangeDescription(start, end) {
@@ -10726,7 +11024,7 @@ module.exports = (() => {
10726
11024
  }
10727
11025
 
10728
11026
  function getMonthlyRangeDescription(start, end) {
10729
- return '';
11027
+ return `Month ended ${end.format()}`;
10730
11028
  }
10731
11029
 
10732
11030
  function getYearToDateRangeDescription(start, end) {
@@ -10771,7 +11069,7 @@ module.exports = (() => {
10771
11069
  * @param {Boolean} corporateAction
10772
11070
  * @param {Boolean} initial
10773
11071
  * @param {Boolean} significant
10774
- * @param {Boolean} eod
11072
+ * @param {Boolean} system
10775
11073
  */
10776
11074
  class TransactionType extends Enum {
10777
11075
  constructor(code, description, display, sequence, purchase, sale, income, opening, closing, fee, corporateAction, initial, significant) {
@@ -11101,6 +11399,17 @@ module.exports = (() => {
11101
11399
  static get DEBIT() {
11102
11400
  return debit;
11103
11401
  }
11402
+
11403
+ /**
11404
+ * A system-generated transaction, indicating the security has stopped active trading.
11405
+ *
11406
+ * @public
11407
+ * @static
11408
+ * @returns {TransactionType}
11409
+ */
11410
+ static get DELIST() {
11411
+ return delist;
11412
+ }
11104
11413
 
11105
11414
  /**
11106
11415
  * A system-generated deposit, arising from another transaction.
@@ -11150,6 +11459,7 @@ module.exports = (() => {
11150
11459
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
11151
11460
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
11152
11461
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', 0, false, false, false, false, true, false, false, false, false);
11462
+ const delist = new TransactionType('DL', 'Delist', 'Delist', 1, false, false, false, false, false, false, true, false, false);
11153
11463
 
11154
11464
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
11155
11465
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -11785,6 +12095,10 @@ module.exports = (() => {
11785
12095
  static get VALUATION() {
11786
12096
  return valuation;
11787
12097
  }
12098
+
12099
+ static get DELIST() {
12100
+ return delist;
12101
+ }
11788
12102
 
11789
12103
  static get INCOME() {
11790
12104
  return income;
@@ -11989,12 +12303,23 @@ module.exports = (() => {
11989
12303
  .withField('sequence', DataType.NUMBER, true)
11990
12304
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
11991
12305
  .withField('date', DataType.DAY)
11992
- .withField('value', DataType.DECIMAL)
12306
+ .withField('rate', DataType.DECIMAL, true)
12307
+ .withField('value', DataType.DECIMAL, true)
11993
12308
  .withField('force', DataType.BOOLEAN, true)
11994
12309
  .schema
11995
12310
  );
11996
-
11997
- const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
12311
+
12312
+ const delist = new TransactionSchema(SchemaBuilder.withName(TransactionType.DELIST.code)
12313
+ .withField('portfolio', DataType.STRING)
12314
+ .withField('position', DataType.STRING)
12315
+ .withField('sequence', DataType.NUMBER, true)
12316
+ .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
12317
+ .withField('date', DataType.DAY)
12318
+ .withField('force', DataType.BOOLEAN, true)
12319
+ .schema
12320
+ );
12321
+
12322
+ const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
11998
12323
  .withField('portfolio', DataType.STRING)
11999
12324
  .withField('position', DataType.STRING)
12000
12325
  .withField('sequence', DataType.NUMBER, true)
@@ -12020,6 +12345,7 @@ module.exports = (() => {
12020
12345
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
12021
12346
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
12022
12347
  addSchemaToMap(TransactionType.VALUATION, valuation);
12348
+ addSchemaToMap(TransactionType.DELIST, delist);
12023
12349
  addSchemaToMap(TransactionType.INCOME, income);
12024
12350
 
12025
12351
  return TransactionSchema;
@@ -12152,7 +12478,7 @@ module.exports = function () {
12152
12478
  * containing the current instance
12153
12479
  *
12154
12480
  * @public
12155
- * @returns {Promise.<JwtGateway>}
12481
+ * @returns {Promise<JwtGateway>}
12156
12482
  */
12157
12483
 
12158
12484
 
@@ -12182,7 +12508,7 @@ module.exports = function () {
12182
12508
  * Retrieves a JWT token from the remote server.
12183
12509
  *
12184
12510
  * @public
12185
- * @returns {Promise.<String>}
12511
+ * @returns {Promise<String>}
12186
12512
  */
12187
12513
 
12188
12514
  }, {
@@ -12222,7 +12548,7 @@ module.exports = function () {
12222
12548
  var refreshToken = function refreshToken() {
12223
12549
  var refreshPromise = scheduler.backoff(function () {
12224
12550
  return _this4.readToken();
12225
- }, 100, 'Read JWT token', 3).then(function (token) {
12551
+ }, 750, 'Read JWT token', 3).then(function (token) {
12226
12552
  if (_this4._refreshInterval > 0) {
12227
12553
  cachePromise = refreshPromise;
12228
12554
 
@@ -12290,8 +12616,8 @@ module.exports = function () {
12290
12616
  *
12291
12617
  * @public
12292
12618
  * @static
12293
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12294
- * @returns {Promise.<JwtGateway>}
12619
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12620
+ * @returns {Promise<JwtGateway>}
12295
12621
  */
12296
12622
 
12297
12623
  }, {
@@ -12319,8 +12645,8 @@ module.exports = function () {
12319
12645
  *
12320
12646
  * @public
12321
12647
  * @static
12322
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12323
- * @returns {Promise.<RequestInterceptor>}
12648
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12649
+ * @returns {Promise<RequestInterceptor>}
12324
12650
  */
12325
12651
 
12326
12652
  }, {
@@ -12336,7 +12662,7 @@ module.exports = function () {
12336
12662
  *
12337
12663
  * @public
12338
12664
  * @static
12339
- * @returns {Promise.<JwtGateway>}
12665
+ * @returns {Promise<JwtGateway>}
12340
12666
  */
12341
12667
 
12342
12668
  }, {
@@ -12350,7 +12676,7 @@ module.exports = function () {
12350
12676
  *
12351
12677
  * @public
12352
12678
  * @static
12353
- * @returns {Promise.<RequestInterceptor>}
12679
+ * @returns {Promise<RequestInterceptor>}
12354
12680
  */
12355
12681
 
12356
12682
  }, {
@@ -12366,7 +12692,7 @@ module.exports = function () {
12366
12692
  *
12367
12693
  * @public
12368
12694
  * @static
12369
- * @returns {Promise.<JwtGateway>}
12695
+ * @returns {Promise<JwtGateway>}
12370
12696
  */
12371
12697
 
12372
12698
  }, {
@@ -12380,7 +12706,7 @@ module.exports = function () {
12380
12706
  *
12381
12707
  * @public
12382
12708
  * @static
12383
- * @returns {Promise.<RequestInterceptor>}
12709
+ * @returns {Promise<RequestInterceptor>}
12384
12710
  */
12385
12711
 
12386
12712
  }, {
@@ -12397,7 +12723,7 @@ module.exports = function () {
12397
12723
  * @public
12398
12724
  * @static
12399
12725
  * @param {Function} tokenGenerator - A function which returns the JWT token.
12400
- * @returns {Promise.<JwtGateway>}
12726
+ * @returns {Promise<JwtGateway>}
12401
12727
  */
12402
12728
 
12403
12729
  }, {
@@ -12414,7 +12740,7 @@ module.exports = function () {
12414
12740
  * @public
12415
12741
  * @static
12416
12742
  * @param {JwtGateway~tokenGenerator} tokenGenerator - A function which returns the JWT token.
12417
- * @returns {Promise.<RequestInterceptor>}
12743
+ * @returns {Promise<RequestInterceptor>}
12418
12744
  */
12419
12745
 
12420
12746
  }, {
@@ -12477,7 +12803,7 @@ module.exports = function () {
12477
12803
  * A function returns a JWT token (or a promise for a JWT token).
12478
12804
  *
12479
12805
  * @callback JwtGateway~tokenGenerator
12480
- * @returns {String|Promise.<String>}
12806
+ * @returns {String|Promise<String>}
12481
12807
  */
12482
12808
 
12483
12809
  return JwtGateway;
@@ -12490,14 +12816,13 @@ module.exports = function () {
12490
12816
  'use strict';
12491
12817
 
12492
12818
  return {
12493
- version: '1.0.42'
12819
+ version: '1.3.3'
12494
12820
  };
12495
12821
  }();
12496
12822
 
12497
12823
  },{}],63:[function(require,module,exports){
12498
12824
  module.exports = require('./lib/axios');
12499
12825
  },{"./lib/axios":65}],64:[function(require,module,exports){
12500
- (function (process){
12501
12826
  'use strict';
12502
12827
 
12503
12828
  var utils = require('./../utils');
@@ -12506,7 +12831,6 @@ var buildURL = require('./../helpers/buildURL');
12506
12831
  var parseHeaders = require('./../helpers/parseHeaders');
12507
12832
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
12508
12833
  var createError = require('../core/createError');
12509
- var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
12510
12834
 
12511
12835
  module.exports = function xhrAdapter(config) {
12512
12836
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -12518,22 +12842,6 @@ module.exports = function xhrAdapter(config) {
12518
12842
  }
12519
12843
 
12520
12844
  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
12845
 
12538
12846
  // HTTP basic authentication
12539
12847
  if (config.auth) {
@@ -12548,8 +12856,8 @@ module.exports = function xhrAdapter(config) {
12548
12856
  request.timeout = config.timeout;
12549
12857
 
12550
12858
  // Listen for ready state
12551
- request[loadEvent] = function handleLoad() {
12552
- if (!request || (request.readyState !== 4 && !xDomain)) {
12859
+ request.onreadystatechange = function handleLoad() {
12860
+ if (!request || request.readyState !== 4) {
12553
12861
  return;
12554
12862
  }
12555
12863
 
@@ -12566,9 +12874,8 @@ module.exports = function xhrAdapter(config) {
12566
12874
  var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
12567
12875
  var response = {
12568
12876
  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,
12877
+ status: request.status,
12878
+ statusText: request.statusText,
12572
12879
  headers: responseHeaders,
12573
12880
  config: config,
12574
12881
  request: request
@@ -12580,6 +12887,18 @@ module.exports = function xhrAdapter(config) {
12580
12887
  request = null;
12581
12888
  };
12582
12889
 
12890
+ // Handle browser request cancellation (as opposed to a manual cancellation)
12891
+ request.onabort = function handleAbort() {
12892
+ if (!request) {
12893
+ return;
12894
+ }
12895
+
12896
+ reject(createError('Request aborted', config, 'ECONNABORTED', request));
12897
+
12898
+ // Clean up request
12899
+ request = null;
12900
+ };
12901
+
12583
12902
  // Handle low level network errors
12584
12903
  request.onerror = function handleError() {
12585
12904
  // Real errors are hidden from us by the browser
@@ -12607,8 +12926,8 @@ module.exports = function xhrAdapter(config) {
12607
12926
 
12608
12927
  // Add xsrf header
12609
12928
  var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
12610
- cookies.read(config.xsrfCookieName) :
12611
- undefined;
12929
+ cookies.read(config.xsrfCookieName) :
12930
+ undefined;
12612
12931
 
12613
12932
  if (xsrfValue) {
12614
12933
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
@@ -12679,13 +12998,13 @@ module.exports = function xhrAdapter(config) {
12679
12998
  });
12680
12999
  };
12681
13000
 
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){
13001
+ },{"../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
13002
  'use strict';
12685
13003
 
12686
13004
  var utils = require('./utils');
12687
13005
  var bind = require('./helpers/bind');
12688
13006
  var Axios = require('./core/Axios');
13007
+ var mergeConfig = require('./core/mergeConfig');
12689
13008
  var defaults = require('./defaults');
12690
13009
 
12691
13010
  /**
@@ -12715,7 +13034,7 @@ axios.Axios = Axios;
12715
13034
 
12716
13035
  // Factory for creating new instances
12717
13036
  axios.create = function create(instanceConfig) {
12718
- return createInstance(utils.merge(defaults, instanceConfig));
13037
+ return createInstance(mergeConfig(axios.defaults, instanceConfig));
12719
13038
  };
12720
13039
 
12721
13040
  // Expose Cancel & CancelToken
@@ -12734,7 +13053,7 @@ module.exports = axios;
12734
13053
  // Allow use of default import syntax in TypeScript
12735
13054
  module.exports.default = axios;
12736
13055
 
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){
13056
+ },{"./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
13057
  'use strict';
12739
13058
 
12740
13059
  /**
@@ -12824,10 +13143,11 @@ module.exports = function isCancel(value) {
12824
13143
  },{}],69:[function(require,module,exports){
12825
13144
  'use strict';
12826
13145
 
12827
- var defaults = require('./../defaults');
12828
13146
  var utils = require('./../utils');
13147
+ var buildURL = require('../helpers/buildURL');
12829
13148
  var InterceptorManager = require('./InterceptorManager');
12830
13149
  var dispatchRequest = require('./dispatchRequest');
13150
+ var mergeConfig = require('./mergeConfig');
12831
13151
 
12832
13152
  /**
12833
13153
  * Create a new instance of Axios
@@ -12851,13 +13171,14 @@ Axios.prototype.request = function request(config) {
12851
13171
  /*eslint no-param-reassign:0*/
12852
13172
  // Allow for axios('example/url'[, config]) a la fetch API
12853
13173
  if (typeof config === 'string') {
12854
- config = utils.merge({
12855
- url: arguments[0]
12856
- }, arguments[1]);
13174
+ config = arguments[1] || {};
13175
+ config.url = arguments[0];
13176
+ } else {
13177
+ config = config || {};
12857
13178
  }
12858
13179
 
12859
- config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
12860
- config.method = config.method.toLowerCase();
13180
+ config = mergeConfig(this.defaults, config);
13181
+ config.method = config.method ? config.method.toLowerCase() : 'get';
12861
13182
 
12862
13183
  // Hook up interceptors middleware
12863
13184
  var chain = [dispatchRequest, undefined];
@@ -12878,6 +13199,11 @@ Axios.prototype.request = function request(config) {
12878
13199
  return promise;
12879
13200
  };
12880
13201
 
13202
+ Axios.prototype.getUri = function getUri(config) {
13203
+ config = mergeConfig(this.defaults, config);
13204
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
13205
+ };
13206
+
12881
13207
  // Provide aliases for supported request methods
12882
13208
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
12883
13209
  /*eslint func-names:0*/
@@ -12902,7 +13228,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
12902
13228
 
12903
13229
  module.exports = Axios;
12904
13230
 
12905
- },{"./../defaults":76,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72}],70:[function(require,module,exports){
13231
+ },{"../helpers/buildURL":79,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72,"./mergeConfig":74}],70:[function(require,module,exports){
12906
13232
  'use strict';
12907
13233
 
12908
13234
  var utils = require('./../utils');
@@ -13064,7 +13390,7 @@ module.exports = function dispatchRequest(config) {
13064
13390
  });
13065
13391
  };
13066
13392
 
13067
- },{"../cancel/isCancel":68,"../defaults":76,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":75}],73:[function(require,module,exports){
13393
+ },{"../cancel/isCancel":68,"../defaults":77,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":76}],73:[function(require,module,exports){
13068
13394
  'use strict';
13069
13395
 
13070
13396
  /**
@@ -13082,14 +13408,88 @@ module.exports = function enhanceError(error, config, code, request, response) {
13082
13408
  if (code) {
13083
13409
  error.code = code;
13084
13410
  }
13411
+
13085
13412
  error.request = request;
13086
13413
  error.response = response;
13414
+ error.isAxiosError = true;
13415
+
13416
+ error.toJSON = function() {
13417
+ return {
13418
+ // Standard
13419
+ message: this.message,
13420
+ name: this.name,
13421
+ // Microsoft
13422
+ description: this.description,
13423
+ number: this.number,
13424
+ // Mozilla
13425
+ fileName: this.fileName,
13426
+ lineNumber: this.lineNumber,
13427
+ columnNumber: this.columnNumber,
13428
+ stack: this.stack,
13429
+ // Axios
13430
+ config: this.config,
13431
+ code: this.code
13432
+ };
13433
+ };
13087
13434
  return error;
13088
13435
  };
13089
13436
 
13090
13437
  },{}],74:[function(require,module,exports){
13091
13438
  'use strict';
13092
13439
 
13440
+ var utils = require('../utils');
13441
+
13442
+ /**
13443
+ * Config-specific merge-function which creates a new config-object
13444
+ * by merging two configuration objects together.
13445
+ *
13446
+ * @param {Object} config1
13447
+ * @param {Object} config2
13448
+ * @returns {Object} New object resulting from merging config2 to config1
13449
+ */
13450
+ module.exports = function mergeConfig(config1, config2) {
13451
+ // eslint-disable-next-line no-param-reassign
13452
+ config2 = config2 || {};
13453
+ var config = {};
13454
+
13455
+ utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
13456
+ if (typeof config2[prop] !== 'undefined') {
13457
+ config[prop] = config2[prop];
13458
+ }
13459
+ });
13460
+
13461
+ utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
13462
+ if (utils.isObject(config2[prop])) {
13463
+ config[prop] = utils.deepMerge(config1[prop], config2[prop]);
13464
+ } else if (typeof config2[prop] !== 'undefined') {
13465
+ config[prop] = config2[prop];
13466
+ } else if (utils.isObject(config1[prop])) {
13467
+ config[prop] = utils.deepMerge(config1[prop]);
13468
+ } else if (typeof config1[prop] !== 'undefined') {
13469
+ config[prop] = config1[prop];
13470
+ }
13471
+ });
13472
+
13473
+ utils.forEach([
13474
+ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
13475
+ 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
13476
+ 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
13477
+ 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
13478
+ 'socketPath'
13479
+ ], function defaultToConfig2(prop) {
13480
+ if (typeof config2[prop] !== 'undefined') {
13481
+ config[prop] = config2[prop];
13482
+ } else if (typeof config1[prop] !== 'undefined') {
13483
+ config[prop] = config1[prop];
13484
+ }
13485
+ });
13486
+
13487
+ return config;
13488
+ };
13489
+
13490
+ },{"../utils":87}],75:[function(require,module,exports){
13491
+ 'use strict';
13492
+
13093
13493
  var createError = require('./createError');
13094
13494
 
13095
13495
  /**
@@ -13101,8 +13501,7 @@ var createError = require('./createError');
13101
13501
  */
13102
13502
  module.exports = function settle(resolve, reject, response) {
13103
13503
  var validateStatus = response.config.validateStatus;
13104
- // Note: status is not exposed by XDomainRequest
13105
- if (!response.status || !validateStatus || validateStatus(response.status)) {
13504
+ if (!validateStatus || validateStatus(response.status)) {
13106
13505
  resolve(response);
13107
13506
  } else {
13108
13507
  reject(createError(
@@ -13115,7 +13514,7 @@ module.exports = function settle(resolve, reject, response) {
13115
13514
  }
13116
13515
  };
13117
13516
 
13118
- },{"./createError":71}],75:[function(require,module,exports){
13517
+ },{"./createError":71}],76:[function(require,module,exports){
13119
13518
  'use strict';
13120
13519
 
13121
13520
  var utils = require('./../utils');
@@ -13137,7 +13536,7 @@ module.exports = function transformData(data, headers, fns) {
13137
13536
  return data;
13138
13537
  };
13139
13538
 
13140
- },{"./../utils":87}],76:[function(require,module,exports){
13539
+ },{"./../utils":87}],77:[function(require,module,exports){
13141
13540
  (function (process){
13142
13541
  'use strict';
13143
13542
 
@@ -13156,12 +13555,13 @@ function setContentTypeIfUnset(headers, value) {
13156
13555
 
13157
13556
  function getDefaultAdapter() {
13158
13557
  var adapter;
13159
- if (typeof XMLHttpRequest !== 'undefined') {
13160
- // For browsers use XHR adapter
13161
- adapter = require('./adapters/xhr');
13162
- } else if (typeof process !== 'undefined') {
13558
+ // Only Node.JS has a process variable that is of [[Class]] process
13559
+ if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
13163
13560
  // For node use HTTP adapter
13164
13561
  adapter = require('./adapters/http');
13562
+ } else if (typeof XMLHttpRequest !== 'undefined') {
13563
+ // For browsers use XHR adapter
13564
+ adapter = require('./adapters/xhr');
13165
13565
  }
13166
13566
  return adapter;
13167
13567
  }
@@ -13170,6 +13570,7 @@ var defaults = {
13170
13570
  adapter: getDefaultAdapter(),
13171
13571
 
13172
13572
  transformRequest: [function transformRequest(data, headers) {
13573
+ normalizeHeaderName(headers, 'Accept');
13173
13574
  normalizeHeaderName(headers, 'Content-Type');
13174
13575
  if (utils.isFormData(data) ||
13175
13576
  utils.isArrayBuffer(data) ||
@@ -13204,6 +13605,10 @@ var defaults = {
13204
13605
  return data;
13205
13606
  }],
13206
13607
 
13608
+ /**
13609
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
13610
+ * timeout is not created.
13611
+ */
13207
13612
  timeout: 0,
13208
13613
 
13209
13614
  xsrfCookieName: 'XSRF-TOKEN',
@@ -13233,7 +13638,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
13233
13638
  module.exports = defaults;
13234
13639
 
13235
13640
  }).call(this,require('_process'))
13236
- },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],77:[function(require,module,exports){
13641
+ },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],78:[function(require,module,exports){
13237
13642
  'use strict';
13238
13643
 
13239
13644
  module.exports = function bind(fn, thisArg) {
@@ -13246,44 +13651,6 @@ module.exports = function bind(fn, thisArg) {
13246
13651
  };
13247
13652
  };
13248
13653
 
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
13654
  },{}],79:[function(require,module,exports){
13288
13655
  'use strict';
13289
13656
 
@@ -13328,9 +13695,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13328
13695
 
13329
13696
  if (utils.isArray(val)) {
13330
13697
  key = key + '[]';
13331
- }
13332
-
13333
- if (!utils.isArray(val)) {
13698
+ } else {
13334
13699
  val = [val];
13335
13700
  }
13336
13701
 
@@ -13348,6 +13713,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13348
13713
  }
13349
13714
 
13350
13715
  if (serializedParams) {
13716
+ var hashmarkIndex = url.indexOf('#');
13717
+ if (hashmarkIndex !== -1) {
13718
+ url = url.slice(0, hashmarkIndex);
13719
+ }
13720
+
13351
13721
  url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
13352
13722
  }
13353
13723
 
@@ -13379,50 +13749,50 @@ module.exports = (
13379
13749
  utils.isStandardBrowserEnv() ?
13380
13750
 
13381
13751
  // 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));
13752
+ (function standardBrowserEnv() {
13753
+ return {
13754
+ write: function write(name, value, expires, path, domain, secure) {
13755
+ var cookie = [];
13756
+ cookie.push(name + '=' + encodeURIComponent(value));
13387
13757
 
13388
- if (utils.isNumber(expires)) {
13389
- cookie.push('expires=' + new Date(expires).toGMTString());
13390
- }
13758
+ if (utils.isNumber(expires)) {
13759
+ cookie.push('expires=' + new Date(expires).toGMTString());
13760
+ }
13391
13761
 
13392
- if (utils.isString(path)) {
13393
- cookie.push('path=' + path);
13394
- }
13762
+ if (utils.isString(path)) {
13763
+ cookie.push('path=' + path);
13764
+ }
13395
13765
 
13396
- if (utils.isString(domain)) {
13397
- cookie.push('domain=' + domain);
13398
- }
13766
+ if (utils.isString(domain)) {
13767
+ cookie.push('domain=' + domain);
13768
+ }
13399
13769
 
13400
- if (secure === true) {
13401
- cookie.push('secure');
13402
- }
13770
+ if (secure === true) {
13771
+ cookie.push('secure');
13772
+ }
13403
13773
 
13404
- document.cookie = cookie.join('; ');
13405
- },
13774
+ document.cookie = cookie.join('; ');
13775
+ },
13406
13776
 
13407
- read: function read(name) {
13408
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13409
- return (match ? decodeURIComponent(match[3]) : null);
13410
- },
13777
+ read: function read(name) {
13778
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13779
+ return (match ? decodeURIComponent(match[3]) : null);
13780
+ },
13411
13781
 
13412
- remove: function remove(name) {
13413
- this.write(name, '', Date.now() - 86400000);
13414
- }
13415
- };
13416
- })() :
13782
+ remove: function remove(name) {
13783
+ this.write(name, '', Date.now() - 86400000);
13784
+ }
13785
+ };
13786
+ })() :
13417
13787
 
13418
13788
  // 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
- })()
13789
+ (function nonStandardBrowserEnv() {
13790
+ return {
13791
+ write: function write() {},
13792
+ read: function read() { return null; },
13793
+ remove: function remove() {}
13794
+ };
13795
+ })()
13426
13796
  );
13427
13797
 
13428
13798
  },{"./../utils":87}],82:[function(require,module,exports){
@@ -13451,64 +13821,64 @@ module.exports = (
13451
13821
 
13452
13822
  // Standard browser envs have full support of the APIs needed to test
13453
13823
  // 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;
13824
+ (function standardBrowserEnv() {
13825
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
13826
+ var urlParsingNode = document.createElement('a');
13827
+ var originURL;
13458
13828
 
13459
- /**
13829
+ /**
13460
13830
  * Parse a URL to discover it's components
13461
13831
  *
13462
13832
  * @param {String} url The URL to be parsed
13463
13833
  * @returns {Object}
13464
13834
  */
13465
- function resolveURL(url) {
13466
- var href = url;
13835
+ function resolveURL(url) {
13836
+ var href = url;
13467
13837
 
13468
- if (msie) {
13838
+ if (msie) {
13469
13839
  // IE needs attribute set twice to normalize properties
13470
- urlParsingNode.setAttribute('href', href);
13471
- href = urlParsingNode.href;
13472
- }
13840
+ urlParsingNode.setAttribute('href', href);
13841
+ href = urlParsingNode.href;
13842
+ }
13473
13843
 
13474
- urlParsingNode.setAttribute('href', href);
13844
+ urlParsingNode.setAttribute('href', href);
13475
13845
 
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
- }
13846
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13847
+ return {
13848
+ href: urlParsingNode.href,
13849
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13850
+ host: urlParsingNode.host,
13851
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13852
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13853
+ hostname: urlParsingNode.hostname,
13854
+ port: urlParsingNode.port,
13855
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13856
+ urlParsingNode.pathname :
13857
+ '/' + urlParsingNode.pathname
13858
+ };
13859
+ }
13490
13860
 
13491
- originURL = resolveURL(window.location.href);
13861
+ originURL = resolveURL(window.location.href);
13492
13862
 
13493
- /**
13863
+ /**
13494
13864
  * Determine if a URL shares the same origin as the current location
13495
13865
  *
13496
13866
  * @param {String} requestURL The URL to test
13497
13867
  * @returns {boolean} True if URL shares the same origin, otherwise false
13498
13868
  */
13499
- return function isURLSameOrigin(requestURL) {
13500
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13501
- return (parsed.protocol === originURL.protocol &&
13869
+ return function isURLSameOrigin(requestURL) {
13870
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13871
+ return (parsed.protocol === originURL.protocol &&
13502
13872
  parsed.host === originURL.host);
13503
- };
13504
- })() :
13873
+ };
13874
+ })() :
13505
13875
 
13506
13876
  // Non standard browser envs (web workers, react-native) lack needed support.
13507
- (function nonStandardBrowserEnv() {
13508
- return function isURLSameOrigin() {
13509
- return true;
13510
- };
13511
- })()
13877
+ (function nonStandardBrowserEnv() {
13878
+ return function isURLSameOrigin() {
13879
+ return true;
13880
+ };
13881
+ })()
13512
13882
  );
13513
13883
 
13514
13884
  },{"./../utils":87}],84:[function(require,module,exports){
@@ -13789,9 +14159,13 @@ function trim(str) {
13789
14159
  *
13790
14160
  * react-native:
13791
14161
  * navigator.product -> 'ReactNative'
14162
+ * nativescript
14163
+ * navigator.product -> 'NativeScript' or 'NS'
13792
14164
  */
13793
14165
  function isStandardBrowserEnv() {
13794
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
14166
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
14167
+ navigator.product === 'NativeScript' ||
14168
+ navigator.product === 'NS')) {
13795
14169
  return false;
13796
14170
  }
13797
14171
  return (
@@ -13872,6 +14246,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
13872
14246
  return result;
13873
14247
  }
13874
14248
 
14249
+ /**
14250
+ * Function equal to merge with the difference being that no reference
14251
+ * to original objects is kept.
14252
+ *
14253
+ * @see merge
14254
+ * @param {Object} obj1 Object to merge
14255
+ * @returns {Object} Result of all merge properties
14256
+ */
14257
+ function deepMerge(/* obj1, obj2, obj3, ... */) {
14258
+ var result = {};
14259
+ function assignValue(val, key) {
14260
+ if (typeof result[key] === 'object' && typeof val === 'object') {
14261
+ result[key] = deepMerge(result[key], val);
14262
+ } else if (typeof val === 'object') {
14263
+ result[key] = deepMerge({}, val);
14264
+ } else {
14265
+ result[key] = val;
14266
+ }
14267
+ }
14268
+
14269
+ for (var i = 0, l = arguments.length; i < l; i++) {
14270
+ forEach(arguments[i], assignValue);
14271
+ }
14272
+ return result;
14273
+ }
14274
+
13875
14275
  /**
13876
14276
  * Extends object a by mutably adding to it the properties of object b.
13877
14277
  *
@@ -13910,11 +14310,12 @@ module.exports = {
13910
14310
  isStandardBrowserEnv: isStandardBrowserEnv,
13911
14311
  forEach: forEach,
13912
14312
  merge: merge,
14313
+ deepMerge: deepMerge,
13913
14314
  extend: extend,
13914
14315
  trim: trim
13915
14316
  };
13916
14317
 
13917
- },{"./helpers/bind":77,"is-buffer":90}],88:[function(require,module,exports){
14318
+ },{"./helpers/bind":78,"is-buffer":90}],88:[function(require,module,exports){
13918
14319
  /*
13919
14320
  * big.js v5.0.3
13920
14321
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -15049,19 +15450,9 @@ process.umask = function() { return 0; };
15049
15450
  * @license MIT
15050
15451
  */
15051
15452
 
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))
15453
+ module.exports = function isBuffer (obj) {
15454
+ return obj != null && obj.constructor != null &&
15455
+ typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
15065
15456
  }
15066
15457
 
15067
15458
  },{}],91:[function(require,module,exports){
@@ -18618,22 +19009,36 @@ moment.tz.load(require('./data/packed/latest.json'));
18618
19009
  function createDate (y, m, d, h, M, s, ms) {
18619
19010
  // can't just apply() to create a date:
18620
19011
  // https://stackoverflow.com/q/181348
18621
- var date = new Date(y, m, d, h, M, s, ms);
18622
-
19012
+ var date;
18623
19013
  // the date constructor remaps years 0-99 to 1900-1999
18624
- if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
18625
- date.setFullYear(y);
19014
+ if (y < 100 && y >= 0) {
19015
+ // preserve leap years using a full 400 year cycle, then reset
19016
+ date = new Date(y + 400, m, d, h, M, s, ms);
19017
+ if (isFinite(date.getFullYear())) {
19018
+ date.setFullYear(y);
19019
+ }
19020
+ } else {
19021
+ date = new Date(y, m, d, h, M, s, ms);
18626
19022
  }
19023
+
18627
19024
  return date;
18628
19025
  }
18629
19026
 
18630
19027
  function createUTCDate (y) {
18631
- var date = new Date(Date.UTC.apply(null, arguments));
18632
-
19028
+ var date;
18633
19029
  // the Date.UTC function remaps years 0-99 to 1900-1999
18634
- if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
18635
- date.setUTCFullYear(y);
19030
+ if (y < 100 && y >= 0) {
19031
+ var args = Array.prototype.slice.call(arguments);
19032
+ // preserve leap years using a full 400 year cycle, then reset
19033
+ args[0] = y + 400;
19034
+ date = new Date(Date.UTC.apply(null, args));
19035
+ if (isFinite(date.getUTCFullYear())) {
19036
+ date.setUTCFullYear(y);
19037
+ }
19038
+ } else {
19039
+ date = new Date(Date.UTC.apply(null, arguments));
18636
19040
  }
19041
+
18637
19042
  return date;
18638
19043
  }
18639
19044
 
@@ -18735,7 +19140,7 @@ moment.tz.load(require('./data/packed/latest.json'));
18735
19140
 
18736
19141
  var defaultLocaleWeek = {
18737
19142
  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.
19143
+ doy : 6 // The week that contains Jan 6th is the first week of the year.
18739
19144
  };
18740
19145
 
18741
19146
  function localeFirstDayOfWeek () {
@@ -18844,25 +19249,28 @@ moment.tz.load(require('./data/packed/latest.json'));
18844
19249
  }
18845
19250
 
18846
19251
  // LOCALES
19252
+ function shiftWeekdays (ws, n) {
19253
+ return ws.slice(n, 7).concat(ws.slice(0, n));
19254
+ }
18847
19255
 
18848
19256
  var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
18849
19257
  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()];
19258
+ var weekdays = isArray(this._weekdays) ? this._weekdays :
19259
+ this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
19260
+ return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
19261
+ : (m) ? weekdays[m.day()] : weekdays;
18856
19262
  }
18857
19263
 
18858
19264
  var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
18859
19265
  function localeWeekdaysShort (m) {
18860
- return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
19266
+ return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
19267
+ : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
18861
19268
  }
18862
19269
 
18863
19270
  var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
18864
19271
  function localeWeekdaysMin (m) {
18865
- return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
19272
+ return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
19273
+ : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
18866
19274
  }
18867
19275
 
18868
19276
  function handleStrictParse$1(weekdayName, format, strict) {
@@ -19611,13 +20019,13 @@ moment.tz.load(require('./data/packed/latest.json'));
19611
20019
  weekdayOverflow = true;
19612
20020
  }
19613
20021
  } else if (w.e != null) {
19614
- // local weekday -- counting starts from begining of week
20022
+ // local weekday -- counting starts from beginning of week
19615
20023
  weekday = w.e + dow;
19616
20024
  if (w.e < 0 || w.e > 6) {
19617
20025
  weekdayOverflow = true;
19618
20026
  }
19619
20027
  } else {
19620
- // default to begining of week
20028
+ // default to beginning of week
19621
20029
  weekday = dow;
19622
20030
  }
19623
20031
  }
@@ -20211,7 +20619,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20211
20619
  years = normalizedInput.year || 0,
20212
20620
  quarters = normalizedInput.quarter || 0,
20213
20621
  months = normalizedInput.month || 0,
20214
- weeks = normalizedInput.week || 0,
20622
+ weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
20215
20623
  days = normalizedInput.day || 0,
20216
20624
  hours = normalizedInput.hour || 0,
20217
20625
  minutes = normalizedInput.minute || 0,
@@ -20515,7 +20923,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20515
20923
  ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
20516
20924
  };
20517
20925
  } else if (!!(match = isoRegex.exec(input))) {
20518
- sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
20926
+ sign = (match[1] === '-') ? -1 : 1;
20519
20927
  duration = {
20520
20928
  y : parseIso(match[2], sign),
20521
20929
  M : parseIso(match[3], sign),
@@ -20557,7 +20965,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20557
20965
  }
20558
20966
 
20559
20967
  function positiveMomentsDifference(base, other) {
20560
- var res = {milliseconds: 0, months: 0};
20968
+ var res = {};
20561
20969
 
20562
20970
  res.months = other.month() - base.month() +
20563
20971
  (other.year() - base.year()) * 12;
@@ -20666,7 +21074,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20666
21074
  if (!(this.isValid() && localInput.isValid())) {
20667
21075
  return false;
20668
21076
  }
20669
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
21077
+ units = normalizeUnits(units) || 'millisecond';
20670
21078
  if (units === 'millisecond') {
20671
21079
  return this.valueOf() > localInput.valueOf();
20672
21080
  } else {
@@ -20679,7 +21087,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20679
21087
  if (!(this.isValid() && localInput.isValid())) {
20680
21088
  return false;
20681
21089
  }
20682
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
21090
+ units = normalizeUnits(units) || 'millisecond';
20683
21091
  if (units === 'millisecond') {
20684
21092
  return this.valueOf() < localInput.valueOf();
20685
21093
  } else {
@@ -20688,9 +21096,14 @@ moment.tz.load(require('./data/packed/latest.json'));
20688
21096
  }
20689
21097
 
20690
21098
  function isBetween (from, to, units, inclusivity) {
21099
+ var localFrom = isMoment(from) ? from : createLocal(from),
21100
+ localTo = isMoment(to) ? to : createLocal(to);
21101
+ if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
21102
+ return false;
21103
+ }
20691
21104
  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));
21105
+ return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
21106
+ (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
20694
21107
  }
20695
21108
 
20696
21109
  function isSame (input, units) {
@@ -20699,7 +21112,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20699
21112
  if (!(this.isValid() && localInput.isValid())) {
20700
21113
  return false;
20701
21114
  }
20702
- units = normalizeUnits(units || 'millisecond');
21115
+ units = normalizeUnits(units) || 'millisecond';
20703
21116
  if (units === 'millisecond') {
20704
21117
  return this.valueOf() === localInput.valueOf();
20705
21118
  } else {
@@ -20709,11 +21122,11 @@ moment.tz.load(require('./data/packed/latest.json'));
20709
21122
  }
20710
21123
 
20711
21124
  function isSameOrAfter (input, units) {
20712
- return this.isSame(input, units) || this.isAfter(input,units);
21125
+ return this.isSame(input, units) || this.isAfter(input, units);
20713
21126
  }
20714
21127
 
20715
21128
  function isSameOrBefore (input, units) {
20716
- return this.isSame(input, units) || this.isBefore(input,units);
21129
+ return this.isSame(input, units) || this.isBefore(input, units);
20717
21130
  }
20718
21131
 
20719
21132
  function diff (input, units, asFloat) {
@@ -20890,62 +21303,130 @@ moment.tz.load(require('./data/packed/latest.json'));
20890
21303
  return this._locale;
20891
21304
  }
20892
21305
 
21306
+ var MS_PER_SECOND = 1000;
21307
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
21308
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
21309
+ var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
21310
+
21311
+ // actual modulo - handles negative numbers (for dates before 1970):
21312
+ function mod$1(dividend, divisor) {
21313
+ return (dividend % divisor + divisor) % divisor;
21314
+ }
21315
+
21316
+ function localStartOfDate(y, m, d) {
21317
+ // the date constructor remaps years 0-99 to 1900-1999
21318
+ if (y < 100 && y >= 0) {
21319
+ // preserve leap years using a full 400 year cycle, then reset
21320
+ return new Date(y + 400, m, d) - MS_PER_400_YEARS;
21321
+ } else {
21322
+ return new Date(y, m, d).valueOf();
21323
+ }
21324
+ }
21325
+
21326
+ function utcStartOfDate(y, m, d) {
21327
+ // Date.UTC remaps years 0-99 to 1900-1999
21328
+ if (y < 100 && y >= 0) {
21329
+ // preserve leap years using a full 400 year cycle, then reset
21330
+ return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
21331
+ } else {
21332
+ return Date.UTC(y, m, d);
21333
+ }
21334
+ }
21335
+
20893
21336
  function startOf (units) {
21337
+ var time;
20894
21338
  units = normalizeUnits(units);
20895
- // the following switch intentionally omits break keywords
20896
- // to utilize falling through the cases.
21339
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
21340
+ return this;
21341
+ }
21342
+
21343
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21344
+
20897
21345
  switch (units) {
20898
21346
  case 'year':
20899
- this.month(0);
20900
- /* falls through */
21347
+ time = startOfDate(this.year(), 0, 1);
21348
+ break;
20901
21349
  case 'quarter':
21350
+ time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
21351
+ break;
20902
21352
  case 'month':
20903
- this.date(1);
20904
- /* falls through */
21353
+ time = startOfDate(this.year(), this.month(), 1);
21354
+ break;
20905
21355
  case 'week':
21356
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
21357
+ break;
20906
21358
  case 'isoWeek':
21359
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
21360
+ break;
20907
21361
  case 'day':
20908
21362
  case 'date':
20909
- this.hours(0);
20910
- /* falls through */
21363
+ time = startOfDate(this.year(), this.month(), this.date());
21364
+ break;
20911
21365
  case 'hour':
20912
- this.minutes(0);
20913
- /* falls through */
21366
+ time = this._d.valueOf();
21367
+ time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
21368
+ break;
20914
21369
  case 'minute':
20915
- this.seconds(0);
20916
- /* falls through */
21370
+ time = this._d.valueOf();
21371
+ time -= mod$1(time, MS_PER_MINUTE);
21372
+ break;
20917
21373
  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);
21374
+ time = this._d.valueOf();
21375
+ time -= mod$1(time, MS_PER_SECOND);
21376
+ break;
20932
21377
  }
20933
21378
 
21379
+ this._d.setTime(time);
21380
+ hooks.updateOffset(this, true);
20934
21381
  return this;
20935
21382
  }
20936
21383
 
20937
21384
  function endOf (units) {
21385
+ var time;
20938
21386
  units = normalizeUnits(units);
20939
- if (units === undefined || units === 'millisecond') {
21387
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
20940
21388
  return this;
20941
21389
  }
20942
21390
 
20943
- // 'date' is an alias for 'day', so it should be considered as such.
20944
- if (units === 'date') {
20945
- units = 'day';
21391
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21392
+
21393
+ switch (units) {
21394
+ case 'year':
21395
+ time = startOfDate(this.year() + 1, 0, 1) - 1;
21396
+ break;
21397
+ case 'quarter':
21398
+ time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
21399
+ break;
21400
+ case 'month':
21401
+ time = startOfDate(this.year(), this.month() + 1, 1) - 1;
21402
+ break;
21403
+ case 'week':
21404
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
21405
+ break;
21406
+ case 'isoWeek':
21407
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
21408
+ break;
21409
+ case 'day':
21410
+ case 'date':
21411
+ time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
21412
+ break;
21413
+ case 'hour':
21414
+ time = this._d.valueOf();
21415
+ time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
21416
+ break;
21417
+ case 'minute':
21418
+ time = this._d.valueOf();
21419
+ time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
21420
+ break;
21421
+ case 'second':
21422
+ time = this._d.valueOf();
21423
+ time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
21424
+ break;
20946
21425
  }
20947
21426
 
20948
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
21427
+ this._d.setTime(time);
21428
+ hooks.updateOffset(this, true);
21429
+ return this;
20949
21430
  }
20950
21431
 
20951
21432
  function valueOf () {
@@ -21651,10 +22132,14 @@ moment.tz.load(require('./data/packed/latest.json'));
21651
22132
 
21652
22133
  units = normalizeUnits(units);
21653
22134
 
21654
- if (units === 'month' || units === 'year') {
21655
- days = this._days + milliseconds / 864e5;
22135
+ if (units === 'month' || units === 'quarter' || units === 'year') {
22136
+ days = this._days + milliseconds / 864e5;
21656
22137
  months = this._months + daysToMonths(days);
21657
- return units === 'month' ? months : months / 12;
22138
+ switch (units) {
22139
+ case 'month': return months;
22140
+ case 'quarter': return months / 3;
22141
+ case 'year': return months / 12;
22142
+ }
21658
22143
  } else {
21659
22144
  // handle milliseconds separately because of floating point math errors (issue #1867)
21660
22145
  days = this._days + Math.round(monthsToDays(this._months));
@@ -21697,6 +22182,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21697
22182
  var asDays = makeAs('d');
21698
22183
  var asWeeks = makeAs('w');
21699
22184
  var asMonths = makeAs('M');
22185
+ var asQuarters = makeAs('Q');
21700
22186
  var asYears = makeAs('y');
21701
22187
 
21702
22188
  function clone$1 () {
@@ -21888,6 +22374,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21888
22374
  proto$2.asDays = asDays;
21889
22375
  proto$2.asWeeks = asWeeks;
21890
22376
  proto$2.asMonths = asMonths;
22377
+ proto$2.asQuarters = asQuarters;
21891
22378
  proto$2.asYears = asYears;
21892
22379
  proto$2.valueOf = valueOf$1;
21893
22380
  proto$2._bubble = bubble;
@@ -21932,7 +22419,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21932
22419
  // Side effect imports
21933
22420
 
21934
22421
 
21935
- hooks.version = '2.22.2';
22422
+ hooks.version = '2.24.0';
21936
22423
 
21937
22424
  setHookCallback(createLocal);
21938
22425
 
@@ -21973,7 +22460,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21973
22460
  TIME: 'HH:mm', // <input type="time" />
21974
22461
  TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
21975
22462
  TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
21976
- WEEK: 'YYYY-[W]WW', // <input type="week" />
22463
+ WEEK: 'GGGG-[W]WW', // <input type="week" />
21977
22464
  MONTH: 'YYYY-MM' // <input type="month" />
21978
22465
  };
21979
22466