Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Nov 26, 2024
1 parent 4da6a67 commit 297ddd9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1325,26 +1325,29 @@ const B = Value.Encode(Type.String(), 42) // throw
### Parse
Use the Parse function to process a value. The Parse function will call a specific sequence of Value functions (operations) to process the value.
Use the Parse function to parse a value. This function calls the Value functions `Clone` `Clean`, `Default`, `Convert`, `Assert` and `Decode` in this order to process a value.
```typescript
const R = Value.Parse(Type.String(), 'hello') // const R: string = "hello"

const E = Value.Parse(Type.String(), undefined) // throws AssertError
```
The specific sequence of Value operations is `Clone` `Clean`, `Default`, `Convert`, `Assert` and `Decode`. You can specify user defined sequences in the following way.
You can override the order in which functions are are run, or omit function calls entirely in the following way.
```typescript
// Same as calling the Assert() function
// Runs no functions.

const R = Value.Parse([], Type.String(), 12345)

// Runs the Assert() function.

const E = Value.Parse(['Assert'], Type.String(), 12345)

// Same as calling the Convert() then Assert() functions.
// Runs the Convert() function followed by the Assert() function.

const S = Value.Parse(['Convert', 'Assert'], Type.String(), 12345)
```
When specifying user defined sequences, the return type of Parse will be unknown.
<a name='values-equal'></a>
Expand Down

0 comments on commit 297ddd9

Please sign in to comment.