@barchart/portfolio-api-common 1.2.59 → 1.2.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/data/InstrumentType.js +19 -6
- package/lib/data/PositionSummaryFrame.js +1 -2
- package/lib/data/ValuationType.js +1 -2
- package/lib/formatters/PositionSummaryFormatter.js +0 -1
- package/lib/processing/PositionItem.js +1 -1
- package/lib/serialization/PortfolioSchema.js +1 -3
- package/lib/serialization/PositionSchema.js +1 -3
- package/lib/serialization/PositionSummarySchema.js +13 -12
- package/package.json +1 -1
- package/test/SpecRunner.js +96 -36
|
@@ -19,11 +19,12 @@ module.exports = (() => {
|
|
|
19
19
|
* @param {Boolean} canSwitchDirection
|
|
20
20
|
* @param {Boolean} usesSymbols
|
|
21
21
|
* @param {Boolean} hasCorporateActions
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {Boolean} closeFractional
|
|
23
|
+
* @param {Boolean} roundQuantity
|
|
23
24
|
* @param {Function} generator
|
|
24
25
|
*/
|
|
25
26
|
class InstrumentType extends Enum {
|
|
26
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, generator) {
|
|
27
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, generator) {
|
|
27
28
|
super(code, description);
|
|
28
29
|
|
|
29
30
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -33,6 +34,7 @@ module.exports = (() => {
|
|
|
33
34
|
assert.argumentIsRequired(usesSymbols, 'usesSymbols', Boolean);
|
|
34
35
|
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
35
36
|
assert.argumentIsRequired(closeFractional, 'closeFractional', Boolean);
|
|
37
|
+
assert.argumentIsRequired(roundQuantity, 'roundQuantity', Boolean);
|
|
36
38
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
37
39
|
|
|
38
40
|
this._alternateDescription = alternateDescription;
|
|
@@ -42,6 +44,7 @@ module.exports = (() => {
|
|
|
42
44
|
this._usesSymbols = usesSymbols;
|
|
43
45
|
this._hasCorporateActions = hasCorporateActions;
|
|
44
46
|
this._closeFractional = closeFractional;
|
|
47
|
+
this._roundQuantity = roundQuantity;
|
|
45
48
|
|
|
46
49
|
this._generator = generator;
|
|
47
50
|
}
|
|
@@ -118,6 +121,16 @@ module.exports = (() => {
|
|
|
118
121
|
return this._closeFractional;
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Indicates transaction quantities should be rounded.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @returns {Boolean}
|
|
129
|
+
*/
|
|
130
|
+
get roundQuantity() {
|
|
131
|
+
return this._roundQuantity;
|
|
132
|
+
}
|
|
133
|
+
|
|
121
134
|
/**
|
|
122
135
|
* Generates an identifier for the instrument.
|
|
123
136
|
*
|
|
@@ -215,10 +228,10 @@ module.exports = (() => {
|
|
|
215
228
|
}
|
|
216
229
|
}
|
|
217
230
|
|
|
218
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
219
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
220
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
221
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
231
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
232
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
233
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
234
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
222
235
|
|
|
223
236
|
const map = { };
|
|
224
237
|
|
|
@@ -2,8 +2,7 @@ const array = require('@barchart/common-js/lang/array'),
|
|
|
2
2
|
assert = require('@barchart/common-js/lang/assert'),
|
|
3
3
|
Day = require('@barchart/common-js/lang/Day'),
|
|
4
4
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
5
|
-
Enum = require('@barchart/common-js/lang/Enum')
|
|
6
|
-
is = require('@barchart/common-js/lang/is');
|
|
5
|
+
Enum = require('@barchart/common-js/lang/Enum');
|
|
7
6
|
|
|
8
7
|
module.exports = (() => {
|
|
9
8
|
'use strict';
|
|
@@ -420,7 +420,7 @@ module.exports = (() => {
|
|
|
420
420
|
} else if (data.previousPrice) {
|
|
421
421
|
priceToUse = new Decimal(data.previousPrice);
|
|
422
422
|
} else if (!currentSummary.end.open.getIsZero()) {
|
|
423
|
-
priceToUse = currentSummary.end.value.divide(
|
|
423
|
+
priceToUse = currentSummary.end.value.divide(currentSummary.end.open);
|
|
424
424
|
} else {
|
|
425
425
|
priceToUse = null;
|
|
426
426
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
Currency = require('@barchart/common-js/lang/Currency'),
|
|
1
|
+
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
3
2
|
DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
4
3
|
Enum = require('@barchart/common-js/lang/Enum'),
|
|
5
|
-
is = require('@barchart/common-js/lang/is'),
|
|
6
4
|
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
7
5
|
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder'),
|
|
8
6
|
Timezones = require('@barchart/common-js/lang/Timezones');
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
Currency = require('@barchart/common-js/lang/Currency'),
|
|
1
|
+
const Currency = require('@barchart/common-js/lang/Currency'),
|
|
3
2
|
DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
4
3
|
Enum = require('@barchart/common-js/lang/Enum'),
|
|
5
|
-
is = require('@barchart/common-js/lang/is'),
|
|
6
4
|
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
7
5
|
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
|
|
8
6
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
Currency = require('@barchart/common-js/lang/Currency'),
|
|
3
|
-
DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
1
|
+
const DataType = require('@barchart/common-js/serialization/json/DataType'),
|
|
4
2
|
Enum = require('@barchart/common-js/lang/Enum'),
|
|
5
|
-
is = require('@barchart/common-js/lang/is'),
|
|
6
3
|
Schema = require('@barchart/common-js/serialization/json/Schema'),
|
|
7
4
|
SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
|
|
8
5
|
|
|
@@ -66,13 +63,15 @@ module.exports = (() => {
|
|
|
66
63
|
.withField('user', DataType.STRING)
|
|
67
64
|
.withField('portfolio', DataType.STRING)
|
|
68
65
|
.withField('position', DataType.STRING)
|
|
69
|
-
|
|
70
|
-
.withField('instrument.
|
|
71
|
-
.withField('instrument.
|
|
72
|
-
.withField('instrument.
|
|
66
|
+
|
|
67
|
+
.withField('instrument.id', DataType.STRING, true)
|
|
68
|
+
.withField('instrument.name', DataType.STRING, true)
|
|
69
|
+
.withField('instrument.type', DataType.STRING, true)
|
|
70
|
+
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
73
71
|
.withField('instrument.delist', DataType.DAY, true)
|
|
74
72
|
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
75
73
|
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
74
|
+
|
|
76
75
|
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
77
76
|
.withField('start.date', DataType.DAY)
|
|
78
77
|
.withField('start.sequence', DataType.NUMBER)
|
|
@@ -100,13 +99,15 @@ module.exports = (() => {
|
|
|
100
99
|
.withField('user', DataType.STRING)
|
|
101
100
|
.withField('portfolio', DataType.STRING)
|
|
102
101
|
.withField('position', DataType.STRING)
|
|
103
|
-
|
|
104
|
-
.withField('instrument.
|
|
105
|
-
.withField('instrument.
|
|
106
|
-
.withField('instrument.
|
|
102
|
+
|
|
103
|
+
.withField('instrument.id', DataType.STRING, true)
|
|
104
|
+
.withField('instrument.name', DataType.STRING, true)
|
|
105
|
+
.withField('instrument.type', DataType.STRING, true)
|
|
106
|
+
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
107
107
|
.withField('instrument.delist', DataType.DAY, true)
|
|
108
108
|
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
109
109
|
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
110
|
+
|
|
110
111
|
.withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
|
|
111
112
|
.withField('start.date', DataType.DAY)
|
|
112
113
|
.withField('start.sequence', DataType.NUMBER)
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -20,11 +20,12 @@ module.exports = (() => {
|
|
|
20
20
|
* @param {Boolean} canSwitchDirection
|
|
21
21
|
* @param {Boolean} usesSymbols
|
|
22
22
|
* @param {Boolean} hasCorporateActions
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {Boolean} closeFractional
|
|
24
|
+
* @param {Boolean} roundQuantity
|
|
24
25
|
* @param {Function} generator
|
|
25
26
|
*/
|
|
26
27
|
class InstrumentType extends Enum {
|
|
27
|
-
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, generator) {
|
|
28
|
+
constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, generator) {
|
|
28
29
|
super(code, description);
|
|
29
30
|
|
|
30
31
|
assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
|
|
@@ -34,6 +35,7 @@ module.exports = (() => {
|
|
|
34
35
|
assert.argumentIsRequired(usesSymbols, 'usesSymbols', Boolean);
|
|
35
36
|
assert.argumentIsRequired(hasCorporateActions, 'hasCorporateActions', Boolean);
|
|
36
37
|
assert.argumentIsRequired(closeFractional, 'closeFractional', Boolean);
|
|
38
|
+
assert.argumentIsRequired(roundQuantity, 'roundQuantity', Boolean);
|
|
37
39
|
assert.argumentIsRequired(generator, 'generator', Function);
|
|
38
40
|
|
|
39
41
|
this._alternateDescription = alternateDescription;
|
|
@@ -43,6 +45,7 @@ module.exports = (() => {
|
|
|
43
45
|
this._usesSymbols = usesSymbols;
|
|
44
46
|
this._hasCorporateActions = hasCorporateActions;
|
|
45
47
|
this._closeFractional = closeFractional;
|
|
48
|
+
this._roundQuantity = roundQuantity;
|
|
46
49
|
|
|
47
50
|
this._generator = generator;
|
|
48
51
|
}
|
|
@@ -119,6 +122,16 @@ module.exports = (() => {
|
|
|
119
122
|
return this._closeFractional;
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Indicates transaction quantities should be rounded.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @returns {Boolean}
|
|
130
|
+
*/
|
|
131
|
+
get roundQuantity() {
|
|
132
|
+
return this._roundQuantity;
|
|
133
|
+
}
|
|
134
|
+
|
|
122
135
|
/**
|
|
123
136
|
* Generates an identifier for the instrument.
|
|
124
137
|
*
|
|
@@ -216,10 +229,10 @@ module.exports = (() => {
|
|
|
216
229
|
}
|
|
217
230
|
}
|
|
218
231
|
|
|
219
|
-
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
220
|
-
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
221
|
-
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
222
|
-
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
232
|
+
const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
|
|
233
|
+
const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
234
|
+
const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
|
|
235
|
+
const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
|
|
223
236
|
|
|
224
237
|
const map = { };
|
|
225
238
|
|
|
@@ -366,8 +379,7 @@ const array = require('@barchart/common-js/lang/array'),
|
|
|
366
379
|
assert = require('@barchart/common-js/lang/assert'),
|
|
367
380
|
Day = require('@barchart/common-js/lang/Day'),
|
|
368
381
|
Decimal = require('@barchart/common-js/lang/Decimal'),
|
|
369
|
-
Enum = require('@barchart/common-js/lang/Enum')
|
|
370
|
-
is = require('@barchart/common-js/lang/is');
|
|
382
|
+
Enum = require('@barchart/common-js/lang/Enum');
|
|
371
383
|
|
|
372
384
|
module.exports = (() => {
|
|
373
385
|
'use strict';
|
|
@@ -634,7 +646,7 @@ module.exports = (() => {
|
|
|
634
646
|
return PositionSummaryFrame;
|
|
635
647
|
})();
|
|
636
648
|
|
|
637
|
-
},{"@barchart/common-js/lang/Day":21,"@barchart/common-js/lang/Decimal":22,"@barchart/common-js/lang/Enum":24,"@barchart/common-js/lang/array":28,"@barchart/common-js/lang/assert":29
|
|
649
|
+
},{"@barchart/common-js/lang/Day":21,"@barchart/common-js/lang/Decimal":22,"@barchart/common-js/lang/Enum":24,"@barchart/common-js/lang/array":28,"@barchart/common-js/lang/assert":29}],4:[function(require,module,exports){
|
|
638
650
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
639
651
|
Enum = require('@barchart/common-js/lang/Enum');
|
|
640
652
|
|
|
@@ -3556,7 +3568,7 @@ module.exports = (() => {
|
|
|
3556
3568
|
} else if (data.previousPrice) {
|
|
3557
3569
|
priceToUse = new Decimal(data.previousPrice);
|
|
3558
3570
|
} else if (!currentSummary.end.open.getIsZero()) {
|
|
3559
|
-
priceToUse = currentSummary.end.value.divide(
|
|
3571
|
+
priceToUse = currentSummary.end.value.divide(currentSummary.end.open);
|
|
3560
3572
|
} else {
|
|
3561
3573
|
priceToUse = null;
|
|
3562
3574
|
}
|
|
@@ -5167,8 +5179,8 @@ module.exports = function () {
|
|
|
5167
5179
|
* Compares two strings (in ascending order), using {@link String#localeCompare}.
|
|
5168
5180
|
*
|
|
5169
5181
|
* @static
|
|
5170
|
-
* @param {
|
|
5171
|
-
* @param {
|
|
5182
|
+
* @param {String} a
|
|
5183
|
+
* @param {String} b
|
|
5172
5184
|
* @returns {Number}
|
|
5173
5185
|
*/
|
|
5174
5186
|
compareStrings: function compareStrings(a, b) {
|
|
@@ -5858,7 +5870,7 @@ module.exports = function () {
|
|
|
5858
5870
|
* @returns {String}
|
|
5859
5871
|
*/
|
|
5860
5872
|
value: function format() {
|
|
5861
|
-
return this._year + '-' + leftPad(this._month) + '-' + leftPad(this._day);
|
|
5873
|
+
return leftPad(this._year, 4, '0') + '-' + leftPad(this._month, 2, '0') + '-' + leftPad(this._day, 2, '0');
|
|
5862
5874
|
}
|
|
5863
5875
|
|
|
5864
5876
|
/**
|
|
@@ -5975,7 +5987,7 @@ module.exports = function () {
|
|
|
5975
5987
|
*
|
|
5976
5988
|
* @static
|
|
5977
5989
|
* @public
|
|
5978
|
-
* @
|
|
5990
|
+
* @returns {Day}
|
|
5979
5991
|
*/
|
|
5980
5992
|
|
|
5981
5993
|
}, {
|
|
@@ -6067,8 +6079,11 @@ module.exports = function () {
|
|
|
6067
6079
|
|
|
6068
6080
|
var dayRegex = /^([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/;
|
|
6069
6081
|
|
|
6070
|
-
function leftPad(value) {
|
|
6071
|
-
|
|
6082
|
+
function leftPad(value, digits, character) {
|
|
6083
|
+
var string = value.toString();
|
|
6084
|
+
var padding = digits - string.length;
|
|
6085
|
+
|
|
6086
|
+
return '' + character.repeat(padding) + string;
|
|
6072
6087
|
}
|
|
6073
6088
|
|
|
6074
6089
|
var comparator = ComparatorBuilder.startWith(function (a, b) {
|
|
@@ -6234,15 +6249,17 @@ module.exports = function () {
|
|
|
6234
6249
|
*
|
|
6235
6250
|
* @public
|
|
6236
6251
|
* @param {Boolean=} approximate
|
|
6252
|
+
* @param {Number=} places
|
|
6237
6253
|
* @returns {Boolean}
|
|
6238
6254
|
*/
|
|
6239
6255
|
|
|
6240
6256
|
}, {
|
|
6241
6257
|
key: 'getIsZero',
|
|
6242
|
-
value: function getIsZero(approximate) {
|
|
6258
|
+
value: function getIsZero(approximate, places) {
|
|
6243
6259
|
assert.argumentIsOptional(approximate, 'approximate', Boolean);
|
|
6260
|
+
assert.argumentIsOptional(places, 'places', Number);
|
|
6244
6261
|
|
|
6245
|
-
return this._big.eq(zero) || is.boolean(approximate) && approximate && this.round(
|
|
6262
|
+
return this._big.eq(zero) || is.boolean(approximate) && approximate && this.round(places || Big.DP, RoundingMode.NORMAL).getIsZero();
|
|
6246
6263
|
}
|
|
6247
6264
|
|
|
6248
6265
|
/**
|
|
@@ -6341,6 +6358,43 @@ module.exports = function () {
|
|
|
6341
6358
|
return this._big.eq(getBig(other));
|
|
6342
6359
|
}
|
|
6343
6360
|
|
|
6361
|
+
/**
|
|
6362
|
+
* Returns true if the current instance is an integer (i.e. has no decimal
|
|
6363
|
+
* component).
|
|
6364
|
+
*
|
|
6365
|
+
* @public
|
|
6366
|
+
* @return {Boolean}
|
|
6367
|
+
*/
|
|
6368
|
+
|
|
6369
|
+
}, {
|
|
6370
|
+
key: 'getIsInteger',
|
|
6371
|
+
value: function getIsInteger() {
|
|
6372
|
+
return this.getIsEqual(this.round(0));
|
|
6373
|
+
}
|
|
6374
|
+
|
|
6375
|
+
/**
|
|
6376
|
+
* Returns the number of decimal places used.
|
|
6377
|
+
*
|
|
6378
|
+
* @public
|
|
6379
|
+
* @returns {Number}
|
|
6380
|
+
*/
|
|
6381
|
+
|
|
6382
|
+
}, {
|
|
6383
|
+
key: 'getDecimalPlaces',
|
|
6384
|
+
value: function getDecimalPlaces() {
|
|
6385
|
+
var matches = this.toFixed().match(/-?\d*\.(\d*)/);
|
|
6386
|
+
|
|
6387
|
+
var returnVal = void 0;
|
|
6388
|
+
|
|
6389
|
+
if (matches === null) {
|
|
6390
|
+
returnVal = 0;
|
|
6391
|
+
} else {
|
|
6392
|
+
returnVal = matches[1].length;
|
|
6393
|
+
}
|
|
6394
|
+
|
|
6395
|
+
return returnVal;
|
|
6396
|
+
}
|
|
6397
|
+
|
|
6344
6398
|
/**
|
|
6345
6399
|
* Emits a floating point value that approximates the value of the current
|
|
6346
6400
|
* instance.
|
|
@@ -6423,7 +6477,7 @@ module.exports = function () {
|
|
|
6423
6477
|
*
|
|
6424
6478
|
* @public
|
|
6425
6479
|
* @param {Decimal} instance
|
|
6426
|
-
* @
|
|
6480
|
+
* @returns {Boolean}
|
|
6427
6481
|
*/
|
|
6428
6482
|
value: function getIsZero(instance) {
|
|
6429
6483
|
assert.argumentIsRequired(instance, 'instance', Decimal, 'Decimal');
|
|
@@ -6436,7 +6490,7 @@ module.exports = function () {
|
|
|
6436
6490
|
*
|
|
6437
6491
|
* @public
|
|
6438
6492
|
* @param {Decimal} instance
|
|
6439
|
-
* @
|
|
6493
|
+
* @returns {Boolean}
|
|
6440
6494
|
*/
|
|
6441
6495
|
|
|
6442
6496
|
}, {
|
|
@@ -6452,7 +6506,7 @@ module.exports = function () {
|
|
|
6452
6506
|
*
|
|
6453
6507
|
* @public
|
|
6454
6508
|
* @param {Decimal} instance
|
|
6455
|
-
* @
|
|
6509
|
+
* @returns {Boolean}
|
|
6456
6510
|
*/
|
|
6457
6511
|
|
|
6458
6512
|
}, {
|
|
@@ -6468,7 +6522,7 @@ module.exports = function () {
|
|
|
6468
6522
|
*
|
|
6469
6523
|
* @public
|
|
6470
6524
|
* @param {Decimal} instance
|
|
6471
|
-
* @
|
|
6525
|
+
* @returns {Boolean}
|
|
6472
6526
|
*/
|
|
6473
6527
|
|
|
6474
6528
|
}, {
|
|
@@ -6484,7 +6538,7 @@ module.exports = function () {
|
|
|
6484
6538
|
*
|
|
6485
6539
|
* @public
|
|
6486
6540
|
* @param {Decimal} instance
|
|
6487
|
-
* @
|
|
6541
|
+
* @returns {Boolean}
|
|
6488
6542
|
*/
|
|
6489
6543
|
|
|
6490
6544
|
}, {
|
|
@@ -6500,7 +6554,7 @@ module.exports = function () {
|
|
|
6500
6554
|
*
|
|
6501
6555
|
* @public
|
|
6502
6556
|
* @param {Decimal} instance
|
|
6503
|
-
* @
|
|
6557
|
+
* @returns {Boolean}
|
|
6504
6558
|
*/
|
|
6505
6559
|
|
|
6506
6560
|
}, {
|
|
@@ -6890,6 +6944,7 @@ module.exports = function () {
|
|
|
6890
6944
|
/**
|
|
6891
6945
|
* The unique code.
|
|
6892
6946
|
*
|
|
6947
|
+
* @public
|
|
6893
6948
|
* @returns {String}
|
|
6894
6949
|
*/
|
|
6895
6950
|
|
|
@@ -6902,6 +6957,7 @@ module.exports = function () {
|
|
|
6902
6957
|
* Returns true if the provided {@link Enum} argument is equal
|
|
6903
6958
|
* to the instance.
|
|
6904
6959
|
*
|
|
6960
|
+
* @public
|
|
6905
6961
|
* @param {Enum} other
|
|
6906
6962
|
* @returns {boolean}
|
|
6907
6963
|
*/
|
|
@@ -6926,6 +6982,7 @@ module.exports = function () {
|
|
|
6926
6982
|
* Looks up a enumeration item; given the enumeration type and the enumeration
|
|
6927
6983
|
* item's value. If no matching item can be found, a null value is returned.
|
|
6928
6984
|
*
|
|
6985
|
+
* @public
|
|
6929
6986
|
* @param {Function} type - The enumeration type.
|
|
6930
6987
|
* @param {String} code - The enumeration item's code.
|
|
6931
6988
|
* @returns {*|null}
|
|
@@ -6945,6 +7002,7 @@ module.exports = function () {
|
|
|
6945
7002
|
/**
|
|
6946
7003
|
* The description.
|
|
6947
7004
|
*
|
|
7005
|
+
* @public
|
|
6948
7006
|
* @returns {String}
|
|
6949
7007
|
*/
|
|
6950
7008
|
|
|
@@ -6964,6 +7022,7 @@ module.exports = function () {
|
|
|
6964
7022
|
/**
|
|
6965
7023
|
* Returns all of the enumeration's items (given an enumeration type).
|
|
6966
7024
|
*
|
|
7025
|
+
* @public
|
|
6967
7026
|
* @param {Function} type - The enumeration to list.
|
|
6968
7027
|
* @returns {Array}
|
|
6969
7028
|
*/
|
|
@@ -7421,7 +7480,7 @@ module.exports = function () {
|
|
|
7421
7480
|
* Parses the value emitted by {@link Timestamp#toJSON}.
|
|
7422
7481
|
*
|
|
7423
7482
|
* @public
|
|
7424
|
-
* @param {
|
|
7483
|
+
* @param {Number} value
|
|
7425
7484
|
* @returns {Timestamp}
|
|
7426
7485
|
*/
|
|
7427
7486
|
|
|
@@ -8057,7 +8116,7 @@ module.exports = function () {
|
|
|
8057
8116
|
|
|
8058
8117
|
if (typeof itemConstraint === 'function' && itemConstraint !== Function) {
|
|
8059
8118
|
itemValidator = function itemValidator(value, index) {
|
|
8060
|
-
return value instanceof itemConstraint || itemConstraint(value, variableName + '[' + index + ']');
|
|
8119
|
+
return itemConstraint.prototype !== undefined && value instanceof itemConstraint || itemConstraint(value, variableName + '[' + index + ']');
|
|
8061
8120
|
};
|
|
8062
8121
|
} else {
|
|
8063
8122
|
itemValidator = function itemValidator(value, index) {
|
|
@@ -8167,7 +8226,7 @@ module.exports = function () {
|
|
|
8167
8226
|
*
|
|
8168
8227
|
* @static
|
|
8169
8228
|
* @param {Object} target - The object to check for existence of the property.
|
|
8170
|
-
* @param {String|Array
|
|
8229
|
+
* @param {String|Array.<String>} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
|
|
8171
8230
|
* @param {String=} separator - The separator (defaults to a period character).
|
|
8172
8231
|
* @returns {boolean}
|
|
8173
8232
|
*/
|
|
@@ -8193,7 +8252,7 @@ module.exports = function () {
|
|
|
8193
8252
|
*
|
|
8194
8253
|
* @static
|
|
8195
8254
|
* @param {Object} target - The object to read from.
|
|
8196
|
-
* @param {String|Array
|
|
8255
|
+
* @param {String|Array.<String>} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
|
|
8197
8256
|
* @param {String=} separator - The separator (defaults to a period character).
|
|
8198
8257
|
* @returns {*}
|
|
8199
8258
|
*/
|
|
@@ -8228,7 +8287,8 @@ module.exports = function () {
|
|
|
8228
8287
|
*
|
|
8229
8288
|
* @static
|
|
8230
8289
|
* @param {Object} target - The object to write to.
|
|
8231
|
-
* @param {String|Array
|
|
8290
|
+
* @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
|
|
8291
|
+
* @param {*} value - The value to assign.
|
|
8232
8292
|
* @param {String=} separator - The separator (defaults to a period character).
|
|
8233
8293
|
*/
|
|
8234
8294
|
write: function write(target, propertyNames, value, separator) {
|
|
@@ -8254,7 +8314,7 @@ module.exports = function () {
|
|
|
8254
8314
|
*
|
|
8255
8315
|
* @static
|
|
8256
8316
|
* @param {Object} target - The object to erase a property from.
|
|
8257
|
-
* @param {String|Array
|
|
8317
|
+
* @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
|
|
8258
8318
|
* @param {String=} separator - The separator (defaults to a period character).
|
|
8259
8319
|
*/
|
|
8260
8320
|
erase: function erase(target, propertyNames, separator) {
|
|
@@ -9507,7 +9567,7 @@ module.exports = function () {
|
|
|
9507
9567
|
}
|
|
9508
9568
|
|
|
9509
9569
|
/**
|
|
9510
|
-
* Generates a function suitable for use by JSON.parse.
|
|
9570
|
+
* Generates a function suitable for use by {@link JSON.parse}.
|
|
9511
9571
|
*
|
|
9512
9572
|
* @public
|
|
9513
9573
|
* @returns {Function}
|
|
@@ -13632,9 +13692,9 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
13632
13692
|
|
|
13633
13693
|
mom = createUTC([2000, 1]).day(i);
|
|
13634
13694
|
if (strict && !this._fullWeekdaysParse[i]) {
|
|
13635
|
-
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '
|
|
13636
|
-
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '
|
|
13637
|
-
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '
|
|
13695
|
+
this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
|
|
13696
|
+
this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
|
|
13697
|
+
this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
|
|
13638
13698
|
}
|
|
13639
13699
|
if (!this._weekdaysParse[i]) {
|
|
13640
13700
|
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
|
@@ -14437,7 +14497,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
14437
14497
|
|
|
14438
14498
|
function preprocessRFC2822(s) {
|
|
14439
14499
|
// Remove comments and folding whitespace and replace multiple-spaces with a single space
|
|
14440
|
-
return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').
|
|
14500
|
+
return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
|
14441
14501
|
}
|
|
14442
14502
|
|
|
14443
14503
|
function checkWeekday(weekdayStr, parsedInput, config) {
|
|
@@ -16616,7 +16676,7 @@ moment.tz.load(require('./data/packed/latest.json'));
|
|
|
16616
16676
|
// Side effect imports
|
|
16617
16677
|
|
|
16618
16678
|
|
|
16619
|
-
hooks.version = '2.22.
|
|
16679
|
+
hooks.version = '2.22.2';
|
|
16620
16680
|
|
|
16621
16681
|
setHookCallback(createLocal);
|
|
16622
16682
|
|