From 80c0006f4703d2a70e59c8fdad264570499dd3f1 Mon Sep 17 00:00:00 2001 From: markH5 Date: Tue, 24 Sep 2024 09:27:48 +0800 Subject: [PATCH 1/2] fix:readme https://github.com/scalarhq/nominal/commit/00faaf1569300d1cff10bde15aa027679008dec6 --- Readme.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 2bf3c49..a2c1cb3 100644 --- a/Readme.md +++ b/Readme.md @@ -27,8 +27,9 @@ minutesToSeconds(seconds) ``` Nominal types solve this problem + ```ts -import { Nominal, nominal } from 'nominal-types'; +import { Nominal } from 'nominal-types'; type Minutes = Nominal<'Minutes', number>; type Seconds = Nominal<'Seconds', number>; @@ -36,7 +37,7 @@ type Seconds = Nominal<'Seconds', number>; const minutesToSeconds = (minutes: Minutes) => minutes * 60 // You can directly type cast or use nominal.make -const seconds = nominal.make(420) +const seconds = 420 as Seconds const minutes = 1337 as Minutes // doesn't work, yay type safety @@ -108,9 +109,9 @@ binarySearch(nonEmpty(sort(regularArray))) More examples in [examples folder](./examples), you can also see them typed on replit. | Example | Link | -|-------------|-----------------------------------------------------------| -| basic | https://replit.com/@CryogenicPlanet/Nominal#basic.ts | -| sorting | https://replit.com/@CryogenicPlanet/Nominal#sort.ts | +| ----------- | --------------------------------------------------------- | +| basic | https://replit.com/@CryogenicPlanet/Nominal#basic.ts | +| sorting | https://replit.com/@CryogenicPlanet/Nominal#sort.ts | | composing | https://replit.com/@CryogenicPlanet/Nominal#composing.ts | | safeRecords | https://replit.com/@CryogenicPlanet/Nominal#safeRecord.ts | From 83c7447e0289312c9a043ffde9b4c1854db279e8 Mon Sep 17 00:00:00 2001 From: markH5 Date: Tue, 24 Sep 2024 09:29:17 +0800 Subject: [PATCH 2/2] fix:readme2 --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index a2c1cb3..57de0ef 100644 --- a/Readme.md +++ b/Readme.md @@ -36,7 +36,6 @@ type Seconds = Nominal<'Seconds', number>; const minutesToSeconds = (minutes: Minutes) => minutes * 60 -// You can directly type cast or use nominal.make const seconds = 420 as Seconds const minutes = 1337 as Minutes