Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,26 @@ Various range limits specific to the WebAssembly types are present as global con
const f64.MAX_SAFE_INTEGER: f64 = 9007199254740991
const f64.EPSILON: f64 = 2.2204460492503131e-16
```

## Special functions

### parse

All value types (except `v128`) have some special `parse` method which more are the most preferable and ideomatic way of parsing a string into the appropriate type if you don't require portability.

```ts
i8.parse("0x7F") // same as I8.parseInt
i8.parse("7F", 16) // same as I8.parseInt
u8.parse("0x7F") // same as U8.parseInt
i16.parse("16") // same as I16.parseInt
u16.parse("16") // same as U16.parseInt
i32.parse("32") // same as I32.parseInt
u32.parse("32") // same as U32.parseInt
u64.parse("64") // same as U64.parseInt
u64.parse("64") // same as U64.parseInt

f32.parse("32.0") // same as F32.parseFloat
f64.parse("1e64") // same as F64.parseFloat

bool.parse(" true\n") // hasn't equivalent
```