encoding-browser.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Same as `@exodus/bytes/encoding.js`, but in browsers instead of polyfilling just uses whatever the
  3. * browser provides, drastically reducing the bundle size (to less than 2 KiB gzipped).
  4. *
  5. * Does not provide `isomorphicDecode` and `isomorphicEncode` exports.
  6. *
  7. * ```js
  8. * import { TextDecoder, TextEncoder } from '@exodus/bytes/encoding-browser.js'
  9. * import { TextDecoderStream, TextEncoderStream } from '@exodus/bytes/encoding-browser.js' // Requires Streams
  10. *
  11. * // Hooks for standards
  12. * import { getBOMEncoding, legacyHookDecode, labelToName, normalizeEncoding } from '@exodus/bytes/encoding-browser.js'
  13. * ```
  14. *
  15. * Under non-browser engines (Node.js, React Native, etc.) a full polyfill is used as those platforms
  16. * do not provide sufficiently complete / non-buggy `TextDecoder` APIs.
  17. *
  18. * > [!NOTE]
  19. * > Implementations in browsers [have bugs](https://docs.google.com/spreadsheets/d/1pdEefRG6r9fZy61WHGz0TKSt8cO4ISWqlpBN5KntIvQ/edit),
  20. * > but they are fixing them and the expected update window is short.\
  21. * > If you want to circumvent browser bugs, use full `@exodus/bytes/encoding.js` import.
  22. *
  23. * @module @exodus/bytes/encoding-browser.js
  24. */
  25. export {
  26. TextDecoder,
  27. TextEncoder,
  28. TextDecoderStream,
  29. TextEncoderStream,
  30. normalizeEncoding,
  31. getBOMEncoding,
  32. labelToName,
  33. legacyHookDecode,
  34. } from './encoding.js'