Skip to content

Instantly share code, notes, and snippets.

View joshuakb2's full-sized avatar

Joshua Baker joshuakb2

  • Enseo
  • Fort Collins, CO
  • 03:06 (UTC -06:00)
View GitHub Profile
@joshuakb2
joshuakb2 / duplicateStringDecoder.js
Created November 19, 2020 04:38
Duplicate a StringDecoder
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;
}