@parischap/conversions 0.2.0 → 0.3.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 (2) hide show
  1. package/README.md +15 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -45,16 +45,16 @@ After reading this introduction, you may take a look at the [API](https://parisc
45
45
 
46
46
  This package contains:
47
47
 
48
- - a [module to round numbers and `BigDecimal`'s](#RoundingModule) with the same rounding options as those offered by the javascript INTL namespace: Ceil, Floor, Expand, Trunc, HalfCeil...
49
- - a safe, easy-to-use [number/`BigDecimal` parser/formatter](#NumberParserFormatter) with almost all the options offered by the javascript INTL namespace: choice of the thousand separator, of the fractional separator, of the minimum and maximum number of fractional digits, of the rounding mode, of the sign display mode, of whether to show or not the integer part when it's zero, of whether to use a scientific or engineering notation, of the character to use as exponent mark... It can also be used as a `Schema` instead of the `Effect.Schema.NumberFromString` transformer.
48
+ - a [module to round numbers and BigDecimal's](#RoundingModule) with the same rounding options as those offered by the javascript INTL namespace: Ceil, Floor, Expand, Trunc, HalfCeil...
49
+ - a safe, easy-to-use [number/BigDecimal parser/formatter](#NumberParserFormatter) with almost all the options offered by the javascript INTL namespace: choice of the thousand separator, of the fractional separator, of the minimum and maximum number of fractional digits, of the rounding mode, of the sign display mode, of whether to show or not the integer part when it's zero, of whether to use a scientific or engineering notation, of the character to use as exponent mark... It can also be used as a `Schema` instead of the `Effect.Schema.NumberFromString` transformer.
50
50
  - an equivalent to the PHP [sprintf and sscanf functions](#Templating) with real typing of the placeholders. Although `Effect.Schema` does offer the [`TemplateLiteralParser` API](https://effect.website/docs/schema/basic-usage/#templateliteralparser), the latter does not provide a solution to situations such as fixed length fields (potentially padded), numbers formatted otherwise than in the English format... This module can also be used as a `Schema`.
51
- - a very easy to use [`CVDateTime` module](#DateTimeModule) that implements natively the Iso calendar (Iso year and Iso week). It is also faster than its `Effect` counterpart as it implements an internal state that's only used to speed up calculation times (but does not alter the result of functions; so `CVDateTime` functions can be viewed as pure from a user's perspective). It can therefore be useful in applications where time is of essence.
52
- - a [`CVDateTime` parser/formatter](#DateTimeParserFormatter) which supports many of the available [unicode tokens](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). It can also be used as a `Schema` instead of the `Effect.Schema.Date` transformer.
51
+ - a very easy to use [DateTime module](#DateTimeModule) that implements natively the Iso calendar (Iso year and Iso week). It is also faster than its `Effect` counterpart as it implements an internal state that's only used to speed up calculation times (but does not alter the result of functions; so `CVDateTime` functions can be viewed as pure from a user's perspective). It can therefore be useful in applications where time is of essence.
52
+ - a [DateTime parser/formatter](#DateTimeParserFormatter) which supports many of the available [unicode tokens](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). It can also be used as a `Schema` instead of the `Effect.Schema.Date` transformer.
53
53
  - a few [brands](#Branding) which come in handy in many projects such as email, semantic versioning, integer numbers, positive integer numbers, real numbers and positive real numbers. All these brands are also defined as `Schemas`. Please read the [`Effect` documentation about Branding](https://effect.website/docs/code-style/branded-types/) if you are not familiar with this concept
54
54
 
55
55
  Most functions of this package return an `Either` or an `Option` to signify the possibility of an error. However, if you are not an `Effect` user and do not care to learn more about it, you can simply use the `OrThrow` variant of the function. For instance, use `CVDateTime.setWeekdayOrThrow` instead of `CVDateTime.setWeekday`. As its name suggests, it will throw in case failure. Some functions return functions that return an `Either` or throw. In that case, the variant for non-`Effect` users contains the word `Throwing`, e.g. use `CVDateTimeFormat.toThrowingFormatter` instead of `CVDateTimeFormat.toFormatter`.
56
56
 
57
- ### <a name="RoundingModule"></a>A) Rounding module
57
+ ### <a id="RoundingModule"></a>A) Rounding module
58
58
 
59
59
  #### 1. Usage example
60
60
 
@@ -226,7 +226,7 @@ console.log(Equal.equals(CVRoundingOption.halfExpand2, dummyOption1));
226
226
  console.log(Equal.equals(CVRoundingOption.halfExpand2, dummyOption2));
227
227
  ```
228
228
 
229
- ### <a name="NumberParserFormatter"></a>B) Number and `BigDecimal` parser/formatter
229
+ ### <a id="NumberParserFormatter"></a>B) Number and BigDecimal parser/formatter
230
230
 
231
231
  #### 1. Usage example
232
232
 
@@ -293,19 +293,19 @@ console.log(frenchStyleDecoder("1 024,56"));
293
293
  console.log(frenchStyleEncoder(CVReal.unsafeFromNumber(1024.56)));
294
294
  ```
295
295
 
296
- #### 2. `CVNumberBase10Format` instances
296
+ #### 2. CVNumberBase10Format instances
297
297
 
298
298
  In the previous example, we used the `ukStyleNumber`, `ukStyleUngroupedNumber` and `frenchStyleInteger` `CVNumberBase10Format` instances.
299
299
 
300
300
  You will find in the [API](https://parischap.github.io/effect-libs/conversions/NumberBase10Format.ts) the list of all pre-defined instances.
301
301
 
302
- #### 3. `CVNumberBase10Format` Instance modifiers
302
+ #### 3. CVNumberBase10Format Instance modifiers
303
303
 
304
304
  Sometimes, you will need to bring some small modifications to a pre-defined `CVNumberBase10Format` instance. For instance, in the previous example, we defined the `ukStyleNumberWithEngineeringNotation` instance by using the `withEngineeringScientificNotation` modifier on the `ukStyleNumber` pre-defined instance.
305
305
 
306
306
  There are quite a few such modifiers whose list you will find in the [API](https://parischap.github.io/effect-libs/conversions/NumberBase10Format.ts).
307
307
 
308
- #### 4. `CVNumberBase10Format` in more details
308
+ #### 4. CVNumberBase10Format in more details
309
309
 
310
310
  If you have very specific needs, you can define your own CVNumberBase10Format instance that must comply with the following interface:
311
311
 
@@ -436,7 +436,7 @@ console.log(
436
436
  );
437
437
  ```
438
438
 
439
- ### <a name="Templating"></a>C) Templating
439
+ ### <a id="Templating"></a>C) Templating
440
440
 
441
441
  #### 1. Usage example
442
442
 
@@ -603,7 +603,7 @@ Inversely, given a template and the values of the placeholders that compose it (
603
603
 
604
604
  we will obtain the text: "Tom is a 15-year old boy."
605
605
 
606
- #### 3. `CVTemplateSeparator`'s
606
+ #### 3. CVTemplateSeparator's
607
607
 
608
608
  A `CVTemplateSeparator` represents the immutable part of a template. Upon parsing, we must check that it is present as is in the text. Upon formatting, it must be inserted as is into the text.
609
609
 
@@ -766,7 +766,7 @@ const template = CVTemplate.make(
766
766
  console.log(template);
767
767
  ```
768
768
 
769
- ### <a name="DateTimeModule"></a>D) DateTime module
769
+ ### <a id="DateTimeModule"></a>D) DateTime module
770
770
 
771
771
  #### 1. Introduction
772
772
 
@@ -1009,7 +1009,7 @@ console.log(CVDateTime.isLastMonthDay(aDate));
1009
1009
  console.log(CVDateTime.isFirstMonthDay(aDate));
1010
1010
  ```
1011
1011
 
1012
- ### <a name="DateTimeParserFormatter"></a>E) DateTime parser/formatter
1012
+ ### <a id="DateTimeParserFormatter"></a>E) DateTime parser/formatter
1013
1013
 
1014
1014
  #### 1. Usage example
1015
1015
 
@@ -1249,7 +1249,7 @@ export type Token =
1249
1249
  | "zszs";
1250
1250
  ```
1251
1251
 
1252
- #### 3. `CVDateTimeFormatContext`
1252
+ #### 3. CVDateTimeFormatContext
1253
1253
 
1254
1254
  Some of the available tokens are language specific. For instance the `MMMM` token is expected to display `december` in English and `décembre` in French. For this reason, you need to build a `CVDateTimeFormatContext` before building a `CVDateTimeFormat`. You can build a `CVDateTimeFormatContext` in one of the three following ways:
1255
1255
 
@@ -1289,7 +1289,7 @@ const frenchFormat = CVDateTimeFormat.make({
1289
1289
  console.log(frenchFormat);
1290
1290
  ```
1291
1291
 
1292
- ### <a name="Branding"></a>F) Branding
1292
+ ### <a id="Branding"></a>F) Branding
1293
1293
 
1294
1294
  #### 1. Introduction
1295
1295
 
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "directory": "packages/conversions"
44
44
  },
45
45
  "homepage": "https://github.com/parischap/effect-libs/tree/master/packages/conversions",
46
- "version": "0.2.0",
46
+ "version": "0.3.0",
47
47
  "main": "./cjs/index.js",
48
48
  "types": "./dts/index.d.ts"
49
49
  }