Skip to content

Commit 004d7db

Browse files
committed
chore: updated docs, added a playground
1 parent ad79bd9 commit 004d7db

21 files changed

+405
-128
lines changed

effect-libs.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
{
2424
"path": "packages/conversions",
2525
},
26+
{
27+
"path": "packages/playground",
28+
},
2629
],
2730
"settings": {
2831
"typescript.tsdk": "effect-libs\\node_modules\\typescript\\lib",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"eslint-plugin-yml": "latest",
3737
"prettier": "latest",
3838
"typescript": "latest",
39+
"tsx": "latest",
3940
"typescript-eslint": "latest",
4041
"vite": "latest",
4142
"vite-node": "latest",
@@ -47,8 +48,7 @@
4748
"babel-plugin-annotate-pure-calls": "latest",
4849
"@babel/cli": "latest",
4950
"@effect/docgen": "latest",
50-
"prettier-plugin-jsdoc": "latest",
51-
"tsx": "latest"
51+
"prettier-plugin-jsdoc": "latest"
5252
},
5353
"pnpm": {
5454
"patchedDependencies": {},

packages/conversions/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ After reading this introduction, you may take a look at the [API](https://parisc
4545

4646
This package contains:
4747

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.
5050
- 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.
5353
- 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
5454

5555
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`.
5656

57-
### <a name="RoundingModule"></a>A) Rounding module
57+
### <a id="RoundingModule"></a>A) Rounding module
5858

5959
#### 1. Usage example
6060

@@ -226,7 +226,7 @@ console.log(Equal.equals(CVRoundingOption.halfExpand2, dummyOption1));
226226
console.log(Equal.equals(CVRoundingOption.halfExpand2, dummyOption2));
227227
```
228228

229-
### <a name="NumberParserFormatter"></a>B) Number and `BigDecimal` parser/formatter
229+
### <a id="NumberParserFormatter"></a>B) Number and BigDecimal parser/formatter
230230

231231
#### 1. Usage example
232232

@@ -293,19 +293,19 @@ console.log(frenchStyleDecoder("1 024,56"));
293293
console.log(frenchStyleEncoder(CVReal.unsafeFromNumber(1024.56)));
294294
```
295295

296-
#### 2. `CVNumberBase10Format` instances
296+
#### 2. CVNumberBase10Format instances
297297

298298
In the previous example, we used the `ukStyleNumber`, `ukStyleUngroupedNumber` and `frenchStyleInteger` `CVNumberBase10Format` instances.
299299

300300
You will find in the [API](https://parischap.github.io/effect-libs/conversions/NumberBase10Format.ts) the list of all pre-defined instances.
301301

302-
#### 3. `CVNumberBase10Format` Instance modifiers
302+
#### 3. CVNumberBase10Format Instance modifiers
303303

304304
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.
305305

306306
There are quite a few such modifiers whose list you will find in the [API](https://parischap.github.io/effect-libs/conversions/NumberBase10Format.ts).
307307

308-
#### 4. `CVNumberBase10Format` in more details
308+
#### 4. CVNumberBase10Format in more details
309309

310310
If you have very specific needs, you can define your own CVNumberBase10Format instance that must comply with the following interface:
311311

@@ -436,7 +436,7 @@ console.log(
436436
);
437437
```
438438

439-
### <a name="Templating"></a>C) Templating
439+
### <a id="Templating"></a>C) Templating
440440

441441
#### 1. Usage example
442442

@@ -603,7 +603,7 @@ Inversely, given a template and the values of the placeholders that compose it (
603603

604604
we will obtain the text: "Tom is a 15-year old boy."
605605

606-
#### 3. `CVTemplateSeparator`'s
606+
#### 3. CVTemplateSeparator's
607607

608608
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.
609609

@@ -766,7 +766,7 @@ const template = CVTemplate.make(
766766
console.log(template);
767767
```
768768

769-
### <a name="DateTimeModule"></a>D) DateTime module
769+
### <a id="DateTimeModule"></a>D) DateTime module
770770

771771
#### 1. Introduction
772772

@@ -1009,7 +1009,7 @@ console.log(CVDateTime.isLastMonthDay(aDate));
10091009
console.log(CVDateTime.isFirstMonthDay(aDate));
10101010
```
10111011

1012-
### <a name="DateTimeParserFormatter"></a>E) DateTime parser/formatter
1012+
### <a id="DateTimeParserFormatter"></a>E) DateTime parser/formatter
10131013

10141014
#### 1. Usage example
10151015

@@ -1249,7 +1249,7 @@ export type Token =
12491249
| "zszs";
12501250
```
12511251

1252-
#### 3. `CVDateTimeFormatContext`
1252+
#### 3. CVDateTimeFormatContext
12531253

12541254
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:
12551255

@@ -1289,7 +1289,7 @@ const frenchFormat = CVDateTimeFormat.make({
12891289
console.log(frenchFormat);
12901290
```
12911291

1292-
### <a name="Branding"></a>F) Branding
1292+
### <a id="Branding"></a>F) Branding
12931293

12941294
#### 1. Introduction
12951295

packages/effect-report/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"scripts": {},
4040
"devDependencies": {},
4141
"peerDependencies": {
42-
"@parischap/effect-lib": "^0.6.0",
43-
"@parischap/ansi-styles": "^0.2.2",
42+
"@parischap/effect-lib": "^0.7.0",
43+
"@parischap/ansi-styles": "^0.2.3",
4444
"effect": "^3.17.13"
4545
},
4646
"publishConfig": {},

packages/node-effect-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"scripts": {},
4040
"devDependencies": {},
4141
"peerDependencies": {
42-
"@parischap/effect-lib": "^0.6.0",
42+
"@parischap/effect-lib": "^0.7.0",
4343
"effect": "^3.17.13",
4444
"@effect/platform": "^0.90.7",
4545
"@effect/platform-node": "^0.96.1"

packages/playground/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist/
2+
node_modules/
3+
vite.config.ts.timestamp-*.mjs
4+
/.tsbuildinfo/
5+
/*.old

packages/playground/.madgerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"detectiveOptions": {
3+
"ts": {
4+
"skipTypeImports": true
5+
}
6+
}
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Same rules as .git
2+
node_modules/

packages/playground/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div align="center">
2+
3+
# playground
4+
5+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { eslintConfigLibrary } from '@parischap/configs';
2+
3+
export default eslintConfigLibrary;

0 commit comments

Comments
 (0)