diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-09 00:29:31 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-09 00:29:31 +0200 |
commit | b6b998bf608f2f82d5b639455b2fd6224b0919e2 (patch) | |
tree | 8dd1e2869b64ac584700b6de034db5c667200954 /src/js/encoding.nim | |
parent | 4c64687290c908cd791a058dede9bd4f2a1c7757 (diff) | |
download | chawan-b6b998bf608f2f82d5b639455b2fd6224b0919e2.tar.gz |
Update monoucha
Diffstat (limited to 'src/js/encoding.nim')
-rw-r--r-- | src/js/encoding.nim | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/js/encoding.nim b/src/js/encoding.nim index 2394cc6c..7d1bd126 100644 --- a/src/js/encoding.nim +++ b/src/js/encoding.nim @@ -13,7 +13,7 @@ type encoding: Charset ignoreBOM {.jsget.}: bool errorMode: DecoderErrorMode - doNotFlush: bool + stream: bool bomSeen: bool tdctx: TextDecoderContext @@ -21,10 +21,10 @@ jsDestructor(JSTextDecoder) jsDestructor(JSTextEncoder) type TextDecoderOptions = object of JSDict - fatal: bool - ignoreBOM: bool + fatal {.jsdefault.}: bool + ignoreBOM {.jsdefault.}: bool -func newJSTextDecoder(label = "utf-8", options = TextDecoderOptions()): +func newJSTextDecoder(label = "utf-8"; options = TextDecoderOptions()): JSResult[JSTextDecoder] {.jsctor.} = let encoding = getCharset(label) if encoding in {CHARSET_UNKNOWN, CHARSET_REPLACEMENT}: @@ -52,17 +52,16 @@ proc decode0(this: JSTextDecoder; ctx: JSContext; input: JSArrayBufferView; return ok(JS_NewStringLen(ctx, cstring(oq), csize_t(oq.len))) type TextDecodeOptions = object of JSDict - stream: bool + stream {.jsdefault.}: bool #TODO AllowSharedBufferSource proc decode(ctx: JSContext; this: JSTextDecoder; input = none(JSArrayBufferView); options = TextDecodeOptions()): JSResult[JSValue] {.jsfunc.} = - if not this.doNotFlush: + if not this.stream: this.tdctx = initTextDecoderContext(this.encoding, this.errorMode) this.bomSeen = false - if this.doNotFlush != options.stream: - this.doNotFlush = options.stream + this.stream = options.stream if input.isSome: return this.decode0(ctx, input.get, options.stream) return ok(JS_NewString(ctx, "")) |