-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathWebapi__TextDecoder.res
More file actions
35 lines (25 loc) · 897 Bytes
/
Webapi__TextDecoder.res
File metadata and controls
35 lines (25 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
type t = {
encoding: string,
fatal: bool,
ignoreBOM: bool,
}
type decoderOptions
type decodeOptions
%%private(
@new external _makeWithOptions: (string, decoderOptions) => t = "TextDecoder"
@obj
external makeDecoderOptions: (
~fatal: option<bool>=?,
~ignoreBOM: option<bool>=?,
unit,
) => decoderOptions = ""
)
@new external make: unit => t = "TextDecoder"
let makeWithOptions = (~encoding="utf-8", ~fatal=?, ~ignoreBOM=?, ()) =>
_makeWithOptions(encoding, makeDecoderOptions(~fatal, ~ignoreBOM, ()))
%%private(
@obj external makeDecodeOptions: (~stream: bool) => decodeOptions = ""
@send external _decodeWithOptions: (t, Js.TypedArray2.Uint8Array.t, decodeOptions) => t = "decode"
)
@send external decode: (t, Js.TypedArray2.Uint8Array.t) => string = "decode"
let decodeStream = (t, array) => _decodeWithOptions(t, array, makeDecodeOptions(~stream=true))