@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,381 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.toEnd = exports.schemaInstance = exports.realMappedLiterals = exports.real = exports.parser = exports.paddedFixedLength = exports.name = exports.moduleTag = exports.modify = exports.mappedLiterals = exports.make = exports.label = exports.has = exports.getLabelledDescription = exports.fulfilling = exports.formatter = exports.fixedLengthToReal = exports.fixedLength = exports.description = exports.anythingBut = void 0;
|
7
|
+
var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
|
8
|
+
var _effect = /*#__PURE__*/require("effect");
|
9
|
+
var CVNumberBase10Format = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./NumberBase10Format.js"));
|
10
|
+
var CVReal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Real.js"));
|
11
|
+
function _interopRequireWildcard(e, t) {
|
12
|
+
if ("function" == typeof WeakMap) var r = new WeakMap(),
|
13
|
+
n = new WeakMap();
|
14
|
+
return (_interopRequireWildcard = function (e, t) {
|
15
|
+
if (!t && e && e.__esModule) return e;
|
16
|
+
var o,
|
17
|
+
i,
|
18
|
+
f = {
|
19
|
+
__proto__: null,
|
20
|
+
default: e
|
21
|
+
};
|
22
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return f;
|
23
|
+
if (o = t ? n : r) {
|
24
|
+
if (o.has(e)) return o.get(e);
|
25
|
+
o.set(e, f);
|
26
|
+
}
|
27
|
+
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]);
|
28
|
+
return f;
|
29
|
+
})(e, t);
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* This module implements a TemplatePlaceholder type which is a sub-type of the TemplatePart type
|
33
|
+
* (see TemplatePart.ts)
|
34
|
+
*
|
35
|
+
* A TemplatePlaceholder represents the mutable part of a template. Each Placeholder defines a
|
36
|
+
* parser and a formatter:
|
37
|
+
*
|
38
|
+
* - The parser takes a string, consumes a part of that string, optionnally converts the consumed part
|
39
|
+
* to a value of type T and, if successful, returns a right of that value and of what has not been
|
40
|
+
* consumed. In case of an error, it returns a left.
|
41
|
+
* - The formatter takes a value of type T, converts it to a string (if T is not string), checks that
|
42
|
+
* the result is coherent and, if so, returns a right of that string. Otherwise, it returns a
|
43
|
+
* left.
|
44
|
+
*/
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Module tag
|
48
|
+
*
|
49
|
+
* @category Module markers
|
50
|
+
*/
|
51
|
+
const moduleTag = exports.moduleTag = '@parischap/conversions/TemplatePlaceholder/';
|
52
|
+
const _TypeId = /*#__PURE__*/Symbol.for(moduleTag);
|
53
|
+
/**
|
54
|
+
* Type guard
|
55
|
+
*
|
56
|
+
* @category Guards
|
57
|
+
*/
|
58
|
+
const has = u => _effect.Predicate.hasProperty(u, _TypeId);
|
59
|
+
/** Proto */
|
60
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
61
|
+
exports.has = has;
|
62
|
+
const proto = {
|
63
|
+
[_TypeId]: {
|
64
|
+
_N: _effectLib.MTypes.covariantValue,
|
65
|
+
_T: _effectLib.MTypes.invariantValue
|
66
|
+
},
|
67
|
+
[_effectLib.MInspectable.IdSymbol]() {
|
68
|
+
return getLabelledDescription(this);
|
69
|
+
},
|
70
|
+
... /*#__PURE__*/_effectLib.MInspectable.BaseProto(moduleTag),
|
71
|
+
..._effectLib.MPipeable.BaseProto
|
72
|
+
};
|
73
|
+
const _make = params => _effectLib.MTypes.objectFromDataAndProto(proto, params);
|
74
|
+
/**
|
75
|
+
* Constructor
|
76
|
+
*
|
77
|
+
* @category Constructors
|
78
|
+
*/
|
79
|
+
const make = exports.make = /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MStruct.enrichWith({
|
80
|
+
label: ({
|
81
|
+
name
|
82
|
+
}) => _effectLib.MString.prepend('#')(name)
|
83
|
+
}), _make);
|
84
|
+
/**
|
85
|
+
* Returns the `name` property of `self`
|
86
|
+
*
|
87
|
+
* @category Destructors
|
88
|
+
*/
|
89
|
+
const name = exports.name = /*#__PURE__*/_effect.Struct.get('name');
|
90
|
+
/**
|
91
|
+
* Returns the `label` property of `self`
|
92
|
+
*
|
93
|
+
* @category Destructors
|
94
|
+
*/
|
95
|
+
const label = exports.label = /*#__PURE__*/_effect.Struct.get('label');
|
96
|
+
/**
|
97
|
+
* Returns the `description` property of `self`
|
98
|
+
*
|
99
|
+
* @category Destructors
|
100
|
+
*/
|
101
|
+
const description = exports.description = /*#__PURE__*/_effect.Struct.get('description');
|
102
|
+
/**
|
103
|
+
* Returns the `parser` property of `self`
|
104
|
+
*
|
105
|
+
* @category Destructors
|
106
|
+
*/
|
107
|
+
const parser = exports.parser = /*#__PURE__*/_effect.Struct.get('parser');
|
108
|
+
/**
|
109
|
+
* Returns the `formatter` property of `self`
|
110
|
+
*
|
111
|
+
* @category Destructors
|
112
|
+
*/
|
113
|
+
const formatter = exports.formatter = /*#__PURE__*/_effect.Struct.get('formatter');
|
114
|
+
/**
|
115
|
+
* Returns the `schemaInstance` property of `self`
|
116
|
+
*
|
117
|
+
* @category Destructors
|
118
|
+
*/
|
119
|
+
const schemaInstance = exports.schemaInstance = /*#__PURE__*/_effect.Struct.get('schemaInstance');
|
120
|
+
/**
|
121
|
+
* Returns the description of `self`
|
122
|
+
*
|
123
|
+
* @category Destructors
|
124
|
+
*/
|
125
|
+
const getLabelledDescription = self => `${self.label}: ${self.description}`;
|
126
|
+
/**
|
127
|
+
* Returns a modified copy of `self` where a postParser function is executed after the parser of
|
128
|
+
* `self` and a preFormatter function is executed before the formatter of `self`
|
129
|
+
*
|
130
|
+
* @category Destructors
|
131
|
+
*/
|
132
|
+
exports.getLabelledDescription = getLabelledDescription;
|
133
|
+
const modify = ({
|
134
|
+
descriptorMapper,
|
135
|
+
postParser,
|
136
|
+
preFormatter,
|
137
|
+
t1SchemaInstance
|
138
|
+
}) => self => make({
|
139
|
+
name: self.name,
|
140
|
+
description: descriptorMapper(self.description),
|
141
|
+
parser: function (text) {
|
142
|
+
return _effect.Either.flatMap(self.parser.call(this, text), (0, _effect.flow)(_effect.Tuple.mapBoth({
|
143
|
+
onFirst: t => postParser.call(this, t),
|
144
|
+
onSecond: _effect.Either.right
|
145
|
+
}), _effect.Either.all));
|
146
|
+
},
|
147
|
+
formatter: function (t1) {
|
148
|
+
return (0, _effect.pipe)(preFormatter.call(this, t1), _effect.Either.flatMap(t => self.formatter.call(this, t)));
|
149
|
+
},
|
150
|
+
schemaInstance: t1SchemaInstance === undefined ? self.schemaInstance : t1SchemaInstance
|
151
|
+
});
|
152
|
+
/**
|
153
|
+
* Builds a TemplatePlaceholder instance that parses/formats exactly `length` characters from a
|
154
|
+
* string. `length` must be a strictly positive integer.
|
155
|
+
*
|
156
|
+
* @category Constructors
|
157
|
+
*/
|
158
|
+
exports.modify = modify;
|
159
|
+
const fixedLength = ({
|
160
|
+
name,
|
161
|
+
length
|
162
|
+
}) => {
|
163
|
+
return make({
|
164
|
+
name,
|
165
|
+
description: `${length}-character string`,
|
166
|
+
parser: function (text) {
|
167
|
+
return (0, _effect.pipe)(text, _effectLib.MString.splitAt(length), _effect.Tuple.mapBoth({
|
168
|
+
onFirst: _effectLib.MInputError.assertLength({
|
169
|
+
expected: length,
|
170
|
+
name: this.label
|
171
|
+
}),
|
172
|
+
onSecond: _effect.Either.right
|
173
|
+
}), _effect.Either.all);
|
174
|
+
},
|
175
|
+
formatter: function (value) {
|
176
|
+
return _effectLib.MInputError.assertLength({
|
177
|
+
expected: length,
|
178
|
+
name: this.label
|
179
|
+
})(value);
|
180
|
+
},
|
181
|
+
schemaInstance: _effect.Schema.String
|
182
|
+
});
|
183
|
+
};
|
184
|
+
/**
|
185
|
+
* Builds a TemplatePlaceholder instance that parses/formats exactly `length` characters from a
|
186
|
+
* string and trims/pads the result at `padPosition` with `fillChar`. `fillChar` should be a
|
187
|
+
* one-character string. `length` must be a strictly positive integer. See the meaning of
|
188
|
+
* `disallowEmptyString` in String.trim.
|
189
|
+
*
|
190
|
+
* @category Constructors
|
191
|
+
*/
|
192
|
+
exports.fixedLength = fixedLength;
|
193
|
+
const paddedFixedLength = params => {
|
194
|
+
const trimmer = (0, _effect.flow)(_effectLib.MString.trim(params), _effect.Either.right);
|
195
|
+
const padder = (0, _effect.flow)(_effectLib.MString.pad(params), _effect.Either.right);
|
196
|
+
return (0, _effect.pipe)(fixedLength(params), modify({
|
197
|
+
descriptorMapper: _effectLib.MString.append(` ${_effectLib.MString.PadPosition.toId(params.padPosition)}-padded with '${params.fillChar}'`),
|
198
|
+
postParser: trimmer,
|
199
|
+
preFormatter: padder
|
200
|
+
}));
|
201
|
+
};
|
202
|
+
/**
|
203
|
+
* Builds a TemplatePlaceholder instance that parses/formats a Real in the given
|
204
|
+
* `numberBase10Format`. If the number to parse/format is less than `length` characters, `fillChar`
|
205
|
+
* is trimmed/padded between the sign and the number so that the length condition is respected.
|
206
|
+
* fillChar must be a one-character string (but no error is triggered if you do not respect that
|
207
|
+
* condition)
|
208
|
+
*
|
209
|
+
* @category Constructors
|
210
|
+
*/
|
211
|
+
exports.paddedFixedLength = paddedFixedLength;
|
212
|
+
const fixedLengthToReal = params => {
|
213
|
+
const {
|
214
|
+
numberBase10Format,
|
215
|
+
fillChar
|
216
|
+
} = params;
|
217
|
+
const numberParser = function (input) {
|
218
|
+
return (0, _effect.pipe)(input, CVNumberBase10Format.toRealParser(numberBase10Format, fillChar), _effect.Either.fromOption(() => new _effectLib.MInputError.Type({
|
219
|
+
message: `${this.label}: value '${input}' cannot be converted to a(n) ${CVNumberBase10Format.toDescription(numberBase10Format)}`
|
220
|
+
})));
|
221
|
+
};
|
222
|
+
const numberFormatter = (0, _effect.flow)(CVNumberBase10Format.toNumberFormatter(numberBase10Format, (0, _effect.pipe)(fillChar, _effect.String.repeat(params.length))), _effect.Either.right);
|
223
|
+
return (0, _effect.pipe)(fixedLength(params), modify({
|
224
|
+
descriptorMapper: _effectLib.MString.append(` left-padded with '${fillChar}' to ${CVNumberBase10Format.toDescription(numberBase10Format)}`),
|
225
|
+
postParser: numberParser,
|
226
|
+
preFormatter: numberFormatter,
|
227
|
+
t1SchemaInstance: CVReal.SchemaFromSelf
|
228
|
+
}));
|
229
|
+
};
|
230
|
+
/**
|
231
|
+
* Builds a TemplatePlaceholder instance that parses/formats a Real provided in
|
232
|
+
* `numberBase10Format`.
|
233
|
+
*
|
234
|
+
* @category Constructors
|
235
|
+
*/
|
236
|
+
exports.fixedLengthToReal = fixedLengthToReal;
|
237
|
+
const real = ({
|
238
|
+
name,
|
239
|
+
numberBase10Format
|
240
|
+
}) => {
|
241
|
+
const numberParser = CVNumberBase10Format.toRealExtractor(numberBase10Format);
|
242
|
+
const numberFormatter = CVNumberBase10Format.toNumberFormatter(numberBase10Format);
|
243
|
+
const flippedTakeRightBut = _effect.Function.flip(_effectLib.MString.takeRightBut);
|
244
|
+
return make({
|
245
|
+
name,
|
246
|
+
description: `${CVNumberBase10Format.toDescription(numberBase10Format)}`,
|
247
|
+
parser: function (text) {
|
248
|
+
return (0, _effect.pipe)(text, numberParser, _effect.Either.fromOption(() => new _effectLib.MInputError.Type({
|
249
|
+
message: `${this.label} contains '${text}' from the start of which a(n) ${CVNumberBase10Format.toDescription(numberBase10Format)} could not be extracted`
|
250
|
+
})), _effect.Either.map(_effect.Tuple.mapSecond((0, _effect.flow)(_effect.String.length, flippedTakeRightBut(text)))));
|
251
|
+
},
|
252
|
+
formatter: (0, _effect.flow)(numberFormatter, _effect.Either.right),
|
253
|
+
schemaInstance: CVReal.SchemaFromSelf
|
254
|
+
});
|
255
|
+
};
|
256
|
+
/**
|
257
|
+
* Builds a TemplatePlaceholder instance that works as a map:
|
258
|
+
*
|
259
|
+
* The parser expects one of the keys of `keyValuePairs` and will return the associated value. The
|
260
|
+
* formatter expects one of the values of `keyValuePairs` and will return the associated key.
|
261
|
+
*
|
262
|
+
* `keyValuePairs` should define a bijection (each key and each value must be present only once). It
|
263
|
+
* is best if the type of the values defines a toString method. Value equality is checked with The
|
264
|
+
* Effect Equal.equals function.
|
265
|
+
*
|
266
|
+
* `schemaInstance` is a Schema instance that transforms a value of type T into a value of type T.
|
267
|
+
* It is an optional parameter. You need only provide it if you intend to use a CVTemplate built
|
268
|
+
* from it within the Effect Schema module. In that case, you can build such a Schema with the
|
269
|
+
* Schema.declare function. If you don't provide it and use a CVTemplate built from it within the
|
270
|
+
* Effect Schema module, it will not work.
|
271
|
+
*
|
272
|
+
* @category Constructors
|
273
|
+
*/
|
274
|
+
exports.real = real;
|
275
|
+
const mappedLiterals = ({
|
276
|
+
name,
|
277
|
+
keyValuePairs,
|
278
|
+
schemaInstance = _effect.Schema.declare(_input => false)
|
279
|
+
}) => {
|
280
|
+
const keys = (0, _effect.pipe)(keyValuePairs, _effect.Array.map(_effect.Tuple.getFirst), _effect.Array.join(', '), _effectLib.MString.prepend('['), _effectLib.MString.append(']'));
|
281
|
+
const values = (0, _effect.pipe)(keyValuePairs, _effect.Array.map((0, _effect.flow)(_effect.Tuple.getSecond, _effectLib.MString.fromUnknown)), _effect.Array.join(', '), _effectLib.MString.prepend('['), _effectLib.MString.append(']'));
|
282
|
+
const valueNameMap = (0, _effect.pipe)(keyValuePairs, _effect.Array.map(_effect.Tuple.swap), _effect.HashMap.fromIterable);
|
283
|
+
const isTheStartOf = _effect.Function.flip(_effect.String.startsWith);
|
284
|
+
const flippedTakeRightBut = _effect.Function.flip(_effectLib.MString.takeRightBut);
|
285
|
+
return make({
|
286
|
+
name,
|
287
|
+
description: `from ${keys} to ${values}`,
|
288
|
+
parser: function (text) {
|
289
|
+
return (0, _effect.pipe)(keyValuePairs, _effect.Array.findFirst((0, _effect.flow)(_effect.Tuple.getFirst, isTheStartOf(text))), _effect.Either.fromOption(() => new _effectLib.MInputError.Type({
|
290
|
+
message: `Expected remaining text for ${this.label} to start with one of ${keys}. Actual: '${text}'`
|
291
|
+
})), _effect.Either.map(_effectLib.MTuple.makeBothBy({
|
292
|
+
toFirst: _effect.Tuple.getSecond,
|
293
|
+
toSecond: (0, _effect.flow)(_effect.Tuple.getFirst, _effect.String.length, flippedTakeRightBut(text))
|
294
|
+
})));
|
295
|
+
},
|
296
|
+
formatter: function (value) {
|
297
|
+
return (0, _effect.pipe)(valueNameMap, _effect.HashMap.get(value), _effect.Either.fromOption(() => new _effectLib.MInputError.Type({
|
298
|
+
message: `${this.label}: expected one of ${values}. Actual: ${_effectLib.MString.fromUnknown(value)}`
|
299
|
+
})));
|
300
|
+
},
|
301
|
+
schemaInstance
|
302
|
+
});
|
303
|
+
};
|
304
|
+
/**
|
305
|
+
* Same as `mappedLiterals` but `T` is assumed to be `CVReal.Type` which should be the most usual
|
306
|
+
* use case
|
307
|
+
*
|
308
|
+
* @category Constructors
|
309
|
+
*/
|
310
|
+
exports.mappedLiterals = mappedLiterals;
|
311
|
+
const realMappedLiterals = params => mappedLiterals({
|
312
|
+
...params,
|
313
|
+
schemaInstance: CVReal.SchemaFromSelf
|
314
|
+
});
|
315
|
+
/**
|
316
|
+
* Builds a TemplatePlaceholder instance that parses/formats the regular expression regExp. `regExp`
|
317
|
+
* must start with the ^ character. Otherwise, the parser and formatter will not work properly.
|
318
|
+
*
|
319
|
+
* @category Constructors
|
320
|
+
*/
|
321
|
+
exports.realMappedLiterals = realMappedLiterals;
|
322
|
+
const fulfilling = ({
|
323
|
+
name,
|
324
|
+
regExp,
|
325
|
+
regExpDescriptor
|
326
|
+
}) => {
|
327
|
+
const flippedTakeRightBut = _effect.Function.flip(_effectLib.MString.takeRightBut);
|
328
|
+
const match = label => _effectLib.MInputError.match({
|
329
|
+
regExp,
|
330
|
+
regExpDescriptor,
|
331
|
+
name: label
|
332
|
+
});
|
333
|
+
return make({
|
334
|
+
name,
|
335
|
+
description: `${regExpDescriptor}`,
|
336
|
+
parser: function (text) {
|
337
|
+
return (0, _effect.pipe)(text, match(this.label), _effect.Either.map(_effectLib.MTuple.makeBothBy({
|
338
|
+
toFirst: _effect.Function.identity,
|
339
|
+
toSecond: (0, _effect.flow)(_effect.String.length, flippedTakeRightBut(text))
|
340
|
+
})));
|
341
|
+
},
|
342
|
+
formatter: function (text) {
|
343
|
+
return (0, _effect.pipe)(text, match(this.label), _effect.Either.filterOrLeft(_effectLib.MString.hasLength(text.length), () => new _effectLib.MInputError.Type({
|
344
|
+
message: `${this.label}: expected ${regExpDescriptor}. Actual: '${text}'`
|
345
|
+
})));
|
346
|
+
},
|
347
|
+
schemaInstance: _effect.Schema.String
|
348
|
+
});
|
349
|
+
};
|
350
|
+
/**
|
351
|
+
* Builds a TemplatePlaceholder instance that parses/formats a non-empty string made up of
|
352
|
+
* characters other than those contained in `forbiddenChars`. `forbiddenChars` should be an array of
|
353
|
+
* 1-character strings (will not throw otherwise but strange behaviors can be expected)
|
354
|
+
*
|
355
|
+
* @category Constructors
|
356
|
+
*/
|
357
|
+
exports.fulfilling = fulfilling;
|
358
|
+
const anythingBut = ({
|
359
|
+
name,
|
360
|
+
forbiddenChars
|
361
|
+
}) => {
|
362
|
+
const forbiddenCharsAsString = (0, _effect.pipe)(forbiddenChars, _effect.Array.join("', '"), _effectLib.MString.prepend("[ '"), _effectLib.MString.append("' ]"));
|
363
|
+
return fulfilling({
|
364
|
+
name,
|
365
|
+
regExp: (0, _effect.pipe)(forbiddenChars, _effectLib.MRegExpString.notInRange, _effectLib.MRegExpString.oneOrMore, _effectLib.MRegExpString.atStart, _effectLib.MRegExp.fromRegExpString()),
|
366
|
+
regExpDescriptor: `a non-empty string containing non of the following characters: ${forbiddenCharsAsString}`
|
367
|
+
});
|
368
|
+
};
|
369
|
+
/**
|
370
|
+
* Builds a TemplatePlaceholder instance that parses/formats all the remaining text.
|
371
|
+
*
|
372
|
+
* @category Constructors
|
373
|
+
*/
|
374
|
+
exports.anythingBut = anythingBut;
|
375
|
+
const toEnd = name => fulfilling({
|
376
|
+
name,
|
377
|
+
regExp: /^.*/,
|
378
|
+
regExpDescriptor: 'a string'
|
379
|
+
});
|
380
|
+
exports.toEnd = toEnd;
|
381
|
+
//# sourceMappingURL=TemplatePlaceholder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TemplatePlaceholder.js","names":["_effectLib","require","_effect","CVNumberBase10Format","_interopRequireWildcard","CVReal","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","moduleTag","exports","_TypeId","Symbol","for","u","Predicate","hasProperty","proto","_N","MTypes","covariantValue","_T","invariantValue","MInspectable","IdSymbol","getLabelledDescription","BaseProto","MPipeable","_make","params","objectFromDataAndProto","make","flow","MStruct","enrichWith","label","name","MString","prepend","Struct","description","parser","formatter","schemaInstance","self","modify","descriptorMapper","postParser","preFormatter","t1SchemaInstance","text","Either","flatMap","Tuple","mapBoth","onFirst","onSecond","right","all","t1","pipe","undefined","fixedLength","length","splitAt","MInputError","assertLength","expected","value","Schema","String","paddedFixedLength","trimmer","trim","padder","pad","append","PadPosition","toId","padPosition","fillChar","fixedLengthToReal","numberBase10Format","numberParser","input","toRealParser","fromOption","Type","message","toDescription","numberFormatter","toNumberFormatter","repeat","SchemaFromSelf","real","toRealExtractor","flippedTakeRightBut","Function","flip","takeRightBut","map","mapSecond","mappedLiterals","keyValuePairs","declare","_input","keys","Array","getFirst","join","values","getSecond","fromUnknown","valueNameMap","swap","HashMap","fromIterable","isTheStartOf","startsWith","findFirst","MTuple","makeBothBy","toFirst","toSecond","realMappedLiterals","fulfilling","regExp","regExpDescriptor","match","identity","filterOrLeft","hasLength","anythingBut","forbiddenChars","forbiddenCharsAsString","MRegExpString","notInRange","oneOrMore","atStart","MRegExp","fromRegExpString","toEnd"],"sources":["../../esm/TemplatePlaceholder.ts"],"sourcesContent":[null],"mappings":";;;;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AAE,kEAAkEO,sBAAsB;GAC1G,CAAC;AACH,CAAC;AAED;;;;;AAAA5H,OAAA,CAAA0H,WAAA,GAAAA,WAAA;AAKO,MAAMS,KAAK,GAA4BzG,IAAO,IACpDyF,UAAU,CAAC;EACVzF,IAAI;EACJ0F,MAAM,EAAE,KAAK;EACbC,gBAAgB,EAAE;CAClB,CAAC;AAACrH,OAAA,CAAAmI,KAAA,GAAAA,KAAA","ignoreList":[]}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.value = exports.space = exports.slash = exports.parser = exports.moduleTag = exports.make = exports.hyphen = exports.has = exports.formatter = exports.dot = exports.comma = exports.colon = exports.backslash = void 0;
|
7
|
+
var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
|
8
|
+
var _effect = /*#__PURE__*/require("effect");
|
9
|
+
/**
|
10
|
+
* This module implements a TemplateSeparator type which is a sub-type of the TemplatePart type (see
|
11
|
+
* TemplatePart.ts)
|
12
|
+
*
|
13
|
+
* A TemplateSeparator represents the immutable part of a template. Upon parsing, we must check that
|
14
|
+
* it is present as is in the text. Upon formatting, it must be inserted as is into the text. A
|
15
|
+
* Separator contains no valuable information
|
16
|
+
*/
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Module tag
|
20
|
+
*
|
21
|
+
* @category Module markers
|
22
|
+
*/
|
23
|
+
const moduleTag = exports.moduleTag = '@parischap/conversions/TemplateSeparator/';
|
24
|
+
const _TypeId = /*#__PURE__*/Symbol.for(moduleTag);
|
25
|
+
/**
|
26
|
+
* Type guard
|
27
|
+
*
|
28
|
+
* @category Guards
|
29
|
+
*/
|
30
|
+
const has = u => _effect.Predicate.hasProperty(u, _TypeId);
|
31
|
+
/** Proto */
|
32
|
+
exports.has = has;
|
33
|
+
const proto = {
|
34
|
+
[_TypeId]: _TypeId,
|
35
|
+
[_effectLib.MInspectable.IdSymbol]() {
|
36
|
+
return this.value;
|
37
|
+
},
|
38
|
+
... /*#__PURE__*/_effectLib.MInspectable.BaseProto(moduleTag),
|
39
|
+
..._effectLib.MPipeable.BaseProto
|
40
|
+
};
|
41
|
+
const _make = params => _effectLib.MTypes.objectFromDataAndProto(proto, params);
|
42
|
+
/**
|
43
|
+
* Builds a Separator instance that parses/formats a given string.
|
44
|
+
*
|
45
|
+
* @category Constructors
|
46
|
+
*/
|
47
|
+
const make = value => _make({
|
48
|
+
value,
|
49
|
+
parser: pos => (0, _effect.flow)(_effectLib.MInputError.assertStartsWith({
|
50
|
+
startString: value,
|
51
|
+
name: `remaining text for separator at position ${pos}`
|
52
|
+
}), _effect.Either.map(_effectLib.MString.takeRightBut(value.length))),
|
53
|
+
formatter: _effect.Function.constant(value)
|
54
|
+
});
|
55
|
+
/**
|
56
|
+
* Returns the `value` property of `self`
|
57
|
+
*
|
58
|
+
* @category Destructors
|
59
|
+
*/
|
60
|
+
exports.make = make;
|
61
|
+
const value = exports.value = /*#__PURE__*/_effect.Struct.get('value');
|
62
|
+
/**
|
63
|
+
* Returns the `parser` property of `self`
|
64
|
+
*
|
65
|
+
* @category Destructors
|
66
|
+
*/
|
67
|
+
const parser = exports.parser = /*#__PURE__*/_effect.Struct.get('parser');
|
68
|
+
/**
|
69
|
+
* Returns the `formatter` property of `self`
|
70
|
+
*
|
71
|
+
* @category Destructors
|
72
|
+
*/
|
73
|
+
const formatter = exports.formatter = /*#__PURE__*/_effect.Struct.get('formatter');
|
74
|
+
/**
|
75
|
+
* Slash Separator instance
|
76
|
+
*
|
77
|
+
* @category Instances
|
78
|
+
*/
|
79
|
+
const slash = exports.slash = /*#__PURE__*/make('/');
|
80
|
+
/**
|
81
|
+
* Backslash Separator instance
|
82
|
+
*
|
83
|
+
* @category Instances
|
84
|
+
*/
|
85
|
+
const backslash = exports.backslash = /*#__PURE__*/make('\\');
|
86
|
+
/**
|
87
|
+
* Dot Separator instance
|
88
|
+
*
|
89
|
+
* @category Instances
|
90
|
+
*/
|
91
|
+
const dot = exports.dot = /*#__PURE__*/make('.');
|
92
|
+
/**
|
93
|
+
* Hyphen Separator instance
|
94
|
+
*
|
95
|
+
* @category Instances
|
96
|
+
*/
|
97
|
+
const hyphen = exports.hyphen = /*#__PURE__*/make('-');
|
98
|
+
/**
|
99
|
+
* Colon Separator instance
|
100
|
+
*
|
101
|
+
* @category Instances
|
102
|
+
*/
|
103
|
+
const colon = exports.colon = /*#__PURE__*/make(':');
|
104
|
+
/**
|
105
|
+
* Comma Separator instance
|
106
|
+
*
|
107
|
+
* @category Instances
|
108
|
+
*/
|
109
|
+
const comma = exports.comma = /*#__PURE__*/make(',');
|
110
|
+
/**
|
111
|
+
* Space Separator instance
|
112
|
+
*
|
113
|
+
* @category Instances
|
114
|
+
*/
|
115
|
+
const space = exports.space = /*#__PURE__*/make(' ');
|
116
|
+
//# sourceMappingURL=TemplateSeparator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TemplateSeparator.js","names":["_effectLib","require","_effect","moduleTag","exports","_TypeId","Symbol","for","has","u","Predicate","hasProperty","proto","MInspectable","IdSymbol","value","BaseProto","MPipeable","_make","params","MTypes","objectFromDataAndProto","make","parser","pos","flow","MInputError","assertStartsWith","startString","name","Either","map","MString","takeRightBut","length","formatter","Function","constant","Struct","get","slash","backslash","dot","hyphen","colon","comma","space"],"sources":["../../esm/TemplateSeparator.ts"],"sourcesContent":[null],"mappings":";;;;;;AASA,IAAAA,UAAA,gBAAAC,OAAA;AAEA,IAAAC,OAAA,gBAAAD,OAAA;AAXA;;;;;;;;;AAaA;;;;;AAKO,MAAME,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,2CAA2C;AACpE,MAAME,OAAO,gBAAkBC,MAAM,CAACC,GAAG,CAACJ,SAAS,CAAY;AAsD/D;;;;;AAKO,MAAMK,GAAG,GAAIC,CAAU,IAAgBP,OAAA,CAAAQ,SAAS,CAACC,WAAW,CAACF,CAAC,EAA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A,gBAAgDjC,OAAA,CAAAoC,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;AAE7F;;;;;AAKO,MAAMC,KAAK,GAAApC,OAAA,CAAAoC,KAAA,gBAASlB,IAAI,CAAC,GAAG,CAAC;AAEpC;;;;;AAKO,MAAMmB,SAAS,GAAArC,OAAA,CAAAqC,SAAA,gBAASnB,IAAI,CAAC,IAAI,CAAC;AAEzC;;;;;AAKO,MAAMoB,GAAG,GAAAtC,OAAA,CAAAsC,GAAA,gBAASpB,IAAI,CAAC,GAAG,CAAC;AAElC;;;;;AAKO,MAAMqB,MAAM,GAAAvC,OAAA,CAAAuC,MAAA,gBAASrB,IAAI,CAAC,GAAG,CAAC;AAErC;;;;;AAKO,MAAMsB,KAAK,GAAAxC,OAAA,CAAAwC,KAAA,gBAAStB,IAAI,CAAC,GAAG,CAAC;AAEpC;;;;;AAKO,MAAMuB,KAAK,GAAAzC,OAAA,CAAAyC,KAAA,gBAASvB,IAAI,CAAC,GAAG,CAAC;AAEpC;;;;;AAKO,MAAMwB,KAAK,GAAA1C,OAAA,CAAA0C,KAAA,gBAASxB,IAAI,CAAC,GAAG,CAAC","ignoreList":[]}
|
package/cjs/index.js
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CVTemplateSeparator = exports.CVTemplatePlaceholder = exports.CVTemplateParts = exports.CVTemplatePart = exports.CVTemplate = exports.CVSemVer = exports.CVSchema = exports.CVRoundingOption = exports.CVRoundingMode = exports.CVReal = exports.CVPositiveReal = exports.CVPositiveInteger = exports.CVNumberBase10Format = exports.CVInteger = exports.CVEmail = exports.CVDateTimeFormatContext = exports.CVDateTimeFormat = exports.CVDateTime = exports.CVBigInt = exports.CVBigDecimal = void 0;
|
7
|
+
var _CVBigDecimal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./BigDecimal.js"));
|
8
|
+
exports.CVBigDecimal = _CVBigDecimal;
|
9
|
+
var _CVBigInt = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./BigInt.js"));
|
10
|
+
exports.CVBigInt = _CVBigInt;
|
11
|
+
var _CVDateTime = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./DateTime.js"));
|
12
|
+
exports.CVDateTime = _CVDateTime;
|
13
|
+
var _CVDateTimeFormat = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./DateTimeFormat.js"));
|
14
|
+
exports.CVDateTimeFormat = _CVDateTimeFormat;
|
15
|
+
var _CVDateTimeFormatContext = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./DateTimeFormatContext.js"));
|
16
|
+
exports.CVDateTimeFormatContext = _CVDateTimeFormatContext;
|
17
|
+
var _CVEmail = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Email.js"));
|
18
|
+
exports.CVEmail = _CVEmail;
|
19
|
+
var _CVInteger = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Integer.js"));
|
20
|
+
exports.CVInteger = _CVInteger;
|
21
|
+
var _CVNumberBase10Format = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./NumberBase10Format.js"));
|
22
|
+
exports.CVNumberBase10Format = _CVNumberBase10Format;
|
23
|
+
var _CVPositiveInteger = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./PositiveInteger.js"));
|
24
|
+
exports.CVPositiveInteger = _CVPositiveInteger;
|
25
|
+
var _CVPositiveReal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./PositiveReal.js"));
|
26
|
+
exports.CVPositiveReal = _CVPositiveReal;
|
27
|
+
var _CVReal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Real.js"));
|
28
|
+
exports.CVReal = _CVReal;
|
29
|
+
var _CVRoundingMode = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./RoundingMode.js"));
|
30
|
+
exports.CVRoundingMode = _CVRoundingMode;
|
31
|
+
var _CVRoundingOption = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./RoundingOption.js"));
|
32
|
+
exports.CVRoundingOption = _CVRoundingOption;
|
33
|
+
var _CVSchema = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Schema.js"));
|
34
|
+
exports.CVSchema = _CVSchema;
|
35
|
+
var _CVSemVer = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./SemVer.js"));
|
36
|
+
exports.CVSemVer = _CVSemVer;
|
37
|
+
var _CVTemplate = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Template.js"));
|
38
|
+
exports.CVTemplate = _CVTemplate;
|
39
|
+
var _CVTemplatePart = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./TemplatePart.js"));
|
40
|
+
exports.CVTemplatePart = _CVTemplatePart;
|
41
|
+
var _CVTemplateParts = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./TemplateParts.js"));
|
42
|
+
exports.CVTemplateParts = _CVTemplateParts;
|
43
|
+
var _CVTemplatePlaceholder = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./TemplatePlaceholder.js"));
|
44
|
+
exports.CVTemplatePlaceholder = _CVTemplatePlaceholder;
|
45
|
+
var _CVTemplateSeparator = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./TemplateSeparator.js"));
|
46
|
+
exports.CVTemplateSeparator = _CVTemplateSeparator;
|
47
|
+
function _interopRequireWildcard(e, t) {
|
48
|
+
if ("function" == typeof WeakMap) var r = new WeakMap(),
|
49
|
+
n = new WeakMap();
|
50
|
+
return (_interopRequireWildcard = function (e, t) {
|
51
|
+
if (!t && e && e.__esModule) return e;
|
52
|
+
var o,
|
53
|
+
i,
|
54
|
+
f = {
|
55
|
+
__proto__: null,
|
56
|
+
default: e
|
57
|
+
};
|
58
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return f;
|
59
|
+
if (o = t ? n : r) {
|
60
|
+
if (o.has(e)) return o.get(e);
|
61
|
+
o.set(e, f);
|
62
|
+
}
|
63
|
+
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]);
|
64
|
+
return f;
|
65
|
+
})(e, t);
|
66
|
+
}
|
67
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../esm/index.ts"],"sourcesContent":[null],"mappings":"","ignoreList":[]}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.fromNumberOrThrow = exports.fromNumberOption = exports.fromNumber = exports.constructor = exports._TypeId = void 0;
|
7
|
+
var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
|
8
|
+
var _effect = /*#__PURE__*/require("effect");
|
9
|
+
/**
|
10
|
+
* A module that implements an integer brand (non-null fractional part disallowed). Not exported.
|
11
|
+
* Only used internally
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Module tag
|
16
|
+
*
|
17
|
+
* @internal
|
18
|
+
*/
|
19
|
+
const _moduleTag = '@parischap/conversions/Int/';
|
20
|
+
/**
|
21
|
+
* Module TypeId
|
22
|
+
*
|
23
|
+
* @internal
|
24
|
+
*/
|
25
|
+
const _TypeId = exports._TypeId = /*#__PURE__*/Symbol.for(_moduleTag);
|
26
|
+
/**
|
27
|
+
* Brand constructor. Should not be used directly
|
28
|
+
*
|
29
|
+
* @internal
|
30
|
+
*/
|
31
|
+
const constructor = exports.constructor = /*#__PURE__*/_effect.Brand.refined(_effectLib.MNumber.isInt, /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MString.fromNumber(10), /*#__PURE__*/_effectLib.MString.prepend("'"), /*#__PURE__*/_effectLib.MString.append("' does not represent an integer"), _effect.Brand.error));
|
32
|
+
/**
|
33
|
+
* Constructs an Option of an Int from a number.
|
34
|
+
*
|
35
|
+
* @internal
|
36
|
+
*/
|
37
|
+
const fromNumberOption = exports.fromNumberOption = /*#__PURE__*/constructor.option.bind(constructor);
|
38
|
+
/**
|
39
|
+
* Constructs an Either of an Int from a number.
|
40
|
+
*
|
41
|
+
* @internal
|
42
|
+
*/
|
43
|
+
const fromNumber = exports.fromNumber = /*#__PURE__*/constructor.either.bind(constructor);
|
44
|
+
/**
|
45
|
+
* Constructs an Int from a number or throws
|
46
|
+
*
|
47
|
+
* @internal
|
48
|
+
*/
|
49
|
+
const fromNumberOrThrow = exports.fromNumberOrThrow = constructor;
|
50
|
+
//# sourceMappingURL=Int.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Int.js","names":["_effectLib","require","_effect","_moduleTag","_TypeId","exports","Symbol","for","constructor","Brand","refined","MNumber","isInt","flow","MString","fromNumber","prepend","append","error","fromNumberOption","option","bind","either","fromNumberOrThrow"],"sources":["../../../esm/internal/Int.ts"],"sourcesContent":[null],"mappings":";;;;;;AAKA,IAAAA,UAAA,gBAAAC,OAAA;AACA,IAAAC,OAAA,gBAAAD,OAAA;AANA;;;;;AAQA;;;;;AAKA,MAAME,UAAU,GAAG,6BAA6B;AAEhD;;;;;AAKO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,gBAAkBE,MAAM,CAACC,GAAG,CAACJ,UAAU,CAAY;AAUvE;;;;;AAKO,MAAMK,WAAW,GAAAH,OAAA,CAAAG,WAAA,gBAAGN,OAAA,CAAAO,KAAK,CAACC,OAAO,CACvCV,UAAA,CAAAW,OAAO,CAACC,KAAK,eACb,IAAAV,OAAA,CAAAW,IAAI,eACHb,UAAA,CAAAc,OAAO,CAACC,UAAU,CAAC,EAAE,CAAC,eACtBf,UAAA,CAAAc,OAAO,CAACE,OAAO,CAAC,GAAG,CAAC,eACpBhB,UAAA,CAAAc,OAAO,CAACG,MAAM,CAAC,iCAAiC,CAAC,EACjDf,OAAA,CAAAO,KAAK,CAACS,KAAK,CACX,CACD;AAED;;;;;AAKO,MAAMC,gBAAgB,GAAAd,OAAA,CAAAc,gBAAA,gBAGzBX,WAAW,CAACY,MAAM,CAACC,IAAI,CAACb,WAAW,CAAC;AAExC;;;;;AAKO,MAAMO,UAAU,GAAAV,OAAA,CAAAU,UAAA,gBAGnBP,WAAW,CAACc,MAAM,CAACD,IAAI,CAACb,WAAW,CAAC;AAExC;;;;;AAKO,MAAMe,iBAAiB,GAAAlB,OAAA,CAAAkB,iBAAA,GAAwCf,WAAW","ignoreList":[]}
|