@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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1304 -0
  3. package/cjs/BigDecimal.js +16 -0
  4. package/cjs/BigDecimal.js.map +1 -0
  5. package/cjs/BigInt.js +34 -0
  6. package/cjs/BigInt.js.map +1 -0
  7. package/cjs/DateTime.js +2202 -0
  8. package/cjs/DateTime.js.map +1 -0
  9. package/cjs/DateTimeFormat.js +269 -0
  10. package/cjs/DateTimeFormat.js.map +1 -0
  11. package/cjs/DateTimeFormatContext.js +327 -0
  12. package/cjs/DateTimeFormatContext.js.map +1 -0
  13. package/cjs/Email.js +73 -0
  14. package/cjs/Email.js.map +1 -0
  15. package/cjs/Integer.js +155 -0
  16. package/cjs/Integer.js.map +1 -0
  17. package/cjs/NumberBase10Format.js +759 -0
  18. package/cjs/NumberBase10Format.js.map +1 -0
  19. package/cjs/PositiveInteger.js +191 -0
  20. package/cjs/PositiveInteger.js.map +1 -0
  21. package/cjs/PositiveReal.js +162 -0
  22. package/cjs/PositiveReal.js.map +1 -0
  23. package/cjs/Real.js +113 -0
  24. package/cjs/Real.js.map +1 -0
  25. package/cjs/RoundingMode.js +86 -0
  26. package/cjs/RoundingMode.js.map +1 -0
  27. package/cjs/RoundingOption.js +152 -0
  28. package/cjs/RoundingOption.js.map +1 -0
  29. package/cjs/Schema.js +218 -0
  30. package/cjs/Schema.js.map +1 -0
  31. package/cjs/SemVer.js +73 -0
  32. package/cjs/SemVer.js.map +1 -0
  33. package/cjs/Template.js +189 -0
  34. package/cjs/Template.js.map +1 -0
  35. package/cjs/TemplatePart.js +51 -0
  36. package/cjs/TemplatePart.js.map +1 -0
  37. package/cjs/TemplateParts.js +46 -0
  38. package/cjs/TemplateParts.js.map +1 -0
  39. package/cjs/TemplatePlaceholder.js +381 -0
  40. package/cjs/TemplatePlaceholder.js.map +1 -0
  41. package/cjs/TemplateSeparator.js +116 -0
  42. package/cjs/TemplateSeparator.js.map +1 -0
  43. package/cjs/index.js +67 -0
  44. package/cjs/index.js.map +1 -0
  45. package/cjs/internal/Int.js +50 -0
  46. package/cjs/internal/Int.js.map +1 -0
  47. package/cjs/internal/Positive.js +50 -0
  48. package/cjs/internal/Positive.js.map +1 -0
  49. package/dts/BigDecimal.d.ts +11 -0
  50. package/dts/BigDecimal.d.ts.map +1 -0
  51. package/dts/BigInt.d.ts +30 -0
  52. package/dts/BigInt.d.ts.map +1 -0
  53. package/dts/DateTime.d.ts +1421 -0
  54. package/dts/DateTime.d.ts.map +1 -0
  55. package/dts/DateTimeFormat.d.ts +257 -0
  56. package/dts/DateTimeFormat.d.ts.map +1 -0
  57. package/dts/DateTimeFormatContext.d.ts +112 -0
  58. package/dts/DateTimeFormatContext.d.ts.map +1 -0
  59. package/dts/Email.d.ts +61 -0
  60. package/dts/Email.d.ts.map +1 -0
  61. package/dts/Integer.d.ts +123 -0
  62. package/dts/Integer.d.ts.map +1 -0
  63. package/dts/NumberBase10Format.d.ts +641 -0
  64. package/dts/NumberBase10Format.d.ts.map +1 -0
  65. package/dts/PositiveInteger.d.ts +161 -0
  66. package/dts/PositiveInteger.d.ts.map +1 -0
  67. package/dts/PositiveReal.d.ts +130 -0
  68. package/dts/PositiveReal.d.ts.map +1 -0
  69. package/dts/Real.d.ts +102 -0
  70. package/dts/Real.d.ts.map +1 -0
  71. package/dts/RoundingMode.d.ts +72 -0
  72. package/dts/RoundingMode.d.ts.map +1 -0
  73. package/dts/RoundingOption.d.ts +79 -0
  74. package/dts/RoundingOption.d.ts.map +1 -0
  75. package/dts/Schema.d.ts +159 -0
  76. package/dts/Schema.d.ts.map +1 -0
  77. package/dts/SemVer.d.ts +61 -0
  78. package/dts/SemVer.d.ts.map +1 -0
  79. package/dts/Template.d.ts +113 -0
  80. package/dts/Template.d.ts.map +1 -0
  81. package/dts/TemplatePart.d.ts +28 -0
  82. package/dts/TemplatePart.d.ts.map +1 -0
  83. package/dts/TemplateParts.d.ts +23 -0
  84. package/dts/TemplateParts.d.ts.map +1 -0
  85. package/dts/TemplatePlaceholder.d.ts +274 -0
  86. package/dts/TemplatePlaceholder.d.ts.map +1 -0
  87. package/dts/TemplateSeparator.d.ts +130 -0
  88. package/dts/TemplateSeparator.d.ts.map +1 -0
  89. package/dts/index.d.ts +21 -0
  90. package/dts/index.d.ts.map +1 -0
  91. package/dts/internal/Int.d.ts +6 -0
  92. package/dts/internal/Int.d.ts.map +1 -0
  93. package/dts/internal/Positive.d.ts +6 -0
  94. package/dts/internal/Positive.d.ts.map +1 -0
  95. package/esm/BigDecimal.js +9 -0
  96. package/esm/BigDecimal.js.map +1 -0
  97. package/esm/BigInt.js +27 -0
  98. package/esm/BigInt.js.map +1 -0
  99. package/esm/DateTime.js +2130 -0
  100. package/esm/DateTime.js.map +1 -0
  101. package/esm/DateTimeFormat.js +238 -0
  102. package/esm/DateTimeFormat.js.map +1 -0
  103. package/esm/DateTimeFormatContext.js +296 -0
  104. package/esm/DateTimeFormatContext.js.map +1 -0
  105. package/esm/Email.js +65 -0
  106. package/esm/Email.js.map +1 -0
  107. package/esm/Integer.js +128 -0
  108. package/esm/Integer.js.map +1 -0
  109. package/esm/NumberBase10Format.js +717 -0
  110. package/esm/NumberBase10Format.js.map +1 -0
  111. package/esm/PositiveInteger.js +164 -0
  112. package/esm/PositiveInteger.js.map +1 -0
  113. package/esm/PositiveReal.js +135 -0
  114. package/esm/PositiveReal.js.map +1 -0
  115. package/esm/Real.js +106 -0
  116. package/esm/Real.js.map +1 -0
  117. package/esm/RoundingMode.js +79 -0
  118. package/esm/RoundingMode.js.map +1 -0
  119. package/esm/RoundingOption.js +120 -0
  120. package/esm/RoundingOption.js.map +1 -0
  121. package/esm/Schema.js +203 -0
  122. package/esm/Schema.js.map +1 -0
  123. package/esm/SemVer.js +65 -0
  124. package/esm/SemVer.js.map +1 -0
  125. package/esm/Template.js +158 -0
  126. package/esm/Template.js.map +1 -0
  127. package/esm/TemplatePart.js +22 -0
  128. package/esm/TemplatePart.js.map +1 -0
  129. package/esm/TemplateParts.js +19 -0
  130. package/esm/TemplateParts.js.map +1 -0
  131. package/esm/TemplatePlaceholder.js +342 -0
  132. package/esm/TemplatePlaceholder.js.map +1 -0
  133. package/esm/TemplateSeparator.js +107 -0
  134. package/esm/TemplateSeparator.js.map +1 -0
  135. package/esm/index.js +21 -0
  136. package/esm/index.js.map +1 -0
  137. package/esm/internal/Int.js +43 -0
  138. package/esm/internal/Int.js.map +1 -0
  139. package/esm/internal/Positive.js +43 -0
  140. package/esm/internal/Positive.js.map +1 -0
  141. package/esm/package.json +3 -0
  142. package/package.json +49 -0
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toName = exports.toCorrecter = exports.Type = void 0;
7
+ var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
8
+ var _effect = /*#__PURE__*/require("effect");
9
+ /** This module defines possible rounding modes (see Intl.NumberFormat) */
10
+
11
+ /**
12
+ * Possible rounding modes
13
+ *
14
+ * @category Models
15
+ */
16
+ var Type;
17
+ (function (Type) {
18
+ /** Round toward +∞. Positive values round up. Negative values round "more positive" */
19
+ Type[Type["Ceil"] = 0] = "Ceil";
20
+ /** Round toward -∞. Positive values round down. Negative values round "more negative" */
21
+ Type[Type["Floor"] = 1] = "Floor";
22
+ /**
23
+ * Round away from 0. The magnitude of the value is always increased by rounding. Positive values
24
+ * round up. Negative values round "more negative"
25
+ */
26
+ Type[Type["Expand"] = 2] = "Expand";
27
+ /**
28
+ * Round toward 0. The magnitude of the value is always reduced by rounding. Positive values round
29
+ * down. Negative values round "less negative"
30
+ */
31
+ Type[Type["Trunc"] = 3] = "Trunc";
32
+ /**
33
+ * Ties toward +∞. Values above the half-increment round like "ceil" (towards +∞), and below like
34
+ * "floor" (towards -∞). On the half-increment, values round like "ceil"
35
+ */
36
+ Type[Type["HalfCeil"] = 4] = "HalfCeil";
37
+ /**
38
+ * Ties toward -∞. Values above the half-increment round like "ceil" (towards +∞), and below like
39
+ * "floor" (towards -∞). On the half-increment, values round like "floor"
40
+ */
41
+ Type[Type["HalfFloor"] = 5] = "HalfFloor";
42
+ /**
43
+ * Ties away from 0. Values above the half-increment round like "expand" (away from zero), and
44
+ * below like "trunc" (towards 0). On the half-increment, values round like "expand"
45
+ */
46
+ Type[Type["HalfExpand"] = 6] = "HalfExpand";
47
+ /**
48
+ * Ties toward 0. Values above the half-increment round like "expand" (away from zero), and below
49
+ * like "trunc" (towards 0). On the half-increment, values round like "trunc"
50
+ */
51
+ Type[Type["HalfTrunc"] = 7] = "HalfTrunc";
52
+ /**
53
+ * Ties towards the nearest even integer. Values above the half-increment round like "expand"
54
+ * (away from zero), and below like "trunc" (towards 0). On the half-increment values round
55
+ * towards the nearest even digit
56
+ */
57
+ Type[Type["HalfEven"] = 8] = "HalfEven";
58
+ })(Type || (exports.Type = Type = {}));
59
+ /**
60
+ * Returns the name of `self`
61
+ *
62
+ * @category Destructors
63
+ */
64
+ const toName = exports.toName = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MMatch.whenIs(Type.Ceil, /*#__PURE__*/_effect.Function.constant('Ceil')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.Floor, /*#__PURE__*/_effect.Function.constant('Floor')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.Expand, /*#__PURE__*/_effect.Function.constant('Expand')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.Trunc, /*#__PURE__*/_effect.Function.constant('Trunc')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfCeil, /*#__PURE__*/_effect.Function.constant('HalfCeil')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfFloor, /*#__PURE__*/_effect.Function.constant('HalfFloor')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfExpand, /*#__PURE__*/_effect.Function.constant('HalfExpand')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfTrunc, /*#__PURE__*/_effect.Function.constant('HalfTrunc')), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfEven, /*#__PURE__*/_effect.Function.constant('HalfEven'))), _effectLib.MMatch.exhaustive);
65
+ /**
66
+ * Builds a `Correcter` implementing `self`
67
+ *
68
+ * @category Destructors
69
+ */
70
+ const toCorrecter = exports.toCorrecter = /*#__PURE__*/(0, _effect.flow)(_effectLib.MMatch.make, /*#__PURE__*/(0, _effect.flow)(/*#__PURE__*/_effectLib.MMatch.whenIs(Type.Ceil, () => ({
71
+ firstFollowingDigit
72
+ }) => firstFollowingDigit > 0 ? 1 : 0), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.Floor, () => ({
73
+ firstFollowingDigit
74
+ }) => firstFollowingDigit < 0 ? -1 : 0), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.Expand, () => (0, _effect.flow)(_effect.Struct.get('firstFollowingDigit'), Math.sign)), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.Trunc, () => _effect.Function.constant(0)), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfCeil, () => ({
75
+ firstFollowingDigit
76
+ }) => firstFollowingDigit >= 5 ? 1 : firstFollowingDigit < -5 ? -1 : 0), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfFloor, () => ({
77
+ firstFollowingDigit
78
+ }) => firstFollowingDigit > 5 ? 1 : firstFollowingDigit <= -5 ? -1 : 0), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfExpand, () => ({
79
+ firstFollowingDigit
80
+ }) => firstFollowingDigit >= 5 ? 1 : firstFollowingDigit <= -5 ? -1 : 0), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfTrunc, () => ({
81
+ firstFollowingDigit
82
+ }) => firstFollowingDigit > 5 ? 1 : firstFollowingDigit < -5 ? -1 : 0), /*#__PURE__*/_effectLib.MMatch.whenIs(Type.HalfEven, () => ({
83
+ firstFollowingDigit,
84
+ isEven
85
+ }) => firstFollowingDigit > 5 ? 1 : firstFollowingDigit < -5 ? -1 : firstFollowingDigit === 5 ? isEven ? 0 : 1 : firstFollowingDigit === -5 ? isEven ? 0 : -1 : 0)), _effectLib.MMatch.exhaustive);
86
+ //# sourceMappingURL=RoundingMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundingMode.js","names":["_effectLib","require","_effect","Type","exports","toName","flow","MMatch","make","whenIs","Ceil","Function","constant","Floor","Expand","Trunc","HalfCeil","HalfFloor","HalfExpand","HalfTrunc","HalfEven","exhaustive","toCorrecter","firstFollowingDigit","Struct","get","Math","sign","isEven"],"sources":["../../esm/RoundingMode.ts"],"sourcesContent":[null],"mappings":";;;;;;AAEA,IAAAA,UAAA,gBAAAC,OAAA;AACA,IAAAC,OAAA,gBAAAD,OAAA;AAHA;;AAKA;;;;;AAKA,IAAYE,IAyCX;AAzCD,WAAYA,IAAI;EACf;EACAA,IAAA,CAAAA,IAAA,sBAAQ;EACR;EACAA,IAAA,CAAAA,IAAA,wBAAS;EACT;;;;EAIAA,IAAA,CAAAA,IAAA,0BAAU;EACV;;;;EAIAA,IAAA,CAAAA,IAAA,wBAAS;EACT;;;;EAIAA,IAAA,CAAAA,IAAA,8BAAY;EACZ;;;;EAIAA,IAAA,CAAAA,IAAA,gCAAa;EACb;;;;EAIAA,IAAA,CAAAA,IAAA,kCAAc;EACd;;;;EAIAA,IAAA,CAAAA,IAAA,gCAAa;EACb;;;;;EAKAA,IAAA,CAAAA,IAAA,8BAAY;AACb,CAAC,EAzCWA,IAAI,KAAAC,OAAA,CAAAD,IAAA,GAAJA,IAAI;AA2ChB;;;;;AAKO,MAAME,MAAM,GAAAD,OAAA,CAAAC,MAAA,gBAAwC,IAAAH,OAAA,CAAAI,IAAI,EAC9DN,UAAA,CAAAO,MAAM,CAACC,IAAI,eACX,IAAAN,OAAA,CAAAI,IAAI,eACHN,UA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A,CAAAO,MAAM,CAACE,MAAM,CACZN,IAAI,CAACe,UAAU,EACf,MACC,CAAC;EAAEK;AAAmB,CAAE,KACvBA,mBAAmB,IAAI,CAAC,GAAG,CAAC,GAC1BA,mBAAmB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAC9B,CAAC,CACL,eACDvB,UAAA,CAAAO,MAAM,CAACE,MAAM,CACZN,IAAI,CAACgB,SAAS,EACd,MACC,CAAC;EAAEI;AAAmB,CAAE,KACvBA,mBAAmB,GAAG,CAAC,GAAG,CAAC,GACzBA,mBAAmB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAC7B,CAAC,CACL,eACDvB,UAAA,CAAAO,MAAM,CAACE,MAAM,CACZN,IAAI,CAACiB,QAAQ,EACb,MACC,CAAC;EAAEG,mBAAmB;EAAEK;AAAM,CAAE,KAC/BL,mBAAmB,GAAG,CAAC,GAAG,CAAC,GACzBA,mBAAmB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAC7BA,mBAAmB,KAAK,CAAC,GAC1BK,MAAM,GAAG,CAAC,GACR,CAAC,GACFL,mBAAmB,KAAK,CAAC,CAAC,GAC3BK,MAAM,GAAG,CAAC,GACR,CAAC,CAAC,GACH,CAAC,CACL,CACD,EACD5B,UAAA,CAAAO,MAAM,CAACc,UAAU,CACjB","ignoreList":[]}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toNumberRounder = exports.toBigDecimalRounder = exports.roundingMode = exports.precision = exports.moduleTag = exports.make = exports.has = exports.halfExpand2 = exports.equivalence = void 0;
7
+ var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
8
+ var _effect = /*#__PURE__*/require("effect");
9
+ var CVRoundingMode = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./RoundingMode.js"));
10
+ function _interopRequireWildcard(e, t) {
11
+ if ("function" == typeof WeakMap) var r = new WeakMap(),
12
+ n = new WeakMap();
13
+ return (_interopRequireWildcard = function (e, t) {
14
+ if (!t && e && e.__esModule) return e;
15
+ var o,
16
+ i,
17
+ f = {
18
+ __proto__: null,
19
+ default: e
20
+ };
21
+ if (null === e || "object" != typeof e && "function" != typeof e) return f;
22
+ if (o = t ? n : r) {
23
+ if (o.has(e)) return o.get(e);
24
+ o.set(e, f);
25
+ }
26
+ 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]);
27
+ return f;
28
+ })(e, t);
29
+ }
30
+ /**
31
+ * This module allows you to round numbers and BigDecimal's according to diverse RoundingMode's with
32
+ * a given precision
33
+ */
34
+
35
+ /**
36
+ * Module tag
37
+ *
38
+ * @category Module markers
39
+ */
40
+ const moduleTag = exports.moduleTag = '@parischap/conversions/RoundingOption/';
41
+ const _TypeId = /*#__PURE__*/Symbol.for(moduleTag);
42
+ const _bigDecimal10 = /*#__PURE__*/_effect.BigDecimal.make(10n, 0);
43
+ /**
44
+ * Type guard
45
+ *
46
+ * @category Guards
47
+ */
48
+ const has = u => _effect.Predicate.hasProperty(u, _TypeId);
49
+ /**
50
+ * Equivalence
51
+ *
52
+ * @category Equivalences
53
+ */
54
+ exports.has = has;
55
+ const equivalence = (self, that) => self.precision === that.precision && self.roundingMode === that.roundingMode;
56
+ /** Prototype */
57
+ exports.equivalence = equivalence;
58
+ const proto = {
59
+ [_TypeId]: _TypeId,
60
+ [_effect.Equal.symbol](that) {
61
+ return has(that) && equivalence(this, that);
62
+ },
63
+ [_effect.Hash.symbol]() {
64
+ return (0, _effect.pipe)(this.precision, _effect.Hash.hash, _effect.Hash.combine(_effect.Hash.hash(this.roundingMode)), _effect.Hash.cached(this));
65
+ },
66
+ [_effectLib.MInspectable.IdSymbol]() {
67
+ return `${CVRoundingMode.toName(this.roundingMode)}RounderWith${this.precision}Precision`;
68
+ },
69
+ ... /*#__PURE__*/_effectLib.MInspectable.BaseProto(moduleTag),
70
+ ..._effectLib.MPipeable.BaseProto
71
+ };
72
+ /** Constructor */
73
+ const _make = params => _effectLib.MTypes.objectFromDataAndProto(proto, params);
74
+ /**
75
+ * Constructor
76
+ *
77
+ * @category Constructors
78
+ */
79
+ const make = ({
80
+ precision = 0,
81
+ roundingMode = CVRoundingMode.Type.HalfExpand
82
+ } = {}) => _make({
83
+ precision,
84
+ roundingMode
85
+ });
86
+ /**
87
+ * RoundingOption instance that uses the HalfExpand Rounding mode and precision=2. Can be used in
88
+ * accounting apps of most countries.
89
+ *
90
+ * @category Instances
91
+ */
92
+ exports.make = make;
93
+ const halfExpand2 = exports.halfExpand2 = /*#__PURE__*/make({
94
+ precision: 2,
95
+ roundingMode: CVRoundingMode.Type.HalfExpand
96
+ });
97
+ /**
98
+ * Returns the `precision` property of `self`
99
+ *
100
+ * @category Destructors
101
+ */
102
+ const precision = exports.precision = /*#__PURE__*/_effect.Struct.get('precision');
103
+ /**
104
+ * Returns the `roundingMode` property of `self`
105
+ *
106
+ * @category Destructors
107
+ */
108
+ const roundingMode = exports.roundingMode = /*#__PURE__*/_effect.Struct.get('roundingMode');
109
+ /**
110
+ * Builds a number Rounder implementing `self`, i.e a function that rounds a number as specified by
111
+ * `self`
112
+ *
113
+ * @category Destructors
114
+ */
115
+ const toNumberRounder = self => {
116
+ const shiftMultiplicand = (0, _effect.pipe)(1, _effectLib.MNumber.shift(self.precision));
117
+ const unshiftMultiplicand = 1.0 / shiftMultiplicand;
118
+ const correcter = CVRoundingMode.toCorrecter(self.roundingMode);
119
+ return n => {
120
+ const shiftedSelf = shiftMultiplicand * n;
121
+ const truncatedShiftedSelf = Math.trunc(shiftedSelf);
122
+ const firstFollowingDigit = Math.trunc((shiftedSelf - truncatedShiftedSelf) * 10);
123
+ return unshiftMultiplicand * (truncatedShiftedSelf + correcter({
124
+ firstFollowingDigit,
125
+ isEven: truncatedShiftedSelf % 2 == 0
126
+ }));
127
+ };
128
+ };
129
+ /**
130
+ * Builds a BigDecimal Rounder implementing `self`, i.e a function that rounds a BigDecimal as
131
+ * specified by `self`
132
+ *
133
+ * @category Destructors
134
+ */
135
+ exports.toNumberRounder = toNumberRounder;
136
+ const toBigDecimalRounder = self => {
137
+ const shiftValue = _effect.BigDecimal.make(1n, -self.precision);
138
+ const shift = _effect.BigDecimal.multiply(shiftValue);
139
+ const unshift = _effect.BigDecimal.unsafeDivide(shiftValue);
140
+ const correcter = CVRoundingMode.toCorrecter(self.roundingMode);
141
+ return n => {
142
+ const shiftedSelf = shift(n);
143
+ const truncatedShiftedSelf = (0, _effect.pipe)(shiftedSelf, _effectLib.MBigDecimal.trunc());
144
+ const firstFollowingDigit = (0, _effect.pipe)(shiftedSelf, _effect.BigDecimal.subtract(truncatedShiftedSelf), _effect.BigDecimal.multiply(_bigDecimal10), _effectLib.MBigDecimal.trunc(), _effect.BigDecimal.unsafeToNumber);
145
+ return (0, _effect.pipe)(truncatedShiftedSelf, _effect.BigDecimal.sum((0, _effect.pipe)({
146
+ firstFollowingDigit,
147
+ isEven: _effectLib.MBigInt.isEven(truncatedShiftedSelf.value)
148
+ }, correcter, _effect.BigDecimal.unsafeFromNumber)), unshift);
149
+ };
150
+ };
151
+ exports.toBigDecimalRounder = toBigDecimalRounder;
152
+ //# sourceMappingURL=RoundingOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundingOption.js","names":["_effectLib","require","_effect","CVRoundingMode","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","moduleTag","exports","_TypeId","Symbol","for","_bigDecimal10","BigDecimal","make","u","Predicate","hasProperty","equivalence","self","that","precision","roundingMode","proto","Equal","symbol","Hash","pipe","hash","combine","cached","MInspectable","IdSymbol","toName","BaseProto","MPipeable","_make","params","MTypes","objectFromDataAndProto","Type","HalfExpand","halfExpand2","Struct","toNumberRounder","shiftMultiplicand","MNumber","shift","unshiftMultiplicand","correcter","toCorrecter","shiftedSelf","truncatedShiftedSelf","Math","trunc","firstFollowingDigit","isEven","toBigDecimalRounder","shiftValue","multiply","unshift","unsafeDivide","MBigDecimal","subtract","unsafeToNumber","sum","MBigInt","value","unsafeFromNumber"],"sources":["../../esm/RoundingOption.ts"],"sourcesContent":[null],"mappings":";;;;;;AAKA,IAAAA,UAAA,gBAAAC,OAAA;AAQA,IAAAC,OAAA,gBAAAD,OAAA;AACA,IAAAE,cAAA,gBAAAC,uBAAA,cAAAH,OAAA;AAAoD,SAAAG,wBAAAC,CAAA,EAAAC,CAAA;EAAA,yBAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA;IAAAE,CAAA,OAAAF,OAAA;EAAA,QAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA;IAAA,KAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA;IAAA,IAAAM,CAAA;MAAAC,CAAA;MAAAC,CAAA;QAAAC,SAAA;QAAAC,OAAA,EAAAV;MAAA;IAAA,aAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA;IAAA,IAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA;MAAA,IAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA;MAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA;IAAA;IAAA,WAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,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AAW,EAAEpE,UAAA,CAAA+E,WAAW,CAACR,KAAK,EAAE,CAAC;IACnE,MAAMC,mBAAmB,GAAG,IAAAtE,OAAA,CAAA0C,IAAI,EAC/BwB,WAAW,EACXlE,OAAA,CAAA4B,UAAU,CAACkD,QAAQ,CAACX,oBAAoB,CAAC,EACzCnE,OAAA,CAAA4B,UAAU,CAAC8C,QAAQ,CAAC/C,aAAa,CAAC,EAClC7B,UAAA,CAAA+E,WAAW,CAACR,KAAK,EAAE,EACnBrE,OAAA,CAAA4B,UAAU,CAACmD,cAAc,CACzB;IACD,OAAO,IAAA/E,OAAA,CAAA0C,IAAI,EACVyB,oBAAoB,EACpBnE,OAAA,CAAA4B,UAAU,CAACoD,GAAG,CACb,IAAAhF,OAAA,CAAA0C,IAAI,EACH;MAAE4B,mBAAmB;MAAEC,MAAM,EAAEzE,UAAA,CAAAmF,OAAO,CAACV,MAAM,CAACJ,oBAAoB,CAACe,KAAK;IAAC,CAAE,EAC3ElB,SAAS,EACThE,OAAA,CAAA4B,UAAU,CAACuD,gBAAgB,CAC3B,CACD,EACDR,OAAO,CACP;EACF,CAAC;AACF,CAAC;AAACpD,OAAA,CAAAiD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
package/cjs/Schema.js ADDED
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Template = exports.SemVerFromSelf = exports.SemVer = exports.RealFromSelf = exports.RealFromNumber = exports.Real = exports.PositiveRealFromSelf = exports.PositiveRealFromNumber = exports.PositiveIntegerFromSelf = exports.PositiveIntegerFromNumber = exports.IntegerFromSelf = exports.IntegerFromNumber = exports.EmailFromSelf = exports.Email = exports.DateTimeZonedFromDateTime = exports.DateTimeZoned = exports.DateTimeFromSelf = exports.DateTime = exports.DateFromDateTime = exports.Date = exports.BigDecimal = void 0;
7
+ var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
8
+ var _effect = /*#__PURE__*/require("effect");
9
+ var CVDateTime = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./DateTime.js"));
10
+ var CVDateTimeFormat = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./DateTimeFormat.js"));
11
+ var CVEmail = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Email.js"));
12
+ var CVInteger = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Integer.js"));
13
+ var CVNumberBase10Format = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./NumberBase10Format.js"));
14
+ var CVPositiveInteger = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./PositiveInteger.js"));
15
+ var CVPositiveReal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./PositiveReal.js"));
16
+ var CVReal = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Real.js"));
17
+ var CVSemVer = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./SemVer.js"));
18
+ var CVTemplate = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./Template.js"));
19
+ var CVTemplatePart = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./TemplatePart.js"));
20
+ var CVTemplatePlaceholder = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./TemplatePlaceholder.js"));
21
+ function _interopRequireWildcard(e, t) {
22
+ if ("function" == typeof WeakMap) var r = new WeakMap(),
23
+ n = new WeakMap();
24
+ return (_interopRequireWildcard = function (e, t) {
25
+ if (!t && e && e.__esModule) return e;
26
+ var o,
27
+ i,
28
+ f = {
29
+ __proto__: null,
30
+ default: e
31
+ };
32
+ if (null === e || "object" != typeof e && "function" != typeof e) return f;
33
+ if (o = t ? n : r) {
34
+ if (o.has(e)) return o.get(e);
35
+ o.set(e, f);
36
+ }
37
+ 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]);
38
+ return f;
39
+ })(e, t);
40
+ }
41
+ /**
42
+ * An extension to the Effect Schema module that adds Schema instances for data conversion like
43
+ * number and date formatting and parsing
44
+ */
45
+
46
+ /**
47
+ * A Schema that transforms a string into a CVBrand.Email.Type
48
+ *
49
+ * @category Schema transformations
50
+ */
51
+ const Email = exports.Email = CVEmail.SchemaFromString;
52
+ /**
53
+ * A Schema that represents a CVBrand.Email.Type
54
+ *
55
+ * @category Schema instances
56
+ */
57
+ const EmailFromSelf = exports.EmailFromSelf = CVEmail.SchemaFromSelf;
58
+ /**
59
+ * A Schema that transforms a string into an CVBrand.SemVer.Type
60
+ *
61
+ * @category Schema transformations
62
+ */
63
+ const SemVer = exports.SemVer = CVSemVer.SchemaFromString;
64
+ /**
65
+ * A Schema that represents a CVBrand.SemVer.Type
66
+ *
67
+ * @category Schema instances
68
+ */
69
+ const SemVerFromSelf = exports.SemVerFromSelf = CVSemVer.SchemaFromSelf;
70
+ /**
71
+ * A Schema that transforms a number into an CVReal.Type
72
+ *
73
+ * @category Schema transformations
74
+ */
75
+ const RealFromNumber = exports.RealFromNumber = CVReal.SchemaFromNumber;
76
+ /**
77
+ * A Schema that represents a CVReal.Type
78
+ *
79
+ * @category Schema instances
80
+ */
81
+ const RealFromSelf = exports.RealFromSelf = CVReal.SchemaFromSelf;
82
+ /**
83
+ * A Schema that transforms a string into a Real according to the CVNumberBase10Format `format`.
84
+ * Read documentation of CVNumberBase10Format.toRealParser and
85
+ * CVNumberBase10Format.toNumberFormatter for more details
86
+ *
87
+ * @category Schema transformations
88
+ */
89
+ const Real = format => {
90
+ const parser = CVNumberBase10Format.toRealParser(format);
91
+ const formatter = CVNumberBase10Format.toNumberFormatter(format);
92
+ return _effect.Schema.transformOrFail(_effect.Schema.String, RealFromSelf, {
93
+ strict: true,
94
+ decode: (input, _options, ast) => (0, _effect.pipe)(input, parser, _effect.Either.fromOption(() => new _effect.ParseResult.Type(ast, input, 'Failed to convert string to a(n) ' + CVNumberBase10Format.toDescription(format)))),
95
+ encode: (0, _effect.flow)(formatter, _effect.ParseResult.succeed)
96
+ });
97
+ };
98
+ /**
99
+ * A Schema that transforms a number into a CVInteger.Type
100
+ *
101
+ * @category Schema transformations
102
+ */
103
+ exports.Real = Real;
104
+ const IntegerFromNumber = exports.IntegerFromNumber = CVInteger.SchemaFromNumber;
105
+ /**
106
+ * A Schema that represents a CVInteger.Type
107
+ *
108
+ * @category Schema instances
109
+ */
110
+ const IntegerFromSelf = exports.IntegerFromSelf = CVInteger.SchemaFromSelf;
111
+ /**
112
+ * A Schema that transforms a number into a CVPositiveInteger.Type
113
+ *
114
+ * @category Schema transformations
115
+ */
116
+ const PositiveIntegerFromNumber = exports.PositiveIntegerFromNumber = CVPositiveInteger.SchemaFromNumber;
117
+ /**
118
+ * A Schema that represents a CVPositiveInteger.Type
119
+ *
120
+ * @category Schema instances
121
+ */
122
+ const PositiveIntegerFromSelf = exports.PositiveIntegerFromSelf = CVPositiveInteger.SchemaFromSelf;
123
+ /**
124
+ * A Schema that transforms a number into a CVPositiveReal.Type
125
+ *
126
+ * @category Schema transformations
127
+ */
128
+ const PositiveRealFromNumber = exports.PositiveRealFromNumber = CVPositiveReal.SchemaFromNumber;
129
+ /**
130
+ * A Schema that represents a CVPositiveReal.Type
131
+ *
132
+ * @category Schema instances
133
+ */
134
+ const PositiveRealFromSelf = exports.PositiveRealFromSelf = CVPositiveReal.SchemaFromSelf;
135
+ const BigDecimalFromString = format => {
136
+ const parser = CVNumberBase10Format.toBigDecimalParser(format);
137
+ const formatter = CVNumberBase10Format.toNumberFormatter(format);
138
+ return _effect.Schema.transformOrFail(_effect.Schema.String, _effect.Schema.BigDecimalFromSelf, {
139
+ strict: true,
140
+ decode: (input, _options, ast) => (0, _effect.pipe)(input, parser, _effect.Option.map(_effect.ParseResult.succeed), _effect.Option.getOrElse(() => _effect.ParseResult.fail(new _effect.ParseResult.Type(ast, input, 'Failed to convert string to a(n) ' + CVNumberBase10Format.toDescription(format))))),
141
+ encode: (0, _effect.flow)(formatter, _effect.ParseResult.succeed)
142
+ });
143
+ };
144
+ exports.BigDecimal = BigDecimalFromString;
145
+ /**
146
+ * A Schema that represents a CVDateTime
147
+ *
148
+ * @category Schema instances
149
+ */
150
+ const DateTimeFromSelf = exports.DateTimeFromSelf = /*#__PURE__*/_effect.Schema.declare(input => CVDateTime.has(input));
151
+ /**
152
+ * A Schema that transforms a CVDateTime into a Date. The CVDateTime object is created with the
153
+ * default timeZoneOffset of the machine this code is running on
154
+ *
155
+ * @category Schema instances
156
+ */
157
+ const DateFromDateTime = exports.DateFromDateTime = /*#__PURE__*/_effect.Schema.transform(DateTimeFromSelf, _effect.Schema.DateFromSelf, {
158
+ strict: true,
159
+ decode: CVDateTime.toDate,
160
+ encode: CVDateTime.fromDate
161
+ });
162
+ /**
163
+ * A Schema that transforms a CVDateTime into an Effect DateTime.Zoned. Both objects share the same
164
+ * time zone offset.
165
+ *
166
+ * @category Schema instances
167
+ */
168
+ const DateTimeZonedFromDateTime = exports.DateTimeZonedFromDateTime = /*#__PURE__*/_effect.Schema.transform(DateTimeFromSelf, _effect.Schema.DateTimeZonedFromSelf, {
169
+ strict: true,
170
+ decode: CVDateTime.toEffectDateTime,
171
+ encode: CVDateTime.fromEffectDateTime
172
+ });
173
+ const DateTimeFromString = format => {
174
+ const parser = CVDateTimeFormat.toParser(format);
175
+ const formatter = CVDateTimeFormat.toFormatter(format);
176
+ return _effect.Schema.transformOrFail(_effect.Schema.String, DateTimeFromSelf, {
177
+ strict: true,
178
+ decode: (input, _options, ast) => (0, _effect.pipe)(input, parser, _effect.Either.mapLeft(inputError => new _effect.ParseResult.Type(ast, input, inputError.message))),
179
+ encode: (input, _options, ast) => (0, _effect.pipe)(input, formatter, _effect.Either.mapLeft(inputError => new _effect.ParseResult.Type(ast, input, inputError.message)))
180
+ });
181
+ };
182
+ exports.DateTime = DateTimeFromString;
183
+ /**
184
+ * A Schema that transforms a string into a Date according to the CVDateTimeFormat `format`. Read
185
+ * documentation of CVDateTimeFormat.toParser and CVDateTimeFormat.toFormatter for more details
186
+ *
187
+ * @category Schema transformations
188
+ */
189
+ const Date = format => _effect.Schema.compose(DateTimeFromString(format), DateFromDateTime);
190
+ /**
191
+ * A Schema that transforms a string into a Date according to the CVDateTimeFormat `format`. Read
192
+ * documentation of CVDateTimeFormat.toParser and CVDateTimeFormat.toFormatter for more details
193
+ *
194
+ * @category Schema transformations
195
+ */
196
+ exports.Date = Date;
197
+ const DateTimeZoned = format => _effect.Schema.compose(DateTimeFromString(format), DateTimeZonedFromDateTime);
198
+ /**
199
+ * A Schema that transforms a string into an object according to a CVTemplate (see Template.ts)
200
+ *
201
+ * @category Schema transformations
202
+ */
203
+ exports.DateTimeZoned = DateTimeZoned;
204
+ const Template = template => {
205
+ const parser = CVTemplate.toParser(template);
206
+ const formatter = CVTemplate.toFormatter(template);
207
+ const schemaOutput = (0, _effect.pipe)(template.templateParts, _effect.Array.filterMap((0, _effect.flow)(_effectLib.MMatch.make, _effectLib.MMatch.when(CVTemplatePart.isSeparator, () => _effect.Option.none()), _effectLib.MMatch.when(CVTemplatePart.isPlaceholder, (0, _effect.flow)(_effectLib.MTuple.makeBothBy({
208
+ toFirst: CVTemplatePlaceholder.name,
209
+ toSecond: CVTemplatePlaceholder.schemaInstance
210
+ }), _effect.Option.some)), _effectLib.MMatch.exhaustive)), _effect.Record.fromEntries, _effect.Schema.Struct);
211
+ return _effect.Schema.transformOrFail(_effect.Schema.String, schemaOutput, {
212
+ strict: true,
213
+ decode: (input, _options, ast) => (0, _effect.pipe)(input, parser, _effect.Either.mapLeft(inputError => new _effect.ParseResult.Type(ast, input, inputError.message))),
214
+ encode: (input, _options, ast) => (0, _effect.pipe)(input, formatter, _effect.Either.mapLeft(inputError => new _effect.ParseResult.Type(ast, input, inputError.message)))
215
+ });
216
+ };
217
+ exports.Template = Template;
218
+ //# sourceMappingURL=Schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Schema.js","names":["_effectLib","require","_effect","CVDateTime","_interopRequireWildcard","CVDateTimeFormat","CVEmail","CVInteger","CVNumberBase10Format","CVPositiveInteger","CVPositiveReal","CVReal","CVSemVer","CVTemplate","CVTemplatePart","CVTemplatePlaceholder","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Email","exports","SchemaFromString","EmailFromSelf","SchemaFromSelf","SemVer","SemVerFromSelf","RealFromNumber","SchemaFromNumber","RealFromSelf","Real","format","parser","toRealParser","formatter","toNumberFormatter","Schema","transformOrFail","String","strict","decode","input","_options","ast","pipe","Either","fromOption","ParseResult","Type","toDescription","encode","flow","succeed","IntegerFromNumber","IntegerFromSelf","PositiveIntegerFromNumber","PositiveIntegerFromSelf","PositiveRealFromNumber","PositiveRealFromSelf","BigDecimalFromString","toBigDecimalParser","BigDecimalFromSelf","Option","map","getOrElse","fail","BigDecimal","DateTimeFromSelf","declare","DateFromDateTime","transform","DateFromSelf","toDate","fromDate","DateTimeZonedFromDateTime","DateTimeZonedFromSelf","toEffectDateTime","fromEffectDateTime","DateTimeFromString","toParser","toFormatter","mapLeft","inputError","message","DateTime","Date","compose","DateTimeZoned","Template","template","schemaOutput","templateParts","Array","filterMap","MMatch","make","when","isSeparator","none","isPlaceholder","MTuple","makeBothBy","toFirst","name","toSecond","schemaInstance","some","exhaustive","Record","fromEntries","Struct"],"sources":["../../esm/Schema.ts"],"sourcesContent":[null],"mappings":";;;;;;AAKA,IAAAA,UAAA,gBAAAC,OAAA;AACA,IAAAC,OAAA,gBAAAD,OAAA;AAYA,IAAAE,UAAA,gBAAAC,uBAAA,cAAAH,OAAA;AACA,IAAAI,gBAAA,gBAAAD,uBAAA,cAAAH,OAAA;AACA,IAAAK,OAAA,gBAAAF,uBAAA,cAAAH,OAAA;AACA,IAAAM,SAAA,gBAAAH,uBAAA,cAAAH,OAAA;AACA,IAAAO,oBAAA,gBA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oD,YAAY,EAAE;IAC1DnD,MAAM,EAAE,IAAI;IACZC,MAAM,EAAEA,CAACC,KAAK,EAAEC,QAAQ,EAAEC,GAAG,KAC5B,IAAAxD,OAAA,CAAAyD,IAAI,EACHH,KAAK,EACLT,MAAM,EACN7C,OAAA,CAAA0D,MAAM,CAACoC,OAAO,CAAEC,UAAU,IAAK,IAAI/F,OAAA,CAAA4D,WAAW,CAACC,IAAI,CAACL,GAAG,EAAEF,KAAK,EAAEyC,UAAU,CAACC,OAAO,CAAC,CAAC,CAC3E;IACXjC,MAAM,EAAEA,CAACT,KAAK,EAAEC,QAAQ,EAAEC,GAAG,KAC5B,IAAAxD,OAAA,CAAAyD,IAAI,EACHH,KAAc,EACdP,SAAS,EACT/C,OAAA,CAAA0D,MAAM,CAACoC,OAAO,CAAEC,UAAU,IAAK,IAAI/F,OAAA,CAAA4D,WAAW,CAACC,IAAI,CAACL,GAAG,EAAEF,KAAK,EAAEyC,UAAU,CAACC,OAAO,CAAC,CAAC;GAEtF,CAAU;AACZ,CAAC;AAAC9D,OAAA,CAAAmE,QAAA,GAAAA,QAAA","ignoreList":[]}
package/cjs/SemVer.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.unsafeFromString = exports.moduleTag = exports.has = exports.fromStringOrThrow = exports.fromStringOption = exports.fromString = exports.constructor = exports.TypeId = exports.SchemaFromString = exports.SchemaFromSelf = void 0;
7
+ var _effectLib = /*#__PURE__*/require("@parischap/effect-lib");
8
+ var _effect = /*#__PURE__*/require("effect");
9
+ /** A module that implements a SemVer brand */
10
+
11
+ /**
12
+ * Module tag
13
+ *
14
+ * @category Module markers
15
+ */
16
+ const moduleTag = exports.moduleTag = '@parischap/conversions/SemVer/';
17
+ /**
18
+ * Module TypeId
19
+ *
20
+ * @category Module markers
21
+ */
22
+ const TypeId = exports.TypeId = /*#__PURE__*/Symbol.for(moduleTag);
23
+ /**
24
+ * Constructs a SemVer without any verifications
25
+ *
26
+ * @category Constructors
27
+ */
28
+ const unsafeFromString = exports.unsafeFromString = /*#__PURE__*/_effect.Brand.nominal();
29
+ /**
30
+ * Constructs a SemVer from a string. Throws an error if the provided string does not represent a
31
+ * SemVer
32
+ *
33
+ * @category Constructors
34
+ */
35
+ const constructor = exports.constructor = /*#__PURE__*/_effect.Brand.refined(_effectLib.MString.isSemVer, s => _effect.Brand.error(`'${s}' does not represent a semver`));
36
+ /**
37
+ * Constructs an Option of a SemVer from a string.
38
+ *
39
+ * @category Constructors
40
+ */
41
+ const fromStringOption = exports.fromStringOption = /*#__PURE__*/constructor.option.bind(constructor);
42
+ /**
43
+ * Constructs an Either of a SemVer from a string.
44
+ *
45
+ * @category Constructors
46
+ */
47
+ const fromString = exports.fromString = /*#__PURE__*/constructor.either.bind(constructor);
48
+ /**
49
+ * Constructs a SemVer or throws.
50
+ *
51
+ * @category Constructors
52
+ */
53
+ const fromStringOrThrow = exports.fromStringOrThrow = constructor;
54
+ /**
55
+ * Checks if a string is a semver
56
+ *
57
+ * @category Refinement
58
+ */
59
+ const has = input => _effectLib.MString.isSemVer(input);
60
+ /**
61
+ * A Schema that transforms a string into an CVBrand.SemVer.Type
62
+ *
63
+ * @internal
64
+ */
65
+ exports.has = has;
66
+ const SchemaFromString = exports.SchemaFromString = /*#__PURE__*/_effect.Schema.String.pipe(/*#__PURE__*/_effect.Schema.fromBrand(constructor));
67
+ /**
68
+ * A Schema that represents a CVBrand.SemVer.Type
69
+ *
70
+ * @internal
71
+ */
72
+ const SchemaFromSelf = exports.SchemaFromSelf = /*#__PURE__*/_effect.Schema.typeSchema(SchemaFromString);
73
+ //# sourceMappingURL=SemVer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SemVer.js","names":["_effectLib","require","_effect","moduleTag","exports","TypeId","Symbol","for","unsafeFromString","Brand","nominal","constructor","refined","MString","isSemVer","s","error","fromStringOption","option","bind","fromString","either","fromStringOrThrow","has","input","S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