browser-decoder.js 342 B

1234567891011121314151617
  1. module.exports = class BrowserDecoder {
  2. constructor (encoding) {
  3. this.decoder = new TextDecoder(encoding === 'utf16le' ? 'utf16-le' : encoding)
  4. }
  5. get remaining () {
  6. return -1
  7. }
  8. decode (data) {
  9. return this.decoder.decode(data, { stream: true })
  10. }
  11. flush () {
  12. return this.decoder.decode(new Uint8Array(0))
  13. }
  14. }