Created
November 19, 2020 04:38
-
-
Save joshuakb2/ce461952354110a01add1a84b4a75428 to your computer and use it in GitHub Desktop.
Duplicate a StringDecoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function duplicateStringDecoder(decoder) { | |
let r = new StringDecoder(decoder.encoding); | |
let partialCharBytes = decoder.lastTotal - decoder.lastNeed; | |
if (partialCharBytes > 0) { | |
r.write(decoder.lastChar.slice(0, partialCharBytes)); | |
} | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment