@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,161 @@
|
|
1
|
+
/**
|
2
|
+
* This module implements a finite integer brand (Infinity, NaN or non-null fractional part
|
3
|
+
* disallowed)
|
4
|
+
*/
|
5
|
+
import { MTypes } from '@parischap/effect-lib';
|
6
|
+
import { BigDecimal, Brand, Either, Option } from 'effect';
|
7
|
+
import * as CVInteger from './Integer.js';
|
8
|
+
import * as CVPositive from './internal/Positive.js';
|
9
|
+
import type * as CVPositiveReal from './PositiveReal.js';
|
10
|
+
import * as CVReal from './Real.js';
|
11
|
+
/**
|
12
|
+
* Module tag
|
13
|
+
*
|
14
|
+
* @category Module markers
|
15
|
+
*/
|
16
|
+
export declare const moduleTag = "@parischap/conversions/PositiveInteger/";
|
17
|
+
/**
|
18
|
+
* Brand constructor. Should not be used directly
|
19
|
+
*
|
20
|
+
* @category Constructors
|
21
|
+
*/
|
22
|
+
export declare const constructor: Brand.Brand.Constructor<number & Brand.Brand<typeof CVPositive._TypeId> & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof import("./internal/Int.js")._TypeId>>;
|
23
|
+
/**
|
24
|
+
* Integer type
|
25
|
+
*
|
26
|
+
* @category Models
|
27
|
+
*/
|
28
|
+
export type Type = Brand.Brand.FromConstructor<typeof constructor>;
|
29
|
+
/**
|
30
|
+
* Constructs a PositiveInteger from a number without any verifications
|
31
|
+
*
|
32
|
+
* @category Constructors
|
33
|
+
*/
|
34
|
+
export declare const unsafeFromNumber: Brand.Brand.Constructor<number & Brand.Brand<typeof CVPositive._TypeId> & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof import("./internal/Int.js")._TypeId>>;
|
35
|
+
/**
|
36
|
+
* Constructs an Option of a PositiveInteger from a number
|
37
|
+
*
|
38
|
+
* @category Constructors
|
39
|
+
*/
|
40
|
+
export declare const fromNumberOption: MTypes.OneArgFunction<number, Option.Option<Type>>;
|
41
|
+
/**
|
42
|
+
* Constructs an Either of a PositiveInteger from a number
|
43
|
+
*
|
44
|
+
* @category Constructors
|
45
|
+
*/
|
46
|
+
export declare const fromNumber: MTypes.OneArgFunction<number, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
47
|
+
/**
|
48
|
+
* Constructs a PositiveInteger from a number or throws
|
49
|
+
*
|
50
|
+
* @category Constructors
|
51
|
+
*/
|
52
|
+
export declare const fromNumberOrThrow: MTypes.OneArgFunction<number, Type>;
|
53
|
+
/**
|
54
|
+
* Constructs a PositiveInteger from a BigDecimal without any checks
|
55
|
+
*
|
56
|
+
* @category Constructors
|
57
|
+
*/
|
58
|
+
export declare const unsafeFromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>;
|
59
|
+
/**
|
60
|
+
* Constructs an Option of a PositiveInteger from a BigDecimal
|
61
|
+
*
|
62
|
+
* @category Constructors
|
63
|
+
*/
|
64
|
+
export declare const fromBigDecimalOption: MTypes.OneArgFunction<BigDecimal.BigDecimal, Option.Option<Type>>;
|
65
|
+
/**
|
66
|
+
* Constructs an Either of a PositiveInteger from a BigDecimal
|
67
|
+
*
|
68
|
+
* @category Constructors
|
69
|
+
*/
|
70
|
+
export declare const fromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
71
|
+
/**
|
72
|
+
* Constructs a PositiveInteger from a BigDecimal or throws
|
73
|
+
*
|
74
|
+
* @category Constructors
|
75
|
+
*/
|
76
|
+
export declare const fromBigDecimalOrThrow: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>;
|
77
|
+
/**
|
78
|
+
* Constructs a PositiveInteger from a BigInt without any checks
|
79
|
+
*
|
80
|
+
* @category Constructors
|
81
|
+
*/
|
82
|
+
export declare const unsafeFromBigInt: MTypes.OneArgFunction<bigint, Type>;
|
83
|
+
/**
|
84
|
+
* Constructs an Option of a PositiveInteger from a BigInt
|
85
|
+
*
|
86
|
+
* @category Constructors
|
87
|
+
*/
|
88
|
+
export declare const fromBigIntOption: MTypes.OneArgFunction<bigint, Option.Option<Type>>;
|
89
|
+
/**
|
90
|
+
* Constructs an Either of a PositiveInteger from a BigInt
|
91
|
+
*
|
92
|
+
* @category Constructors
|
93
|
+
*/
|
94
|
+
export declare const fromBigInt: MTypes.OneArgFunction<bigint, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
95
|
+
/**
|
96
|
+
* Constructs a PositiveInteger from a BigInt or throws
|
97
|
+
*
|
98
|
+
* @category Constructors
|
99
|
+
*/
|
100
|
+
export declare const fromBigIntOrThrow: MTypes.OneArgFunction<bigint, Type>;
|
101
|
+
/**
|
102
|
+
* Constructs a PositiveInteger from a Real without any checks
|
103
|
+
*
|
104
|
+
* @category Constructors
|
105
|
+
*/
|
106
|
+
export declare const unsafeFromReal: MTypes.OneArgFunction<CVReal.Type, Type>;
|
107
|
+
/**
|
108
|
+
* Constructs an Option of a PositiveInteger from a Real
|
109
|
+
*
|
110
|
+
* @category Constructors
|
111
|
+
*/
|
112
|
+
export declare const fromRealOption: MTypes.OneArgFunction<CVReal.Type, Option.Option<Type>>;
|
113
|
+
/**
|
114
|
+
* Constructs an Either of a PositiveInteger from a Real
|
115
|
+
*
|
116
|
+
* @category Constructors
|
117
|
+
*/
|
118
|
+
export declare const fromReal: MTypes.OneArgFunction<CVReal.Type, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
119
|
+
/**
|
120
|
+
* Constructs a PositiveInteger from a Real or throws
|
121
|
+
*
|
122
|
+
* @category Constructors
|
123
|
+
*/
|
124
|
+
export declare const fromRealOrThrow: MTypes.OneArgFunction<CVReal.Type, Type>;
|
125
|
+
/**
|
126
|
+
* Constructs an Option of a PositiveInteger from an Integer
|
127
|
+
*
|
128
|
+
* @category Constructors
|
129
|
+
*/
|
130
|
+
export declare const fromIntegerOption: MTypes.OneArgFunction<CVInteger.Type, Option.Option<Type>>;
|
131
|
+
/**
|
132
|
+
* Constructs an Either of a PositiveInteger from an Integer
|
133
|
+
*
|
134
|
+
* @category Constructors
|
135
|
+
*/
|
136
|
+
export declare const fromInteger: MTypes.OneArgFunction<CVInteger.Type, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
137
|
+
/**
|
138
|
+
* Constructs a PositiveInteger from an Integer or throws
|
139
|
+
*
|
140
|
+
* @category Constructors
|
141
|
+
*/
|
142
|
+
export declare const fromIntegerOrThrow: MTypes.OneArgFunction<CVInteger.Type, Type>;
|
143
|
+
/**
|
144
|
+
* Constructs an Option of a PositiveInteger from a PositiveReal
|
145
|
+
*
|
146
|
+
* @category Constructors
|
147
|
+
*/
|
148
|
+
export declare const fromPositiveRealOption: MTypes.OneArgFunction<CVPositiveReal.Type, Option.Option<Type>>;
|
149
|
+
/**
|
150
|
+
* Constructs an Either of a PositiveInteger from a PositiveReal
|
151
|
+
*
|
152
|
+
* @category Constructors
|
153
|
+
*/
|
154
|
+
export declare const fromPositiveReal: MTypes.OneArgFunction<CVPositiveReal.Type, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
155
|
+
/**
|
156
|
+
* Constructs a PositiveInteger from a PositiveReal or throws
|
157
|
+
*
|
158
|
+
* @category Constructors
|
159
|
+
*/
|
160
|
+
export declare const fromPositiveRealOrThrow: MTypes.OneArgFunction<CVPositiveReal.Type, Type>;
|
161
|
+
//# sourceMappingURL=PositiveInteger.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PositiveInteger.d.ts","sourceRoot":"","sources":["../../esm/PositiveInteger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,EAAU,MAAM,QAAQ,CAAC;AACnF,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,KAAK,cAAc,MAAM,mB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,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,cAAc,CAC9C,SAAS,CAAC,IAAI,EACd,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CACX,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAEjE,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,cAAc,CACzD,cAAc,CAAC,IAAI,EACnB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CACuB,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,CACnD,cAAc,CAAC,IAAI,EACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CACd,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAE3E,CAAC"}
|
@@ -0,0 +1,130 @@
|
|
1
|
+
/**
|
2
|
+
* This module implements a positive finite number brand (NaN, Infinity and negative numbers
|
3
|
+
* disallowed). Useful for a price, a physical quantity...
|
4
|
+
*/
|
5
|
+
import { MTypes } from '@parischap/effect-lib';
|
6
|
+
import { BigDecimal, Brand, Either, Option } from 'effect';
|
7
|
+
import * as CVPositive from './internal/Positive.js';
|
8
|
+
import type * as CVPositiveInteger from './PositiveInteger.js';
|
9
|
+
import * as CVReal from './Real.js';
|
10
|
+
/**
|
11
|
+
* Module tag
|
12
|
+
*
|
13
|
+
* @category Module markers
|
14
|
+
*/
|
15
|
+
export declare const moduleTag = "@parischap/conversions/PositiveReal/";
|
16
|
+
/**
|
17
|
+
* Brand constructor. Should not be used directly
|
18
|
+
*
|
19
|
+
* @category Constructors
|
20
|
+
*/
|
21
|
+
export declare const constructor: Brand.Brand.Constructor<number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof CVPositive._TypeId>>;
|
22
|
+
/**
|
23
|
+
* PositiveReal type
|
24
|
+
*
|
25
|
+
* @category Models
|
26
|
+
*/
|
27
|
+
export type Type = Brand.Brand.FromConstructor<typeof constructor>;
|
28
|
+
/**
|
29
|
+
* Constructs a PositiveReal from a number without any verifications
|
30
|
+
*
|
31
|
+
* @category Constructors
|
32
|
+
*/
|
33
|
+
export declare const unsafeFromNumber: Brand.Brand.Constructor<number & Brand.Brand<typeof CVReal.TypeId> & Brand.Brand<typeof CVPositive._TypeId>>;
|
34
|
+
/**
|
35
|
+
* Constructs an Option of a PositiveReal from a number
|
36
|
+
*
|
37
|
+
* @category Constructors
|
38
|
+
*/
|
39
|
+
export declare const fromNumberOption: MTypes.OneArgFunction<number, Option.Option<Type>>;
|
40
|
+
/**
|
41
|
+
* Constructs an Either of a PositiveReal from a number
|
42
|
+
*
|
43
|
+
* @category Constructors
|
44
|
+
*/
|
45
|
+
export declare const fromNumber: MTypes.OneArgFunction<number, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
46
|
+
/**
|
47
|
+
* Constructs a PositiveReal from a number or throws
|
48
|
+
*
|
49
|
+
* @category Constructors
|
50
|
+
*/
|
51
|
+
export declare const fromNumberOrThrow: MTypes.OneArgFunction<number, Type>;
|
52
|
+
/**
|
53
|
+
* Constructs a PositiveReal from a BigDecimal without any checks
|
54
|
+
*
|
55
|
+
* @category Constructors
|
56
|
+
*/
|
57
|
+
export declare const unsafeFromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>;
|
58
|
+
/**
|
59
|
+
* Constructs an Option of a PositiveReal from a BigDecimal
|
60
|
+
*
|
61
|
+
* @category Constructors
|
62
|
+
*/
|
63
|
+
export declare const fromBigDecimalOption: MTypes.OneArgFunction<BigDecimal.BigDecimal, Option.Option<Type>>;
|
64
|
+
/**
|
65
|
+
* Constructs an Either of a PositiveReal from a BigDecimal
|
66
|
+
*
|
67
|
+
* @category Constructors
|
68
|
+
*/
|
69
|
+
export declare const fromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
70
|
+
/**
|
71
|
+
* Constructs a PositiveReal from a BigDecimal or throws
|
72
|
+
*
|
73
|
+
* @category Constructors
|
74
|
+
*/
|
75
|
+
export declare const fromBigDecimalOrThrow: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>;
|
76
|
+
/**
|
77
|
+
* Constructs a PositiveReal from a BigInt without any checks
|
78
|
+
*
|
79
|
+
* @category Constructors
|
80
|
+
*/
|
81
|
+
export declare const unsafeFromBigInt: MTypes.OneArgFunction<bigint, Type>;
|
82
|
+
/**
|
83
|
+
* Constructs an Option of a PositiveReal from a BigInt
|
84
|
+
*
|
85
|
+
* @category Constructors
|
86
|
+
*/
|
87
|
+
export declare const fromBigIntOption: MTypes.OneArgFunction<bigint, Option.Option<Type>>;
|
88
|
+
/**
|
89
|
+
* Constructs an Either of a PositiveReal from a BigInt
|
90
|
+
*
|
91
|
+
* @category Constructors
|
92
|
+
*/
|
93
|
+
export declare const fromBigInt: MTypes.OneArgFunction<bigint, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
94
|
+
/**
|
95
|
+
* Constructs a PositiveReal from a BigInt or throws
|
96
|
+
*
|
97
|
+
* @category Constructors
|
98
|
+
*/
|
99
|
+
export declare const fromBigIntOrThrow: MTypes.OneArgFunction<bigint, Type>;
|
100
|
+
/**
|
101
|
+
* Constructs a PositiveReal from a Real without any checks
|
102
|
+
*
|
103
|
+
* @category Constructors
|
104
|
+
*/
|
105
|
+
export declare const unsafeFromReal: MTypes.OneArgFunction<CVReal.Type, Type>;
|
106
|
+
/**
|
107
|
+
* Constructs an Option of a PositiveReal from a Real
|
108
|
+
*
|
109
|
+
* @category Constructors
|
110
|
+
*/
|
111
|
+
export declare const fromRealOption: MTypes.OneArgFunction<CVReal.Type, Option.Option<Type>>;
|
112
|
+
/**
|
113
|
+
* Constructs an Either of a PositiveReal from a Real
|
114
|
+
*
|
115
|
+
* @category Constructors
|
116
|
+
*/
|
117
|
+
export declare const fromReal: MTypes.OneArgFunction<CVReal.Type, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
118
|
+
/**
|
119
|
+
* Constructs a PositiveReal from a Real or throws
|
120
|
+
*
|
121
|
+
* @category Constructors
|
122
|
+
*/
|
123
|
+
export declare const fromRealOrThrow: MTypes.OneArgFunction<CVReal.Type, Type>;
|
124
|
+
/**
|
125
|
+
* Constructs a PositiveReal from a PositiveInteger
|
126
|
+
*
|
127
|
+
* @category Constructors
|
128
|
+
*/
|
129
|
+
export declare const fromPositiveInteger: MTypes.OneArgFunction<CVPositiveInteger.Type, Type>;
|
130
|
+
//# sourceMappingURL=PositiveReal.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PositiveReal.d.ts","sourceRoot":"","sources":["../../esm/PositiveReal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAW,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,EAAU,MAAM,QAAQ,CAAC;AACnF,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,SAAS,yCAAyC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,WAAW,8GAAwD,CAAC;AAEjF;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,8GAAwB,CAAC;AAEtD;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AC,cAAc,CAC7C,MAAM,EACN,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAC8B,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAGxD,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAA8B,CAAC;AAEnG;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,cAAc,CACjD,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CACoB,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,cAAc,CAC3C,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CACX,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAC/B,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CACzD,CAAC"}
|
package/dts/Real.d.ts
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
/** This module implements a finite number brand (Infinity or Nan disallowed) */
|
2
|
+
import { MTypes } from '@parischap/effect-lib';
|
3
|
+
import { BigDecimal, Brand, Either, Option } from 'effect';
|
4
|
+
/**
|
5
|
+
* Module tag
|
6
|
+
*
|
7
|
+
* @category Module markers
|
8
|
+
*/
|
9
|
+
export declare const moduleTag = "@parischap/conversions/Real/";
|
10
|
+
/**
|
11
|
+
* Module TypeId
|
12
|
+
*
|
13
|
+
* @category Module markers
|
14
|
+
*/
|
15
|
+
export declare const TypeId: unique symbol;
|
16
|
+
type _TypeId = typeof TypeId;
|
17
|
+
/**
|
18
|
+
* Real type
|
19
|
+
*
|
20
|
+
* @category Models
|
21
|
+
*/
|
22
|
+
export type Type = Brand.Branded<number, _TypeId>;
|
23
|
+
/**
|
24
|
+
* Brand constructor. Should not be used directly
|
25
|
+
*
|
26
|
+
* @category Constructors
|
27
|
+
*/
|
28
|
+
export declare const constructor: Brand.Brand.Constructor<Type>;
|
29
|
+
/**
|
30
|
+
* Constructs a Real from a number without any verifications
|
31
|
+
*
|
32
|
+
* @category Constructors
|
33
|
+
*/
|
34
|
+
export declare const unsafeFromNumber: Brand.Brand.Constructor<Type>;
|
35
|
+
/**
|
36
|
+
* Constructs an Option of a Real from a number
|
37
|
+
*
|
38
|
+
* @category Constructors
|
39
|
+
*/
|
40
|
+
export declare const fromNumberOption: MTypes.OneArgFunction<number, Option.Option<Type>>;
|
41
|
+
/**
|
42
|
+
* Constructs an Either of a Real from a number
|
43
|
+
*
|
44
|
+
* @category Constructors
|
45
|
+
*/
|
46
|
+
export declare const fromNumber: MTypes.OneArgFunction<number, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
47
|
+
/**
|
48
|
+
* Constructs a Real from a number or throws
|
49
|
+
*
|
50
|
+
* @category Constructors
|
51
|
+
*/
|
52
|
+
export declare const fromNumberOrThrow: MTypes.OneArgFunction<number, Type>;
|
53
|
+
/**
|
54
|
+
* Constructs a Real from a BigDecimal without any checks
|
55
|
+
*
|
56
|
+
* @category Constructors
|
57
|
+
*/
|
58
|
+
export declare const unsafeFromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>;
|
59
|
+
/**
|
60
|
+
* Constructs an Option of a Real from a BigDecimal.
|
61
|
+
*
|
62
|
+
* @category Constructors
|
63
|
+
*/
|
64
|
+
export declare const fromBigDecimalOption: MTypes.OneArgFunction<BigDecimal.BigDecimal, Option.Option<Type>>;
|
65
|
+
/**
|
66
|
+
* Constructs an Either of a Real from a BigDecimal.
|
67
|
+
*
|
68
|
+
* @category Constructors
|
69
|
+
*/
|
70
|
+
export declare const fromBigDecimal: MTypes.OneArgFunction<BigDecimal.BigDecimal, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
71
|
+
/**
|
72
|
+
* Constructs a Real from a BigDecimal or throws
|
73
|
+
*
|
74
|
+
* @category Constructors
|
75
|
+
*/
|
76
|
+
export declare const fromBigDecimalOrThrow: MTypes.OneArgFunction<BigDecimal.BigDecimal, Type>;
|
77
|
+
/**
|
78
|
+
* Constructs a Real from a BigInt without any checks
|
79
|
+
*
|
80
|
+
* @category Constructors
|
81
|
+
*/
|
82
|
+
export declare const unsafeFromBigInt: MTypes.OneArgFunction<bigint, Type>;
|
83
|
+
/**
|
84
|
+
* Constructs an Option of a Real from a BigInt.
|
85
|
+
*
|
86
|
+
* @category Constructors
|
87
|
+
*/
|
88
|
+
export declare const fromBigIntOption: MTypes.OneArgFunction<bigint, Option.Option<Type>>;
|
89
|
+
/**
|
90
|
+
* Constructs an Either of a Real from a BigInt.
|
91
|
+
*
|
92
|
+
* @category Constructors
|
93
|
+
*/
|
94
|
+
export declare const fromBigInt: MTypes.OneArgFunction<bigint, Either.Either<Type, Brand.Brand.BrandErrors>>;
|
95
|
+
/**
|
96
|
+
* Constructs a Real from a BigInt or throws
|
97
|
+
*
|
98
|
+
* @category Constructors
|
99
|
+
*/
|
100
|
+
export declare const fromBigIntOrThrow: MTypes.OneArgFunction<bigint, Type>;
|
101
|
+
export {};
|
102
|
+
//# sourceMappingURL=Real.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Real.d.ts","sourceRoot":"","sources":["../../esm/Real.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAoB,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAQ,MAAM,EAAU,MAAM,QAAQ,CAAC;AAEzE;;;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B,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAC9C,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAC/B,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,CACnD,MAAM,EACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CACiB,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,cAAc,CAC7C,MAAM,EACN,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CACd,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAC/B,CAAC"}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/** This module defines possible rounding modes (see Intl.NumberFormat) */
|
2
|
+
import { MTypes } from '@parischap/effect-lib';
|
3
|
+
/**
|
4
|
+
* Possible rounding modes
|
5
|
+
*
|
6
|
+
* @category Models
|
7
|
+
*/
|
8
|
+
export declare enum Type {
|
9
|
+
/** Round toward +∞. Positive values round up. Negative values round "more positive" */
|
10
|
+
Ceil = 0,
|
11
|
+
/** Round toward -∞. Positive values round down. Negative values round "more negative" */
|
12
|
+
Floor = 1,
|
13
|
+
/**
|
14
|
+
* Round away from 0. The magnitude of the value is always increased by rounding. Positive values
|
15
|
+
* round up. Negative values round "more negative"
|
16
|
+
*/
|
17
|
+
Expand = 2,
|
18
|
+
/**
|
19
|
+
* Round toward 0. The magnitude of the value is always reduced by rounding. Positive values round
|
20
|
+
* down. Negative values round "less negative"
|
21
|
+
*/
|
22
|
+
Trunc = 3,
|
23
|
+
/**
|
24
|
+
* Ties toward +∞. Values above the half-increment round like "ceil" (towards +∞), and below like
|
25
|
+
* "floor" (towards -∞). On the half-increment, values round like "ceil"
|
26
|
+
*/
|
27
|
+
HalfCeil = 4,
|
28
|
+
/**
|
29
|
+
* Ties toward -∞. Values above the half-increment round like "ceil" (towards +∞), and below like
|
30
|
+
* "floor" (towards -∞). On the half-increment, values round like "floor"
|
31
|
+
*/
|
32
|
+
HalfFloor = 5,
|
33
|
+
/**
|
34
|
+
* Ties away from 0. Values above the half-increment round like "expand" (away from zero), and
|
35
|
+
* below like "trunc" (towards 0). On the half-increment, values round like "expand"
|
36
|
+
*/
|
37
|
+
HalfExpand = 6,
|
38
|
+
/**
|
39
|
+
* Ties toward 0. Values above the half-increment round like "expand" (away from zero), and below
|
40
|
+
* like "trunc" (towards 0). On the half-increment, values round like "trunc"
|
41
|
+
*/
|
42
|
+
HalfTrunc = 7,
|
43
|
+
/**
|
44
|
+
* Ties towards the nearest even integer. Values above the half-increment round like "expand"
|
45
|
+
* (away from zero), and below like "trunc" (towards 0). On the half-increment values round
|
46
|
+
* towards the nearest even digit
|
47
|
+
*/
|
48
|
+
HalfEven = 8
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Returns the name of `self`
|
52
|
+
*
|
53
|
+
* @category Destructors
|
54
|
+
*/
|
55
|
+
export declare const toName: MTypes.OneArgFunction<Type, string>;
|
56
|
+
/**
|
57
|
+
* Type of a Correcter
|
58
|
+
*
|
59
|
+
* @category Models
|
60
|
+
*/
|
61
|
+
export interface Correcter extends MTypes.OneArgFunction<{
|
62
|
+
readonly firstFollowingDigit: number;
|
63
|
+
readonly isEven: boolean;
|
64
|
+
}, number> {
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Builds a `Correcter` implementing `self`
|
68
|
+
*
|
69
|
+
* @category Destructors
|
70
|
+
*/
|
71
|
+
export declare const toCorrecter: MTypes.OneArgFunction<Type, Correcter>;
|
72
|
+
//# sourceMappingURL=RoundingMode.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"RoundingMode.d.ts","sourceRoot":"","sources":["../../esm/RoundingMode.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EAAU,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;;;GAIG;AACH,oBAAY,IAAI;IACf,uFAAuF;IACvF,IAAI,IAAI;IACR,yFAAyF;IACzF,KAAK,IAAI;IACT;;;OAGG;IACH,MAAM,IAAI;IACV;;;OAGG;IACH,KAAK,IAAI;IACT;;;OAGG;IACH,QAAQ,IAAI;IACZ;;;OAGG;IACH,SAAS,IAAI;IACb;;;OAGG;IACH,UAAU,IAAI;IACd;;;OAGG;IACH,SAAS,IAAI;IACb;;;;OAIG;IACH,QAAQ,IAAI;CACZ;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CActD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,SAChB,SAAQ,MAAM,CAAC,cAAc,CAC5B;IACC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB,EACD,MAAM,CACN;CAAG;AAEL;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAiE9D,CAAC"}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/**
|
2
|
+
* This module allows you to round numbers and BigDecimal's according to diverse RoundingMode's with
|
3
|
+
* a given precision
|
4
|
+
*/
|
5
|
+
import { MInspectable, MTypes } from '@parischap/effect-lib';
|
6
|
+
import { BigDecimal, Equal, Equivalence, Pipeable } from 'effect';
|
7
|
+
import * as CVRoundingMode from './RoundingMode.js';
|
8
|
+
/**
|
9
|
+
* Module tag
|
10
|
+
*
|
11
|
+
* @category Module markers
|
12
|
+
*/
|
13
|
+
export declare const moduleTag = "@parischap/conversions/RoundingOption/";
|
14
|
+
/**
|
15
|
+
* Type that represents a Rounder.
|
16
|
+
*
|
17
|
+
* @category Models
|
18
|
+
*/
|
19
|
+
export interface Type extends Equal.Equal, MInspectable.Type, Pipeable.Pipeable {
|
20
|
+
/** The precision at which to round the number. Must be a finite positive integer. */
|
21
|
+
readonly precision: number;
|
22
|
+
/** The rounding mode to use */
|
23
|
+
readonly roundingMode: CVRoundingMode.Type;
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Type guard
|
27
|
+
*
|
28
|
+
* @category Guards
|
29
|
+
*/
|
30
|
+
export declare const has: (u: unknown) => u is Type;
|
31
|
+
/**
|
32
|
+
* Equivalence
|
33
|
+
*
|
34
|
+
* @category Equivalences
|
35
|
+
*/
|
36
|
+
export declare const equivalence: Equivalence.Equivalence<Type>;
|
37
|
+
/**
|
38
|
+
* Constructor
|
39
|
+
*
|
40
|
+
* @category Constructors
|
41
|
+
*/
|
42
|
+
export declare const make: ({ precision, roundingMode }?: {
|
43
|
+
readonly precision?: number;
|
44
|
+
readonly roundingMode?: CVRoundingMode.Type;
|
45
|
+
}) => Type;
|
46
|
+
/**
|
47
|
+
* RoundingOption instance that uses the HalfExpand Rounding mode and precision=2. Can be used in
|
48
|
+
* accounting apps of most countries.
|
49
|
+
*
|
50
|
+
* @category Instances
|
51
|
+
*/
|
52
|
+
export declare const halfExpand2: Type;
|
53
|
+
/**
|
54
|
+
* Returns the `precision` property of `self`
|
55
|
+
*
|
56
|
+
* @category Destructors
|
57
|
+
*/
|
58
|
+
export declare const precision: MTypes.OneArgFunction<Type, number>;
|
59
|
+
/**
|
60
|
+
* Returns the `roundingMode` property of `self`
|
61
|
+
*
|
62
|
+
* @category Destructors
|
63
|
+
*/
|
64
|
+
export declare const roundingMode: MTypes.OneArgFunction<Type, CVRoundingMode.Type>;
|
65
|
+
/**
|
66
|
+
* Builds a number Rounder implementing `self`, i.e a function that rounds a number as specified by
|
67
|
+
* `self`
|
68
|
+
*
|
69
|
+
* @category Destructors
|
70
|
+
*/
|
71
|
+
export declare const toNumberRounder: (self: Type) => MTypes.OneArgFunction<number>;
|
72
|
+
/**
|
73
|
+
* Builds a BigDecimal Rounder implementing `self`, i.e a function that rounds a BigDecimal as
|
74
|
+
* specified by `self`
|
75
|
+
*
|
76
|
+
* @category Destructors
|
77
|
+
*/
|
78
|
+
export declare const toBigDecimalRounder: (self: Type) => MTypes.OneArgFunction<BigDecimal.BigDecimal>;
|
79
|
+
//# sourceMappingURL=RoundingOption.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"RoundingOption.d.ts","sourceRoot":"","sources":["../../esm/RoundingOption.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,YAAY,EAGZ,MAAM,EACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAc,QAAQ,EAAqB,MAAM,QAAQ,CAAC;AACjG,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,SAAS,2CAA2C,CAAC;AAMlE;;;;GAIG;AACH,MAAM,WAAW,IAAK,SAAQ,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ;IAC9E,qFAAqF;IACrF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,+BAA+B;IAC/B,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC;CAI3C;AAED;;;;GAIG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAAyC,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,IAAI,CACuB,CAAC;AA2B9E;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,8BAGlB;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC,IAAI,CAAA;CAAO,KAAG,IACpD,CAAC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