@@ -100,40 +100,43 @@ _These are only provided as a compatibility layer, prefer hardened APIs instead
100100
101101### Lite version
102102
103- Alternate exports exist that can help reduce bundle size:
103+ Alternate exports exist that can help reduce bundle size, see comparison :
104104
105- * ` @exodus/bytes/encoding-lite.js ` - if you don't need support for legacy multi-byte encodings.
105+ | import | size |
106+ | - | - |
107+ | [ @exodus/bytes /encoding-browser.js] ( #exodusbytesencoding-browserjs- ) | <sub >![ ] ( https://img.shields.io/bundlejs/size/@exodus/bytes/encoding-browser.js?style=flat-square ) </sub > |
108+ | [ @exodus/bytes /encoding-lite.js] ( #exodusbytesencoding-lite- ) | <sub >![ ] ( https://img.shields.io/bundlejs/size/@exodus/bytes/encoding-lite.js?style=flat-square ) </sub > |
109+ | [ @exodus/bytes /encoding.js] ( #exodusbytesencoding- ) | <sub >![ ] ( https://img.shields.io/bundlejs/size/@exodus/bytes/encoding.js?style=flat-square ) </sub > |
110+ | ` text-encoding ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/text-encoding?style=flat-square ) </sub > |
111+ | ` iconv-lite ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/iconv-lite/lib/index.js?style=flat-square ) </sub > |
112+ | ` whatwg-encoding ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/whatwg-encoding?style=flat-square ) </sub > |
106113
107- Reduces the bundle size 10x, while still keeping ` utf-8 ` , ` utf-16le ` , ` utf-16be ` and all single-byte encodings specified by the spec.
108- The only difference is support for legacy multi-byte encodings.
114+ Libraries are advised to use single-purpose hardened ` @exodus/bytes/utf8.js ` / ` @exodus/bytes/utf16.js ` APIs for Unicode.
109115
110- See [ the list of encodings] ( https://encoding.spec.whatwg.org/#names-and-labels ) .
116+ Applications (including React Native apps) are advised to load either ` @exodus/bytes/encoding-lite.js ` or ` @exodus/bytes/encoding.js `
117+ (depending on whether legacy multi-byte support is needed) and use that as a global polyfill.
111118
112- This can be useful for example in React Native global TextDecoder polyfill,
113- if you are sure that you don't need legacy multi-byte encodings support.
119+ #### ` @exodus/bytes/encoding-lite.js `
114120
115- * ` @exodus/bytes/encoding-browser.js ` - resolves to a tiny import in browser bundles, preferring native ` TextDecoder ` / ` TextEncoder ` .
121+ If you don't need support for legacy multi-byte encodings .
116122
117- For non-browsers (Node.js, React Native), loads a full implementation.
123+ Reduces the bundle size 10x, while still keeping ` utf-8 ` , ` utf-16le ` , ` utf-16be ` and all single-byte encodings specified by the spec.
124+ The only difference is support for legacy multi-byte encodings.
118125
119- > [ !NOTE]
120- > This is not the default behavior for ` @exodus/bytes/encoding.js ` because all major browser implementations have bugs,
121- > which ` @exodus/bytes/encoding.js ` fixes. Only use if you are ok with that.
126+ See [ the list of encodings] ( https://encoding.spec.whatwg.org/#names-and-labels ) .
122127
123- Libraries are advised to use single-purpose hardened ` @exodus/bytes/utf8.js ` / ` @exodus/bytes/utf16.js ` APIs for Unicode.
128+ This can be useful for example in React Native global TextDecoder polyfill,
129+ if you are sure that you don't need legacy multi-byte encodings support.
124130
125- Applications (including React Native apps) are advised to load either ` @exodus/bytes/encoding-lite.js ` or ` @exodus/bytes/encoding.js `
126- (depending on whether legacy multi-byte support is needed) and use that as a global polyfill.
131+ #### ` @exodus/bytes/encoding-browser.js `
127132
128- Bundle size comparison:
129- | import | size |
130- | - | - |
131- | ` @exodus/bytes/encoding-browser.js ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/@exodus/bytes/encoding-browser.js?style=flat-square ) </sub > |
132- | ` @exodus/bytes/encoding-lite.js ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/@exodus/bytes/encoding-lite.js?style=flat-square ) </sub > |
133- | ` @exodus/bytes/encoding.js ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/@exodus/bytes/encoding.js?style=flat-square ) </sub > |
134- | ` text-encoding ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/text-encoding?style=flat-square ) </sub > |
135- | ` iconv-lite ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/iconv-lite/lib/index.js?style=flat-square ) </sub > |
136- | ` whatwg-encoding ` | <sub >![ ] ( https://img.shields.io/bundlejs/size/whatwg-encoding?style=flat-square ) </sub > |
133+ Resolves to a tiny import in browser bundles, preferring native ` TextDecoder ` / ` TextEncoder ` .
134+
135+ For non-browsers (Node.js, React Native), loads a full implementation.
136+
137+ > [ !NOTE]
138+ > This is not the default behavior for ` @exodus/bytes/encoding.js ` because all major browser implementations have bugs,
139+ > which ` @exodus/bytes/encoding.js ` fixes. Only use if you are ok with that.
137140
138141## API
139142
0 commit comments