Skip to content

Commit

Permalink
📝 Update usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Aug 2, 2024
1 parent e902b0a commit ea8956e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ A utility pack for handling `unknown` type.

## Usage

It provides `is` module for type predicate functions and `assert`, `ensure`, and
`maybe` helper functions.
It provides `is` and `as` module for type predicate functions and `assert`,
`ensure`, and `maybe` helper functions.

### is\*
### is\* and as\*

Type predicate function is a function which returns `true` if a given value is
expected type. For example, `isString` (or `is.String`) returns `true` if a
Expand All @@ -28,7 +28,8 @@ if (is.String(a)) {
}
```

For more complex types, you can use `is*Of` (or `is.*Of`) functions like:
For more complex types, you can use `is*Of` (or `is.*Of`) functions and `as*`
(or `as.*`) like:

```typescript
import { as, is, PredicateType } from "@core/unknownutil";
Expand Down Expand Up @@ -231,11 +232,6 @@ const a: unknown = "Hello";
const _: string = maybe(a, is.String) ?? "default value";
```

## Migration

See [GitHub Wiki](https://github.com/jsr-core/unknownutil/wiki) for migration to
v3 from v2 or v2 from v1.

## License

The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
Expand Down
5 changes: 3 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* It provides `is` module for type predicate functions and `assert`, `ensure`, and
* `maybe` helper functions.
*
* ### is\*
* ### is\* and as\*
*
* Type predicate function is a function which returns `true` if a given value is
* expected type. For example, `isString` (or `is.String`) returns `true` if a
Expand All @@ -21,7 +21,8 @@
* }
* ```
*
* For more complex types, you can use `is*Of` (or `is.*Of`) functions like:
* For more complex types, you can use `is*Of` (or `is.*Of`) functions and `as*`
* (or `as.*`) functions like:
*
* ```typescript
* import {
Expand Down

0 comments on commit ea8956e

Please sign in to comment.