@parischap/conversions 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1304 -0
- package/cjs/BigDecimal.js +16 -0
- package/cjs/BigDecimal.js.map +1 -0
- package/cjs/BigInt.js +34 -0
- package/cjs/BigInt.js.map +1 -0
- package/cjs/DateTime.js +2202 -0
- package/cjs/DateTime.js.map +1 -0
- package/cjs/DateTimeFormat.js +269 -0
- package/cjs/DateTimeFormat.js.map +1 -0
- package/cjs/DateTimeFormatContext.js +327 -0
- package/cjs/DateTimeFormatContext.js.map +1 -0
- package/cjs/Email.js +73 -0
- package/cjs/Email.js.map +1 -0
- package/cjs/Integer.js +155 -0
- package/cjs/Integer.js.map +1 -0
- package/cjs/NumberBase10Format.js +759 -0
- package/cjs/NumberBase10Format.js.map +1 -0
- package/cjs/PositiveInteger.js +191 -0
- package/cjs/PositiveInteger.js.map +1 -0
- package/cjs/PositiveReal.js +162 -0
- package/cjs/PositiveReal.js.map +1 -0
- package/cjs/Real.js +113 -0
- package/cjs/Real.js.map +1 -0
- package/cjs/RoundingMode.js +86 -0
- package/cjs/RoundingMode.js.map +1 -0
- package/cjs/RoundingOption.js +152 -0
- package/cjs/RoundingOption.js.map +1 -0
- package/cjs/Schema.js +218 -0
- package/cjs/Schema.js.map +1 -0
- package/cjs/SemVer.js +73 -0
- package/cjs/SemVer.js.map +1 -0
- package/cjs/Template.js +189 -0
- package/cjs/Template.js.map +1 -0
- package/cjs/TemplatePart.js +51 -0
- package/cjs/TemplatePart.js.map +1 -0
- package/cjs/TemplateParts.js +46 -0
- package/cjs/TemplateParts.js.map +1 -0
- package/cjs/TemplatePlaceholder.js +381 -0
- package/cjs/TemplatePlaceholder.js.map +1 -0
- package/cjs/TemplateSeparator.js +116 -0
- package/cjs/TemplateSeparator.js.map +1 -0
- package/cjs/index.js +67 -0
- package/cjs/index.js.map +1 -0
- package/cjs/internal/Int.js +50 -0
- package/cjs/internal/Int.js.map +1 -0
- package/cjs/internal/Positive.js +50 -0
- package/cjs/internal/Positive.js.map +1 -0
- package/dts/BigDecimal.d.ts +11 -0
- package/dts/BigDecimal.d.ts.map +1 -0
- package/dts/BigInt.d.ts +30 -0
- package/dts/BigInt.d.ts.map +1 -0
- package/dts/DateTime.d.ts +1421 -0
- package/dts/DateTime.d.ts.map +1 -0
- package/dts/DateTimeFormat.d.ts +257 -0
- package/dts/DateTimeFormat.d.ts.map +1 -0
- package/dts/DateTimeFormatContext.d.ts +112 -0
- package/dts/DateTimeFormatContext.d.ts.map +1 -0
- package/dts/Email.d.ts +61 -0
- package/dts/Email.d.ts.map +1 -0
- package/dts/Integer.d.ts +123 -0
- package/dts/Integer.d.ts.map +1 -0
- package/dts/NumberBase10Format.d.ts +641 -0
- package/dts/NumberBase10Format.d.ts.map +1 -0
- package/dts/PositiveInteger.d.ts +161 -0
- package/dts/PositiveInteger.d.ts.map +1 -0
- package/dts/PositiveReal.d.ts +130 -0
- package/dts/PositiveReal.d.ts.map +1 -0
- package/dts/Real.d.ts +102 -0
- package/dts/Real.d.ts.map +1 -0
- package/dts/RoundingMode.d.ts +72 -0
- package/dts/RoundingMode.d.ts.map +1 -0
- package/dts/RoundingOption.d.ts +79 -0
- package/dts/RoundingOption.d.ts.map +1 -0
- package/dts/Schema.d.ts +159 -0
- package/dts/Schema.d.ts.map +1 -0
- package/dts/SemVer.d.ts +61 -0
- package/dts/SemVer.d.ts.map +1 -0
- package/dts/Template.d.ts +113 -0
- package/dts/Template.d.ts.map +1 -0
- package/dts/TemplatePart.d.ts +28 -0
- package/dts/TemplatePart.d.ts.map +1 -0
- package/dts/TemplateParts.d.ts +23 -0
- package/dts/TemplateParts.d.ts.map +1 -0
- package/dts/TemplatePlaceholder.d.ts +274 -0
- package/dts/TemplatePlaceholder.d.ts.map +1 -0
- package/dts/TemplateSeparator.d.ts +130 -0
- package/dts/TemplateSeparator.d.ts.map +1 -0
- package/dts/index.d.ts +21 -0
- package/dts/index.d.ts.map +1 -0
- package/dts/internal/Int.d.ts +6 -0
- package/dts/internal/Int.d.ts.map +1 -0
- package/dts/internal/Positive.d.ts +6 -0
- package/dts/internal/Positive.d.ts.map +1 -0
- package/esm/BigDecimal.js +9 -0
- package/esm/BigDecimal.js.map +1 -0
- package/esm/BigInt.js +27 -0
- package/esm/BigInt.js.map +1 -0
- package/esm/DateTime.js +2130 -0
- package/esm/DateTime.js.map +1 -0
- package/esm/DateTimeFormat.js +238 -0
- package/esm/DateTimeFormat.js.map +1 -0
- package/esm/DateTimeFormatContext.js +296 -0
- package/esm/DateTimeFormatContext.js.map +1 -0
- package/esm/Email.js +65 -0
- package/esm/Email.js.map +1 -0
- package/esm/Integer.js +128 -0
- package/esm/Integer.js.map +1 -0
- package/esm/NumberBase10Format.js +717 -0
- package/esm/NumberBase10Format.js.map +1 -0
- package/esm/PositiveInteger.js +164 -0
- package/esm/PositiveInteger.js.map +1 -0
- package/esm/PositiveReal.js +135 -0
- package/esm/PositiveReal.js.map +1 -0
- package/esm/Real.js +106 -0
- package/esm/Real.js.map +1 -0
- package/esm/RoundingMode.js +79 -0
- package/esm/RoundingMode.js.map +1 -0
- package/esm/RoundingOption.js +120 -0
- package/esm/RoundingOption.js.map +1 -0
- package/esm/Schema.js +203 -0
- package/esm/Schema.js.map +1 -0
- package/esm/SemVer.js +65 -0
- package/esm/SemVer.js.map +1 -0
- package/esm/Template.js +158 -0
- package/esm/Template.js.map +1 -0
- package/esm/TemplatePart.js +22 -0
- package/esm/TemplatePart.js.map +1 -0
- package/esm/TemplateParts.js +19 -0
- package/esm/TemplateParts.js.map +1 -0
- package/esm/TemplatePlaceholder.js +342 -0
- package/esm/TemplatePlaceholder.js.map +1 -0
- package/esm/TemplateSeparator.js +107 -0
- package/esm/TemplateSeparator.js.map +1 -0
- package/esm/index.js +21 -0
- package/esm/index.js.map +1 -0
- package/esm/internal/Int.js +43 -0
- package/esm/internal/Int.js.map +1 -0
- package/esm/internal/Positive.js +43 -0
- package/esm/internal/Positive.js.map +1 -0
- package/esm/package.json +3 -0
- package/package.json +49 -0
@@ -0,0 +1,759 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withoutThousandSeparator = exports.withoutSignDisplay = exports.withTruncRoundingMode = exports.withThousandSeparator = exports.withStandardScientificNotation = exports.withSignDisplayForNegativeExceptZero = exports.withSignDisplayForNegative = exports.withSignDisplayExceptZero = exports.withSignDisplay = exports.withNullIntegerPartShowing = exports.withNullIntegerPartNotShowing = exports.withNormalizedScientificNotation = exports.withNoScientificNotation = exports.withNDecimals = exports.withMinNDecimals = exports.withMaxNDecimals = exports.withHalfTruncRoundingMode = exports.withHalfFloorRoundingMode = exports.withHalfExpandRoundingMode = exports.withHalfEvenRoundingMode = exports.withHalfCeilRoundingMode = exports.withFractionalSeparator = exports.withFloorRoundingMode = exports.withExpandRoundingMode = exports.withEngineeringScientificNotation = exports.withCeilRoundingMode = exports.ukStyleUngroupedNumber = exports.ukStyleNumber = exports.ukStyleInteger = exports.toThrowingRealParser = exports.toThrowingRealExtractor = exports.toThrowingBigDecimalParser = exports.toThrowingBigDecimalExtractor = exports.toRealParser = exports.toRealExtractor = exports.toNumberFormatter = exports.toDescription = exports.toBigDecimalParser = exports.toBigDecimalExtractor = exports.thousandSeparator = exports.signDisplay = exports.showNullIntegerPart = exports.scientificNotation = exports.roundingMode = exports.moduleTag = exports.minimumFractionalDigits = exports.maximumFractionalDigits = exports.make = exports.integer = exports.has = exports.frenchStyleUngroupedNumber = exports.frenchStyleNumber = exports.frenchStyleInteger = exports.fractionalSeparator = exports.eNotationChars = exports.dutchStyleUngroupedNumber = exports.dutchStyleNumber = exports.dutchStyleInteger = exports.SignDisplay = exports.ScientificNotation = void 0;
|
7
|
+
var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
|
8
|
+
var _effect = /*#__PURE__*/require("effect");
|
9
|
+
var CVReal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Real.js"));
|
10
|
+
var CVRoundingMode = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./RoundingMode.js"));
|
11
|
+
var CVRoundingOption = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./RoundingOption.js"));
|
12
|
+
function _interopRequireWildcard(e, t) {
|
13
|
+
if ("function" == typeof WeakMap) var r = new WeakMap(),
|
14
|
+
n = new WeakMap();
|
15
|
+
return (_interopRequireWildcard = function (e, t) {
|
16
|
+
if (!t && e && e.__esModule) return e;
|
17
|
+
var o,
|
18
|
+
i,
|
19
|
+
f = {
|
20
|
+
__proto__: null,
|
21
|
+
default: e
|
22
|
+
};
|
23
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return f;
|
24
|
+
if (o = t ? n : r) {
|
25
|
+
if (o.has(e)) return o.get(e);
|
26
|
+
o.set(e, f);
|
27
|
+
}
|
28
|
+
for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
|
29
|
+
return f;
|
30
|
+
})(e, t);
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* This module implements conversions from number to string and string to number in base-10
|
34
|
+
* notation.
|
35
|
+
*/
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Module tag
|
39
|
+
*
|
40
|
+
* @category Module markers
|
41
|
+
*/
|
42
|
+
const moduleTag = exports.moduleTag = '@parischap/conversions/NumberBase10Format/';
|
43
|
+
const _TypeId = /*#__PURE__*/Symbol.for(moduleTag);
|
44
|
+
/**
|
45
|
+
* Possible sign display options
|
46
|
+
*
|
47
|
+
* @category Models
|
48
|
+
*/
|
49
|
+
var SignDisplay;
|
50
|
+
(function (SignDisplay) {
|
51
|
+
/**
|
52
|
+
* Formatting: sign display for negative numbers only, including negative zero.
|
53
|
+
*
|
54
|
+
* Parsing: conversion will fail if a positive sign is used.
|
55
|
+
*/
|
56
|
+
SignDisplay[SignDisplay["Auto"] = 0] = "Auto";
|
57
|
+
/**
|
58
|
+
* Formatting: sign display for all numbers.
|
59
|
+
*
|
60
|
+
* Parsing: conversion will fail if no sign is present
|
61
|
+
*/
|
62
|
+
SignDisplay[SignDisplay["Always"] = 1] = "Always";
|
63
|
+
/**
|
64
|
+
* Formatting: sign display for positive and negative numbers, but not zero
|
65
|
+
*
|
66
|
+
* Parsing: conversion will fail if a sign is not present for a value other than 0 or if a sign is
|
67
|
+
* present for 0.
|
68
|
+
*/
|
69
|
+
SignDisplay[SignDisplay["ExceptZero"] = 2] = "ExceptZero";
|
70
|
+
/**
|
71
|
+
* Formatting: sign display for negative numbers only, excluding negative zero.
|
72
|
+
*
|
73
|
+
* Parsing: conversion will fail if a positive sign is used or if a negative sign is used for 0.
|
74
|
+
*/
|
75
|
+
SignDisplay[SignDisplay["Negative"] = 3] = "Negative";
|
76
|
+
/**
|
77
|
+
* Formatting: no sign display.
|
78
|
+
*
|
79
|
+
* Parsing: conversion will fail if any sign is present. The number will be treated as positive.
|
80
|
+
*/
|
81
|
+
SignDisplay[SignDisplay["Never"] = 4] = "Never";
|
82
|
+
})(SignDisplay || (exports.SignDisplay = SignDisplay = {}));
|
83
|
+
/**
|
84
|
+
* SignDisplay namespace
|
85
|
+
*
|
86
|
+
* @category Models
|
87
|
+
*/
|
88
|
+
(function (SignDisplay) {
|
89
|
+
const isPlusSign = /*#__PURE__*/_effectLib.MPredicate.strictEquals('+');
|
90
|
+
const isMinusSign = /*#__PURE__*/_effectLib.MPredicate.strictEquals('-');
|
91
|
+
const signStringToSignValue = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effect.Option.liftPredicate(isMinusSign), /*#__PURE__*/_effect.Option.as(-1), /*#__PURE__*/_effect.Option.getOrElse(/*#__PURE__*/_effect.Function.constant(1)));
|
92
|
+
const hasASign = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effect.Struct.get('sign'), /*#__PURE__*/_effect.Option.liftPredicate(_effect.String.isNonEmpty), /*#__PURE__*/_effect.Option.map(signStringToSignValue));
|
93
|
+
const hasNoSign = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effect.Struct.get('sign'), /*#__PURE__*/_effect.Option.liftPredicate(_effect.String.isEmpty), /*#__PURE__*/_effect.Option.map(signStringToSignValue));
|
94
|
+
const hasNotPlusSign = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effect.Struct.get('sign'), /*#__PURE__*/_effect.Option.liftPredicate(/*#__PURE__*/_effect.Predicate.not(isPlusSign)), /*#__PURE__*/_effect.Option.map(signStringToSignValue));
|
95
|
+
/**
|
96
|
+
* Builds a `Parser` implementing `self`
|
97
|
+
*
|
98
|
+
* @category Destructors
|
99
|
+
*/
|
100
|
+
SignDisplay.toParser = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Auto, /*#__PURE__*/_effect.Function.constant(hasNotPlusSign)), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Always, /*#__PURE__*/_effect.Function.constant(hasASign)), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.ExceptZero, () => (0, _effect.flow)(_effectLib.MMatch.make, _effectLib.MMatch.when(_effectLib.MPredicate.struct({
|
101
|
+
isZero: _effect.Function.identity
|
102
|
+
}), hasNoSign), _effectLib.MMatch.orElse(hasASign))), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Negative, () => (0, _effect.flow)(_effectLib.MMatch.make, _effectLib.MMatch.when(_effectLib.MPredicate.struct({
|
103
|
+
isZero: _effect.Function.identity
|
104
|
+
}), hasNoSign), _effectLib.MMatch.orElse(hasNotPlusSign))), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Never, /*#__PURE__*/_effect.Function.constant(hasNoSign)), _effectLib.MMatch.exhaustive);
|
105
|
+
/**
|
106
|
+
* Builds a `Formatter` implementing `self`
|
107
|
+
*
|
108
|
+
* @category Destructors
|
109
|
+
*/
|
110
|
+
SignDisplay.toFormatter = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Auto, () => ({
|
111
|
+
sign
|
112
|
+
}) => sign === -1 ? '-' : ''), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Always, () => ({
|
113
|
+
sign
|
114
|
+
}) => sign === -1 ? '-' : '+'), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.ExceptZero, () => ({
|
115
|
+
sign,
|
116
|
+
isZero
|
117
|
+
}) => isZero ? '' : sign === -1 ? '-' : '+'), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Negative, () => ({
|
118
|
+
sign,
|
119
|
+
isZero
|
120
|
+
}) => isZero || sign === 1 ? '' : '-'), /*#__PURE__*/_effectLib.MMatch.whenIs(SignDisplay.Never, () => _effectLib.MFunction.constEmptyString), _effectLib.MMatch.exhaustive);
|
121
|
+
})(SignDisplay || (exports.SignDisplay = SignDisplay = {}));
|
122
|
+
/**
|
123
|
+
* Possible scientific notation options
|
124
|
+
*
|
125
|
+
* @category Models
|
126
|
+
*/
|
127
|
+
var ScientificNotation;
|
128
|
+
(function (ScientificNotation) {
|
129
|
+
/**
|
130
|
+
* Formatting: scientific notation is not used.
|
131
|
+
*
|
132
|
+
* Parsing: conversion will fail if a scientific notation is present.
|
133
|
+
*/
|
134
|
+
ScientificNotation[ScientificNotation["None"] = 0] = "None";
|
135
|
+
/**
|
136
|
+
* Formatting: scientific notation is not used.
|
137
|
+
*
|
138
|
+
* Parsing: scientific notation may be used but is not mandatory.
|
139
|
+
*/
|
140
|
+
ScientificNotation[ScientificNotation["Standard"] = 1] = "Standard";
|
141
|
+
/**
|
142
|
+
* Formatting: scientific notation is used so that the absolute value of the mantissa m fulfills 1
|
143
|
+
* ≤ |m| < 10. Number 0 will be displayed as `0e0`.
|
144
|
+
*
|
145
|
+
* Parsing: the conversion will fail if the mantissa is not null and its value m does not fulfill
|
146
|
+
* 1 ≤ |m| < 10. Scientific notation may be used but is not mandatory. A string that does not
|
147
|
+
* contain a scientific notation is deemed equivalent to a string with a null exponent.
|
148
|
+
*/
|
149
|
+
ScientificNotation[ScientificNotation["Normalized"] = 2] = "Normalized";
|
150
|
+
/**
|
151
|
+
* Formatting: scientific notation is used so that the mantissa m fulfills 1 ≤ |m| < 1000 and the
|
152
|
+
* exponent is a multiple of 3. Number 0 will be displayed as `0e0`.
|
153
|
+
*
|
154
|
+
* Parsing: the conversion will fail if the mantissa is not null and its value m does not fulfill
|
155
|
+
* 1 ≤ |m| < 1000 or if the exponent is not a multiple of 3. Scientific notation may be used but
|
156
|
+
* is not mandatory. A string that does not contain a scientific notation is deemed equivalent to
|
157
|
+
* a string with a null exponent.
|
158
|
+
*/
|
159
|
+
ScientificNotation[ScientificNotation["Engineering"] = 3] = "Engineering";
|
160
|
+
})(ScientificNotation || (exports.ScientificNotation = ScientificNotation = {}));
|
161
|
+
/**
|
162
|
+
* Namespace for possible scientific notation options
|
163
|
+
*
|
164
|
+
* @category Models
|
165
|
+
*/
|
166
|
+
(function (ScientificNotation) {
|
167
|
+
const _stringToExponent = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effect.Option.liftPredicate(_effect.String.isNonEmpty), /*#__PURE__*/_effect.Option.map(_effectLib.MNumber.unsafeFromString), /*#__PURE__*/_effect.Option.orElseSome(/*#__PURE__*/_effect.Function.constant(0)));
|
168
|
+
/**
|
169
|
+
* Builds a `Parser` implementing `self`
|
170
|
+
*
|
171
|
+
* @category Destructors
|
172
|
+
*/
|
173
|
+
ScientificNotation.toParser = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/_effectLib.MMatch.whenIs(ScientificNotation.None, () => (0, _effect.flow)(_effect.Option.liftPredicate(_effect.String.isEmpty), _effect.Option.as(0))), /*#__PURE__*/_effectLib.MMatch.whenIsOr(ScientificNotation.Standard, ScientificNotation.Normalized, /*#__PURE__*/_effect.Function.constant(_stringToExponent)), /*#__PURE__*/_effectLib.MMatch.whenIs(ScientificNotation.Engineering, () => (0, _effect.flow)(_stringToExponent, _effect.Option.filter(_effectLib.MNumber.isMultipleOf(3)))), _effectLib.MMatch.exhaustive);
|
174
|
+
const zeroOrinRange = rangeTop => _effect.Predicate.or(_effect.BigDecimal.isZero, _effect.Predicate.and(_effect.BigDecimal.greaterThanOrEqualTo(_effect.BigDecimal.unsafeFromNumber(1)), _effect.BigDecimal.lessThan(_effect.BigDecimal.unsafeFromNumber(rangeTop))));
|
175
|
+
const zeroOrinOneToTenRange = /*#__PURE__*/zeroOrinRange(10);
|
176
|
+
const zeroOrinOneToOneThousandRange = /*#__PURE__*/zeroOrinRange(1000);
|
177
|
+
/**
|
178
|
+
* Builds a `Parser` implementing `self`
|
179
|
+
*
|
180
|
+
* @category Destructors
|
181
|
+
*/
|
182
|
+
ScientificNotation.toMantissaChecker = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/_effectLib.MMatch.whenIsOr(ScientificNotation.None, ScientificNotation.Standard, () => _effect.Option.some), /*#__PURE__*/_effectLib.MMatch.whenIs(ScientificNotation.Normalized, () => _effect.Option.liftPredicate(zeroOrinOneToTenRange)), /*#__PURE__*/_effectLib.MMatch.whenIs(ScientificNotation.Engineering, () => _effect.Option.liftPredicate(zeroOrinOneToOneThousandRange)), _effectLib.MMatch.exhaustive);
|
183
|
+
/**
|
184
|
+
* Builds a `Parser` implementing `self`
|
185
|
+
*
|
186
|
+
* @category Destructors
|
187
|
+
*/
|
188
|
+
ScientificNotation.toMantissaAdjuster = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/_effectLib.MMatch.whenIsOr(ScientificNotation.None, ScientificNotation.Standard, () => (0, _effect.flow)(_effect.Tuple.make, _effect.Tuple.appendElement(_effect.Option.none()))), /*#__PURE__*/_effectLib.MMatch.whenIs(ScientificNotation.Normalized, () => b => {
|
189
|
+
if (_effect.BigDecimal.isZero(b)) return _effect.Tuple.make(b, _effect.Option.some(0));
|
190
|
+
const value = b.value;
|
191
|
+
const log10 = _effectLib.MBigInt.unsafeLog10(_effect.BigInt.abs(value));
|
192
|
+
return _effect.Tuple.make(_effect.BigDecimal.make(value, log10), _effect.Option.some(log10 - b.scale));
|
193
|
+
}), /*#__PURE__*/_effectLib.MMatch.whenIs(ScientificNotation.Engineering, () => b => {
|
194
|
+
if (_effect.BigDecimal.isZero(b)) return _effect.Tuple.make(b, _effect.Option.some(0));
|
195
|
+
const value = b.value;
|
196
|
+
const log10 = _effectLib.MBigInt.unsafeLog10(_effect.BigInt.abs(value)) - b.scale;
|
197
|
+
const correctedLog10 = log10 - _effectLib.MNumber.intModulo(3)(log10);
|
198
|
+
return _effect.Tuple.make(_effect.BigDecimal.make(value, correctedLog10 + b.scale), _effect.Option.some(correctedLog10));
|
199
|
+
}), _effectLib.MMatch.exhaustive);
|
200
|
+
})(ScientificNotation || (exports.ScientificNotation = ScientificNotation = {}));
|
201
|
+
/**
|
202
|
+
* Type guard
|
203
|
+
*
|
204
|
+
* @category Guards
|
205
|
+
*/
|
206
|
+
const has = u => _effect.Predicate.hasProperty(u, _TypeId);
|
207
|
+
/** Prototype */
|
208
|
+
exports.has = has;
|
209
|
+
const proto = {
|
210
|
+
[_TypeId]: _TypeId,
|
211
|
+
... /*#__PURE__*/_effectLib.MInspectable.BaseProto(moduleTag),
|
212
|
+
..._effectLib.MPipeable.BaseProto
|
213
|
+
};
|
214
|
+
/**
|
215
|
+
* Constructor
|
216
|
+
*
|
217
|
+
* @category Constructors
|
218
|
+
*/
|
219
|
+
const make = params => _effectLib.MTypes.objectFromDataAndProto(proto, params);
|
220
|
+
/**
|
221
|
+
* Returns the `thousandSeparator` property of `self`
|
222
|
+
*
|
223
|
+
* @category Destructors
|
224
|
+
*/
|
225
|
+
exports.make = make;
|
226
|
+
const thousandSeparator = exports.thousandSeparator = /*#__PURE__*/_effect.Struct.get('thousandSeparator');
|
227
|
+
/**
|
228
|
+
* Returns the `fractionalSeparator` property of `self`
|
229
|
+
*
|
230
|
+
* @category Destructors
|
231
|
+
*/
|
232
|
+
const fractionalSeparator = exports.fractionalSeparator = /*#__PURE__*/_effect.Struct.get('fractionalSeparator');
|
233
|
+
/**
|
234
|
+
* Returns the `showNullIntegerPart` property of `self`
|
235
|
+
*
|
236
|
+
* @category Destructors
|
237
|
+
*/
|
238
|
+
const showNullIntegerPart = exports.showNullIntegerPart = /*#__PURE__*/_effect.Struct.get('showNullIntegerPart');
|
239
|
+
/**
|
240
|
+
* Returns the `minimumFractionalDigits` property of `self`
|
241
|
+
*
|
242
|
+
* @category Destructors
|
243
|
+
*/
|
244
|
+
const minimumFractionalDigits = exports.minimumFractionalDigits = /*#__PURE__*/_effect.Struct.get('minimumFractionalDigits');
|
245
|
+
/**
|
246
|
+
* Returns the `maximumFractionalDigits` property of `self`
|
247
|
+
*
|
248
|
+
* @category Destructors
|
249
|
+
*/
|
250
|
+
const maximumFractionalDigits = exports.maximumFractionalDigits = /*#__PURE__*/_effect.Struct.get('maximumFractionalDigits');
|
251
|
+
/**
|
252
|
+
* Returns the `eNotationChar` property of `self`
|
253
|
+
*
|
254
|
+
* @category Destructors
|
255
|
+
*/
|
256
|
+
const eNotationChars = exports.eNotationChars = /*#__PURE__*/_effect.Struct.get('eNotationChars');
|
257
|
+
/**
|
258
|
+
* Returns the `scientificNotation` property of `self`
|
259
|
+
*
|
260
|
+
* @category Destructors
|
261
|
+
*/
|
262
|
+
const scientificNotation = exports.scientificNotation = /*#__PURE__*/_effect.Struct.get('scientificNotation');
|
263
|
+
/**
|
264
|
+
* Returns the `roundingMode` property of `self`
|
265
|
+
*
|
266
|
+
* @category Destructors
|
267
|
+
*/
|
268
|
+
const roundingMode = exports.roundingMode = /*#__PURE__*/_effect.Struct.get('roundingMode');
|
269
|
+
/**
|
270
|
+
* Returns the `signDisplay` property of `self`
|
271
|
+
*
|
272
|
+
* @category Destructors
|
273
|
+
*/
|
274
|
+
const signDisplay = exports.signDisplay = /*#__PURE__*/_effect.Struct.get('signDisplay');
|
275
|
+
/**
|
276
|
+
* Returns a short description of `self`
|
277
|
+
*
|
278
|
+
* @category Destructors
|
279
|
+
*/
|
280
|
+
const toDescription = self => {
|
281
|
+
const {
|
282
|
+
thousandSeparator,
|
283
|
+
fractionalSeparator,
|
284
|
+
minimumFractionalDigits,
|
285
|
+
maximumFractionalDigits,
|
286
|
+
scientificNotation,
|
287
|
+
signDisplay
|
288
|
+
} = self;
|
289
|
+
const isInteger = maximumFractionalDigits <= 0;
|
290
|
+
const isUngrouped = thousandSeparator === '';
|
291
|
+
return (0, _effect.pipe)(signDisplay, _effectLib.MMatch.make, _effectLib.MMatch.whenIs(SignDisplay.Always, _effect.Function.constant('signed ')), _effectLib.MMatch.whenIs(SignDisplay.Never, _effect.Function.constant('unsigned ')), _effectLib.MMatch.orElse(_effect.Function.constant('potentially signed '))) + (isUngrouped && isInteger ? '' : (isUngrouped || thousandSeparator === ' ') && (fractionalSeparator === ',' || isInteger) ? 'French-style ' : thousandSeparator === '.' && (fractionalSeparator === ',' || isInteger) ? 'Dutch-style ' : (isUngrouped || thousandSeparator === ',') && (fractionalSeparator === '.' || isInteger) ? 'UK-style ' : '') + (isInteger ? 'integer' : minimumFractionalDigits === maximumFractionalDigits ? `${minimumFractionalDigits}-decimal number` : 'number') + (0, _effect.pipe)(scientificNotation, _effectLib.MMatch.make, _effectLib.MMatch.whenIs(ScientificNotation.None, _effectLib.MFunction.constEmptyString), _effectLib.MMatch.whenIs(ScientificNotation.Standard, _effect.Function.constant(' in standard scientific notation')), _effectLib.MMatch.whenIs(ScientificNotation.Normalized, _effect.Function.constant(' in normalized scientific notation')), _effectLib.MMatch.whenIs(ScientificNotation.Engineering, _effect.Function.constant(' in engineering notation')), _effectLib.MMatch.exhaustive);
|
292
|
+
};
|
293
|
+
exports.toDescription = toDescription;
|
294
|
+
const _toBigDecimalExtractor = (self, fillChar = '') => {
|
295
|
+
const removeThousandSeparator = _effectLib.MString.removeNCharsEveryMCharsFromRight({
|
296
|
+
m: _effectLib.MRegExpString.DIGIT_GROUP_SIZE,
|
297
|
+
n: self.thousandSeparator.length
|
298
|
+
});
|
299
|
+
const getParts = _effectLib.MString.matchAndGroups((0, _effect.pipe)(self, _effectLib.MStruct.append({
|
300
|
+
fillChar
|
301
|
+
}), _effectLib.MRegExpString.base10Number, _effectLib.MRegExpString.atStart, RegExp), 5);
|
302
|
+
const signParser = SignDisplay.toParser(self.signDisplay);
|
303
|
+
const exponentParser = ScientificNotation.toParser(self.scientificNotation);
|
304
|
+
const mantissaChecker = ScientificNotation.toMantissaChecker(self.scientificNotation);
|
305
|
+
const fillCharIsZero = fillChar === '0';
|
306
|
+
return text => _effect.Option.gen(function* () {
|
307
|
+
const [match, [signPart, fillChars, mantissaIntegerPart, mantissaFractionalPart, exponentPart]] = yield* getParts(text);
|
308
|
+
const mantissaFractionalPartLength = yield* (0, _effect.pipe)(mantissaFractionalPart, _effect.String.length, _effect.Option.liftPredicate(_effect.Number.between({
|
309
|
+
minimum: self.minimumFractionalDigits,
|
310
|
+
maximum: self.maximumFractionalDigits
|
311
|
+
})));
|
312
|
+
const mantissa = yield* (0, _effect.pipe)(mantissaIntegerPart, _effect.Option.liftPredicate(_effect.String.isNonEmpty), _effect.Option.match({
|
313
|
+
// No integer part
|
314
|
+
onNone: () => !self.showNullIntegerPart && mantissaFractionalPartLength !== 0 || fillCharIsZero && fillChars.length !== 0 ? _effect.Option.some(_effectLib.MBigDecimal.zero) : _effect.Option.none(),
|
315
|
+
// With integer part
|
316
|
+
onSome: (0, _effect.flow)(self.showNullIntegerPart || mantissaFractionalPartLength === 0 ? _effect.Option.some : _effect.Option.liftPredicate(_effect.Predicate.not(_effectLib.MPredicate.strictEquals('0'))), _effect.Option.map((0, _effect.flow)(removeThousandSeparator, _effectLib.MBigDecimal.fromPrimitiveOrThrow(0))))
|
317
|
+
}), _effect.Option.map(_effect.BigDecimal.sum((0, _effect.pipe)(mantissaFractionalPart, _effect.Option.liftPredicate(_effect.String.isNonEmpty), _effect.Option.map(_effectLib.MBigDecimal.fromPrimitiveOrThrow(mantissaFractionalPartLength)), _effect.Option.getOrElse(_effect.Function.constant(_effectLib.MBigDecimal.zero))))));
|
318
|
+
const checkedMantissa = yield* mantissaChecker(mantissa);
|
319
|
+
const sign = yield* signParser({
|
320
|
+
isZero: _effect.BigDecimal.isZero(checkedMantissa),
|
321
|
+
sign: signPart
|
322
|
+
});
|
323
|
+
const exponent = yield* exponentParser(exponentPart);
|
324
|
+
return _effect.Tuple.make(_effect.BigDecimal.make(checkedMantissa.value, checkedMantissa.scale - exponent), match, sign);
|
325
|
+
});
|
326
|
+
};
|
327
|
+
/**
|
328
|
+
* Returns a function that tries to parse, from the start of a string `text`, a number respecting
|
329
|
+
* the options represented by `self` and an optional `fillChar` parameter. If successful, that
|
330
|
+
* function returns a `some` containing `parsedText` (the part of `text` that could be analyzed as
|
331
|
+
* representing a number) and `value` (`parsedText` converted to a BigDecimal value). Otherwise, it
|
332
|
+
* returns a `none`. As there is no way to distinguish `-0n` and `0n` in Javascript, parsing '-0',
|
333
|
+
* '0', '+0' will yield the same result.
|
334
|
+
*
|
335
|
+
* `fillChar` is a character that may be used as filler between the sign and the number (or at the
|
336
|
+
* start of the number if it is unsigned). It must be a one-character string (but no error is
|
337
|
+
* triggered if it's not). You can use '0' as `fillChar` but you shoud not use any other digit
|
338
|
+
* because the value of the number to parse would depend on the number of removed `fillChar`'s.
|
339
|
+
*
|
340
|
+
* @category Parsing
|
341
|
+
*/
|
342
|
+
const toBigDecimalExtractor = exports.toBigDecimalExtractor = /*#__PURE__*/(0, _effect.flow)(_toBigDecimalExtractor, /*#__PURE__*/_effect.Function.compose(/*#__PURE__*/_effect.Option.map(([value, parsedText, sign]) => _effect.Tuple.make(_effect.BigDecimal.multiply(value, _effect.BigDecimal.unsafeFromNumber(sign)), parsedText))));
|
343
|
+
/**
|
344
|
+
* Same as toBigDecimalExtractor but the returned parser throws in case of error
|
345
|
+
*
|
346
|
+
* @category Parsing
|
347
|
+
*/
|
348
|
+
const toThrowingBigDecimalExtractor = (self, fillChar) => text => (0, _effect.pipe)(text, toBigDecimalExtractor(self, fillChar), _effect.Option.getOrThrowWith(() => new Error(`A BigDecimal could not be parsed from the start of '${text}'`)));
|
349
|
+
/**
|
350
|
+
* Same as `toBigDecimalExtractor` but returns a `Real` which is the most usual use case.
|
351
|
+
* Furthermore, this function will return -0 if your parse '-0' and 0 if you parse '0' or '+0'.
|
352
|
+
*
|
353
|
+
* @category Parsing
|
354
|
+
*/
|
355
|
+
exports.toThrowingBigDecimalExtractor = toThrowingBigDecimalExtractor;
|
356
|
+
const toRealExtractor = exports.toRealExtractor = /*#__PURE__*/(0, _effect.flow)(_toBigDecimalExtractor, /*#__PURE__*/_effect.Function.compose(/*#__PURE__*/_effect.Option.flatMap(([value, parsedText, sign]) => (0, _effect.pipe)(value, CVReal.fromBigDecimalOption, _effect.Option.map((0, _effect.flow)(_effect.Number.multiply(sign), _effect.Tuple.make, _effect.Tuple.appendElement(parsedText)))))));
|
357
|
+
/**
|
358
|
+
* Same as toRealExtractor but the returned parser throws in case of error
|
359
|
+
*
|
360
|
+
* @category Parsing
|
361
|
+
*/
|
362
|
+
const toThrowingRealExtractor = (self, fillChar) => text => (0, _effect.pipe)(text, toRealExtractor(self, fillChar), _effect.Option.getOrThrowWith(() => new Error(`A Real could not be parsed from the start of '${text}'`)));
|
363
|
+
/**
|
364
|
+
* Same as toBigDecimalExtractor but the whole of the input text must represent a number, not just
|
365
|
+
* its start
|
366
|
+
*
|
367
|
+
* @category Parsing
|
368
|
+
*/
|
369
|
+
exports.toThrowingRealExtractor = toThrowingRealExtractor;
|
370
|
+
const toBigDecimalParser = (self, fillChar) => {
|
371
|
+
const extractor = toBigDecimalExtractor(self, fillChar);
|
372
|
+
return text => (0, _effect.pipe)(text, extractor, _effect.Option.flatMap((0, _effect.flow)(_effect.Option.liftPredicate((0, _effect.flow)(_effect.Tuple.getSecond, _effect.String.length, _effectLib.MPredicate.strictEquals(text.length))), _effect.Option.map(_effect.Tuple.getFirst))));
|
373
|
+
};
|
374
|
+
/**
|
375
|
+
* Same as toRealExtractor but the returned parser throws in case of error
|
376
|
+
*
|
377
|
+
* @category Parsing
|
378
|
+
*/
|
379
|
+
exports.toBigDecimalParser = toBigDecimalParser;
|
380
|
+
const toThrowingBigDecimalParser = (self, fillChar) => text => (0, _effect.pipe)(text, toBigDecimalParser(self, fillChar), _effect.Option.getOrThrowWith(() => new Error(`A BigDecimal could not be parsed from '${text}'`)));
|
381
|
+
/**
|
382
|
+
* Same as `toRealExtractor` but the whole of the input text must represent a number, not just its
|
383
|
+
* start
|
384
|
+
*
|
385
|
+
* @category Parsing
|
386
|
+
*/
|
387
|
+
exports.toThrowingBigDecimalParser = toThrowingBigDecimalParser;
|
388
|
+
const toRealParser = (self, fillChar) => {
|
389
|
+
const extractor = toRealExtractor(self, fillChar);
|
390
|
+
return text => (0, _effect.pipe)(text, extractor, _effect.Option.flatMap((0, _effect.flow)(_effect.Option.liftPredicate((0, _effect.flow)(_effect.Tuple.getSecond, _effect.String.length, _effectLib.MPredicate.strictEquals(text.length))), _effect.Option.map(_effect.Tuple.getFirst))));
|
391
|
+
};
|
392
|
+
/**
|
393
|
+
* Same as toRealParser but the returned parser throws in case of error
|
394
|
+
*
|
395
|
+
* @category Parsing
|
396
|
+
*/
|
397
|
+
exports.toRealParser = toRealParser;
|
398
|
+
const toThrowingRealParser = (self, fillChar) => text => (0, _effect.pipe)(text, toRealParser(self, fillChar), _effect.Option.getOrThrowWith(() => new Error(`A Real could not be parsed from '${text}'`)));
|
399
|
+
/**
|
400
|
+
* Returns a function that tries to format a `number` respecting the options represented by
|
401
|
+
* `self`and an optional parameter `fillChars`. If successful, that function returns a `some` of the
|
402
|
+
* formatted number. Otherwise, it returns a `none`. `number` can be of type number or BigDecimal
|
403
|
+
* for better accuracy. There is a difference between number and BigDecimal (and bigint) regarding
|
404
|
+
* the sign of 0. In Javascript, Object.is(0,-0) is false whereas Object.is(0n,-0n) is true. So if
|
405
|
+
* the sign of zero is important to you, prefer passing a number to the function. `0` as a
|
406
|
+
* BigDecimal will always be interpreted as a positive `0` as we have no means of knowing if it is
|
407
|
+
* negative or positive.
|
408
|
+
*
|
409
|
+
* `fillChars` is a string whose first characters will be inserted between the sign and the number
|
410
|
+
* (or at the start of the number if it is unsigned) so that the formatted number has at least the
|
411
|
+
* same number of characters as fillChars (e.g. the result will be '-02' if you try to format the
|
412
|
+
* value -2 with fillChars = '000')
|
413
|
+
*
|
414
|
+
* @category Formatting
|
415
|
+
*/
|
416
|
+
exports.toThrowingRealParser = toThrowingRealParser;
|
417
|
+
const toNumberFormatter = (self, fillChars = '') => {
|
418
|
+
const rounder = self.maximumFractionalDigits === +Infinity ? _effect.Function.identity : (0, _effect.pipe)({
|
419
|
+
precision: self.maximumFractionalDigits,
|
420
|
+
roundingMode: self.roundingMode
|
421
|
+
}, CVRoundingOption.make, CVRoundingOption.toBigDecimalRounder);
|
422
|
+
const signFormatter = SignDisplay.toFormatter(self.signDisplay);
|
423
|
+
const mantissaAdjuster = ScientificNotation.toMantissaAdjuster(self.scientificNotation);
|
424
|
+
const hasThousandSeparator = self.thousandSeparator !== '';
|
425
|
+
const eNotationChar = (0, _effect.pipe)(self.eNotationChars, _effect.Array.get(0), _effect.Option.getOrElse(_effectLib.MFunction.constEmptyString));
|
426
|
+
const takeNFirstCharsOfFillChars = _effectLib.MFunction.flipDual(_effect.String.takeLeft)(fillChars);
|
427
|
+
return number => {
|
428
|
+
const [sign, selfAsBigDecimal] = _effectLib.MTypes.isNumber(number) ? _effect.Tuple.make(number < 0 || Object.is(-0, number) ? -1 : 1, _effect.BigDecimal.unsafeFromNumber(number)) : _effect.Tuple.make(number.value < 0 ? -1 : 1, number);
|
429
|
+
const [adjusted, exponent] = mantissaAdjuster(selfAsBigDecimal);
|
430
|
+
const absRounded = (0, _effect.pipe)(adjusted, rounder, _effect.BigDecimal.abs);
|
431
|
+
const [integerPart, fractionalPart] = (0, _effect.pipe)(absRounded, _effectLib.MBigDecimal.truncatedAndFollowingParts());
|
432
|
+
const signString = signFormatter({
|
433
|
+
sign,
|
434
|
+
isZero: _effect.BigDecimal.isZero(absRounded)
|
435
|
+
});
|
436
|
+
const normalizedFractionalPart = _effect.BigDecimal.normalize(fractionalPart);
|
437
|
+
const fractionalPartString = (0, _effect.pipe)(normalizedFractionalPart.value, _effect.Option.liftPredicate(_effect.Predicate.not(_effectLib.MBigInt.isZero)), _effect.Option.map(_effectLib.MString.fromNonNullablePrimitive), _effect.Option.getOrElse(_effectLib.MFunction.constEmptyString), _effect.String.padStart(normalizedFractionalPart.scale, '0'), _effect.String.padEnd(self.minimumFractionalDigits, '0'), _effect.Option.liftPredicate(_effect.String.isNonEmpty), _effect.Option.map(_effectLib.MString.prepend(self.fractionalSeparator)), _effect.Option.getOrElse(_effectLib.MFunction.constEmptyString));
|
438
|
+
const integerPartString = (0, _effect.pipe)(integerPart.value.toString(), _effectLib.MFunction.fIfTrue({
|
439
|
+
condition: hasThousandSeparator,
|
440
|
+
f: (0, _effect.flow)(_effectLib.MString.splitEquallyRestAtStart(_effectLib.MRegExpString.DIGIT_GROUP_SIZE), _effect.Array.intersperse(self.thousandSeparator), _effect.Array.join(''))
|
441
|
+
}), _effect.Either.liftPredicate(_effect.Predicate.not(_effectLib.MPredicate.strictEquals('0')), _effectLib.MFunction.fIfTrue({
|
442
|
+
condition: !self.showNullIntegerPart && fractionalPartString.length !== 0,
|
443
|
+
f: _effectLib.MFunction.constEmptyString
|
444
|
+
})), _effect.Either.merge);
|
445
|
+
const exponentString = (0, _effect.pipe)(exponent, _effect.Option.map((0, _effect.flow)(_effectLib.MString.fromNumber(10), _effectLib.MString.prepend(eNotationChar))), _effect.Option.getOrElse(_effectLib.MFunction.constEmptyString));
|
446
|
+
const numberString = integerPartString + fractionalPartString + exponentString;
|
447
|
+
const pad = (0, _effect.pipe)(fillChars.length, _effect.Number.subtract(signString.length), _effect.Number.subtract(numberString.length), _effect.Number.max(0), takeNFirstCharsOfFillChars);
|
448
|
+
return signString + pad + numberString;
|
449
|
+
};
|
450
|
+
};
|
451
|
+
/**
|
452
|
+
* Combinator that returns a copy of self with `minimumFractionalDigits` and
|
453
|
+
* `maximumFractionalDigits` set to `n`. `n` must be a finite positive integer.
|
454
|
+
*
|
455
|
+
* @category Modifiers
|
456
|
+
*/
|
457
|
+
exports.toNumberFormatter = toNumberFormatter;
|
458
|
+
const withNDecimals = decimalNumber => (0, _effect.flow)(_effectLib.MStruct.append({
|
459
|
+
minimumFractionalDigits: decimalNumber,
|
460
|
+
maximumFractionalDigits: decimalNumber
|
461
|
+
}), make);
|
462
|
+
/**
|
463
|
+
* Combinator that returns a copy of self with `maximumFractionalDigits` set to `n`. `n` must be a
|
464
|
+
* positive integer. Pass 0 for an integer format.
|
465
|
+
*
|
466
|
+
* @category Modifiers
|
467
|
+
*/
|
468
|
+
exports.withNDecimals = withNDecimals;
|
469
|
+
const withMaxNDecimals = maxDecimalNumber => self => (0, _effect.pipe)(self, _effectLib.MStruct.append({
|
470
|
+
minimumFractionalDigits: Math.min(self.minimumFractionalDigits, maxDecimalNumber),
|
471
|
+
maximumFractionalDigits: maxDecimalNumber
|
472
|
+
}), make);
|
473
|
+
/**
|
474
|
+
* Combinator that returns a copy of self with `minimumFractionalDigits` set to `n`. `n` must be a
|
475
|
+
* finite positive integer.
|
476
|
+
*
|
477
|
+
* @category Modifiers
|
478
|
+
*/
|
479
|
+
exports.withMaxNDecimals = withMaxNDecimals;
|
480
|
+
const withMinNDecimals = minDecimalNumber => self => (0, _effect.pipe)(self, _effectLib.MStruct.append({
|
481
|
+
minimumFractionalDigits: minDecimalNumber,
|
482
|
+
maximumFractionalDigits: Math.max(self.maximumFractionalDigits, minDecimalNumber)
|
483
|
+
}), make);
|
484
|
+
/**
|
485
|
+
* Combinator that returns a copy of self with `scientificNotation` set to `None`.
|
486
|
+
*
|
487
|
+
* @category Modifiers
|
488
|
+
*/
|
489
|
+
exports.withMinNDecimals = withMinNDecimals;
|
490
|
+
const withNoScientificNotation = exports.withNoScientificNotation = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
491
|
+
scientificNotation: ScientificNotation.None
|
492
|
+
}), make);
|
493
|
+
/**
|
494
|
+
* Combinator that returns a copy of self with `scientificNotation` set to `Standard`.
|
495
|
+
*
|
496
|
+
* @category Modifiers
|
497
|
+
*/
|
498
|
+
const withStandardScientificNotation = exports.withStandardScientificNotation = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
499
|
+
scientificNotation: ScientificNotation.Standard
|
500
|
+
}), make);
|
501
|
+
/**
|
502
|
+
* Combinator that returns a copy of self with `scientificNotation` set to `Normalized`.
|
503
|
+
*
|
504
|
+
* @category Modifiers
|
505
|
+
*/
|
506
|
+
const withNormalizedScientificNotation = exports.withNormalizedScientificNotation = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
507
|
+
scientificNotation: ScientificNotation.Normalized
|
508
|
+
}), make);
|
509
|
+
/**
|
510
|
+
* Combinator that returns a copy of self with `scientificNotation` set to `Engineering`.
|
511
|
+
*
|
512
|
+
* @category Modifiers
|
513
|
+
*/
|
514
|
+
const withEngineeringScientificNotation = exports.withEngineeringScientificNotation = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
515
|
+
scientificNotation: ScientificNotation.Engineering
|
516
|
+
}), make);
|
517
|
+
/**
|
518
|
+
* Combinator that returns a copy of self with `thousandSeparator` set to `thousandSeparator`.
|
519
|
+
*
|
520
|
+
* @category Modifiers
|
521
|
+
*/
|
522
|
+
const withThousandSeparator = thousandSeparator => (0, _effect.flow)(_effectLib.MStruct.append({
|
523
|
+
thousandSeparator
|
524
|
+
}), make);
|
525
|
+
/**
|
526
|
+
* Combinator that returns a copy of self with `thousandSeparator` set to ''.
|
527
|
+
*
|
528
|
+
* @category Modifiers
|
529
|
+
*/
|
530
|
+
exports.withThousandSeparator = withThousandSeparator;
|
531
|
+
const withoutThousandSeparator = exports.withoutThousandSeparator = /*#__PURE__*/withThousandSeparator('');
|
532
|
+
/**
|
533
|
+
* Combinator that returns a copy of self with `fractionalSeparator` set to `fractionalSeparator`.
|
534
|
+
*
|
535
|
+
* @category Modifiers
|
536
|
+
*/
|
537
|
+
const withFractionalSeparator = fractionalSeparator => (0, _effect.flow)(_effectLib.MStruct.append({
|
538
|
+
fractionalSeparator: fractionalSeparator
|
539
|
+
}), make);
|
540
|
+
/**
|
541
|
+
* Combinator that returns a copy of self with `signDisplay` set to `Auto`.
|
542
|
+
*
|
543
|
+
* @category Modifiers
|
544
|
+
*/
|
545
|
+
exports.withFractionalSeparator = withFractionalSeparator;
|
546
|
+
const withSignDisplayForNegative = exports.withSignDisplayForNegative = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
547
|
+
signDisplay: SignDisplay.Auto
|
548
|
+
}), make);
|
549
|
+
/**
|
550
|
+
* Combinator that returns a copy of self with `signDisplay` set to `Always`.
|
551
|
+
*
|
552
|
+
* @category Modifiers
|
553
|
+
*/
|
554
|
+
const withSignDisplay = exports.withSignDisplay = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
555
|
+
signDisplay: SignDisplay.Always
|
556
|
+
}), make);
|
557
|
+
/**
|
558
|
+
* Combinator that returns a copy of self with `signDisplay` set to `ExceptZero`.
|
559
|
+
*
|
560
|
+
* @category Modifiers
|
561
|
+
*/
|
562
|
+
const withSignDisplayExceptZero = exports.withSignDisplayExceptZero = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
563
|
+
signDisplay: SignDisplay.ExceptZero
|
564
|
+
}), make);
|
565
|
+
/**
|
566
|
+
* Combinator that returns a copy of self with `signDisplay` set to `Negative`.
|
567
|
+
*
|
568
|
+
* @category Modifiers
|
569
|
+
*/
|
570
|
+
const withSignDisplayForNegativeExceptZero = exports.withSignDisplayForNegativeExceptZero = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
571
|
+
signDisplay: SignDisplay.Negative
|
572
|
+
}), make);
|
573
|
+
/**
|
574
|
+
* Combinator that returns a copy of self with `signDisplay` set to `Never`.
|
575
|
+
*
|
576
|
+
* @category Modifiers
|
577
|
+
*/
|
578
|
+
const withoutSignDisplay = exports.withoutSignDisplay = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
579
|
+
signDisplay: SignDisplay.Never
|
580
|
+
}), make);
|
581
|
+
/**
|
582
|
+
* Combinator that returns a copy of self with `roundingMode` set to `Ceil`.
|
583
|
+
*
|
584
|
+
* @category Modifiers
|
585
|
+
*/
|
586
|
+
const withCeilRoundingMode = exports.withCeilRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
587
|
+
roundingMode: CVRoundingMode.Type.Ceil
|
588
|
+
}), make);
|
589
|
+
/**
|
590
|
+
* Combinator that returns a copy of self with `roundingMode` set to `Floor`.
|
591
|
+
*
|
592
|
+
* @category Modifiers
|
593
|
+
*/
|
594
|
+
const withFloorRoundingMode = exports.withFloorRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
595
|
+
roundingMode: CVRoundingMode.Type.Floor
|
596
|
+
}), make);
|
597
|
+
/**
|
598
|
+
* Combinator that returns a copy of self with `roundingMode` set to `Expand`.
|
599
|
+
*
|
600
|
+
* @category Modifiers
|
601
|
+
*/
|
602
|
+
const withExpandRoundingMode = exports.withExpandRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
603
|
+
roundingMode: CVRoundingMode.Type.Expand
|
604
|
+
}), make);
|
605
|
+
/**
|
606
|
+
* Combinator that returns a copy of self with `roundingMode` set to `Trunc`.
|
607
|
+
*
|
608
|
+
* @category Modifiers
|
609
|
+
*/
|
610
|
+
const withTruncRoundingMode = exports.withTruncRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
611
|
+
roundingMode: CVRoundingMode.Type.Trunc
|
612
|
+
}), make);
|
613
|
+
/**
|
614
|
+
* Combinator that returns a copy of self with `roundingMode` set to `HalfCeil`.
|
615
|
+
*
|
616
|
+
* @category Modifiers
|
617
|
+
*/
|
618
|
+
const withHalfCeilRoundingMode = exports.withHalfCeilRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
619
|
+
roundingMode: CVRoundingMode.Type.HalfCeil
|
620
|
+
}), make);
|
621
|
+
/**
|
622
|
+
* Combinator that returns a copy of self with `roundingMode` set to `HalfFloor`.
|
623
|
+
*
|
624
|
+
* @category Modifiers
|
625
|
+
*/
|
626
|
+
const withHalfFloorRoundingMode = exports.withHalfFloorRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
627
|
+
roundingMode: CVRoundingMode.Type.HalfFloor
|
628
|
+
}), make);
|
629
|
+
/**
|
630
|
+
* Combinator that returns a copy of self with `roundingMode` set to `HalfExpand`.
|
631
|
+
*
|
632
|
+
* @category Modifiers
|
633
|
+
*/
|
634
|
+
const withHalfExpandRoundingMode = exports.withHalfExpandRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
635
|
+
roundingMode: CVRoundingMode.Type.HalfExpand
|
636
|
+
}), make);
|
637
|
+
/**
|
638
|
+
* Combinator that returns a copy of self with `roundingMode` set to `HalfTrunc`.
|
639
|
+
*
|
640
|
+
* @category Modifiers
|
641
|
+
*/
|
642
|
+
const withHalfTruncRoundingMode = exports.withHalfTruncRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
643
|
+
roundingMode: CVRoundingMode.Type.HalfTrunc
|
644
|
+
}), make);
|
645
|
+
/**
|
646
|
+
* Combinator that returns a copy of self with `roundingMode` set to `HalfEven`.
|
647
|
+
*
|
648
|
+
* @category Modifiers
|
649
|
+
*/
|
650
|
+
const withHalfEvenRoundingMode = exports.withHalfEvenRoundingMode = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
651
|
+
roundingMode: CVRoundingMode.Type.HalfEven
|
652
|
+
}), make);
|
653
|
+
/**
|
654
|
+
* Combinator that returns a copy of self with `showNullIntegerPart` set to `false`.
|
655
|
+
*
|
656
|
+
* @category Modifiers
|
657
|
+
*/
|
658
|
+
const withNullIntegerPartNotShowing = exports.withNullIntegerPartNotShowing = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
659
|
+
showNullIntegerPart: false
|
660
|
+
}), make);
|
661
|
+
/**
|
662
|
+
* Combinator that returns a copy of self with `showNullIntegerPart` set to `true`.
|
663
|
+
*
|
664
|
+
* @category Modifiers
|
665
|
+
*/
|
666
|
+
const withNullIntegerPartShowing = exports.withNullIntegerPartShowing = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.append({
|
667
|
+
showNullIntegerPart: true
|
668
|
+
}), make);
|
669
|
+
/**
|
670
|
+
* NumberBase10Format instance that uses a comma as fractional separator, a space as thousand
|
671
|
+
* separator and shows at most three fractional digits. Used in countries like France,
|
672
|
+
* French-speaking Canada, French-speaking Belgium, Denmark, Finland, Sweden...
|
673
|
+
*
|
674
|
+
* @category Instances
|
675
|
+
*/
|
676
|
+
const frenchStyleNumber = exports.frenchStyleNumber = /*#__PURE__*/make({
|
677
|
+
thousandSeparator: ' ',
|
678
|
+
fractionalSeparator: ',',
|
679
|
+
showNullIntegerPart: true,
|
680
|
+
minimumFractionalDigits: 0,
|
681
|
+
maximumFractionalDigits: 3,
|
682
|
+
eNotationChars: ['e', 'E'],
|
683
|
+
scientificNotation: ScientificNotation.None,
|
684
|
+
roundingMode: CVRoundingMode.Type.HalfExpand,
|
685
|
+
signDisplay: SignDisplay.Negative
|
686
|
+
});
|
687
|
+
/**
|
688
|
+
* NumberBase10Format instance that uses a comma as fractional separator, no thousand separator and
|
689
|
+
* shows at most three fractional digits. Used in countries like France, French-speaking Canada,
|
690
|
+
* French-speaking Belgium, Denmark, Finland, Sweden...
|
691
|
+
*
|
692
|
+
* @category Instances
|
693
|
+
*/
|
694
|
+
const frenchStyleUngroupedNumber = exports.frenchStyleUngroupedNumber = /*#__PURE__*/(0, _effect.pipe)(frenchStyleNumber, withoutThousandSeparator);
|
695
|
+
/**
|
696
|
+
* French-style integer NumberBase10Format instance. Used in countries like France, French-speaking
|
697
|
+
* Canada, French-speaking Belgium, Denmark, Finland, Sweden...
|
698
|
+
*
|
699
|
+
* @category Instances
|
700
|
+
*/
|
701
|
+
const frenchStyleInteger = exports.frenchStyleInteger = /*#__PURE__*/(0, _effect.pipe)(frenchStyleNumber, /*#__PURE__*/withMaxNDecimals(0));
|
702
|
+
/**
|
703
|
+
* NumberBase10Format instance that uses a comma as fractional separator, a dot as thousand
|
704
|
+
* separator and shows at most three fractional digits. Used in countries like Dutch-speaking
|
705
|
+
* Belgium, the Netherlands, Germany, Italy, Norway, Croatia, Spain...
|
706
|
+
*
|
707
|
+
* @category Instances
|
708
|
+
*/
|
709
|
+
const dutchStyleNumber = exports.dutchStyleNumber = /*#__PURE__*/(0, _effect.pipe)(frenchStyleNumber, /*#__PURE__*/_effectLib.MStruct.append({
|
710
|
+
thousandSeparator: '.'
|
711
|
+
}), make);
|
712
|
+
/**
|
713
|
+
* NumberBase10Format instance that uses a comma as fractional separator, no thousand separator and
|
714
|
+
* shows at most three fractional digits. Used in countries like Dutch-speaking Belgium, the
|
715
|
+
* Netherlands, Germany, Italy, Norway, Croatia, Spain...
|
716
|
+
*
|
717
|
+
* @category Instances
|
718
|
+
*/
|
719
|
+
const dutchStyleUngroupedNumber = exports.dutchStyleUngroupedNumber = /*#__PURE__*/(0, _effect.pipe)(dutchStyleNumber, withoutThousandSeparator);
|
720
|
+
/**
|
721
|
+
* Dutch-style integer NumberBase10Format instance. Used in countries like Dutch-speaking Belgium,
|
722
|
+
* the Netherlands, Germany, Italy, Norway, Croatia, Spain...
|
723
|
+
*
|
724
|
+
* @category Instances
|
725
|
+
*/
|
726
|
+
const dutchStyleInteger = exports.dutchStyleInteger = /*#__PURE__*/(0, _effect.pipe)(dutchStyleNumber, /*#__PURE__*/withMaxNDecimals(0));
|
727
|
+
/**
|
728
|
+
* NumberBase10Format instance that uses a dot as fractional separator, a comma as thousand
|
729
|
+
* separator and shows at most three fractional digits. Used in countries like the UK, the US,
|
730
|
+
* English-speaking Canada, Australia, Thaïland, Bosnia...
|
731
|
+
*
|
732
|
+
* @category Instances
|
733
|
+
*/
|
734
|
+
const ukStyleNumber = exports.ukStyleNumber = /*#__PURE__*/(0, _effect.pipe)(frenchStyleNumber, /*#__PURE__*/_effectLib.MStruct.append({
|
735
|
+
fractionalSeparator: '.',
|
736
|
+
thousandSeparator: ','
|
737
|
+
}), make);
|
738
|
+
/**
|
739
|
+
* NumberBase10Format instance that uses a dot as fractional separator, no thousand separator and
|
740
|
+
* shows at most three fractional digits. Used in countries like the UK, the US, English-speaking
|
741
|
+
* Canada, Australia, Thaïland, Bosnia...
|
742
|
+
*
|
743
|
+
* @category Instances
|
744
|
+
*/
|
745
|
+
const ukStyleUngroupedNumber = exports.ukStyleUngroupedNumber = /*#__PURE__*/(0, _effect.pipe)(ukStyleNumber, withoutThousandSeparator);
|
746
|
+
/**
|
747
|
+
* Uk-style integer NumberBase10Format instance. Used in countries like the UK, the US,
|
748
|
+
* English-speaking Canada, Australia, Thaïland, Bosnia...
|
749
|
+
*
|
750
|
+
* @category Instances
|
751
|
+
*/
|
752
|
+
const ukStyleInteger = exports.ukStyleInteger = /*#__PURE__*/(0, _effect.pipe)(ukStyleNumber, /*#__PURE__*/withMaxNDecimals(0));
|
753
|
+
/**
|
754
|
+
* Integer NumberBase10Format instance with no thousand separator
|
755
|
+
*
|
756
|
+
* @category Instances
|
757
|
+
*/
|
758
|
+
const integer = exports.integer = /*#__PURE__*/(0, _effect.pipe)(frenchStyleInteger, withoutThousandSeparator);
|
759
|
+
//# sourceMappingURL=NumberBase10Format.js.map
|