@hyperfrontend/immutable-api-utils/built-in-copy/encodingencoding
Locked, prototype-pollution-resistant copies of the global text encoding APIs.
TextEncoder and TextDecoder constructors are wrapped in factories, and atob / btoa references are captured at module-load time and frozen into a tamper-proof namespace, so encoding and base64 work continues to behave correctly even if the globals are later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.
API Reference
ƒ Functions
(Safe copy) Decodes a base64-encoded string. Use this instead of
atob().Parameters
| Name | Type | Description |
|---|---|---|
§data | string | The base64-encoded string to decode. |
Returns
stringThe decoded string.
(Safe copy) Encodes a string to base64. Use this instead of
btoa().Parameters
| Name | Type | Description |
|---|---|---|
§data | string | The string to encode. |
Returns
stringThe base64-encoded string.
(Safe copy) Creates a new TextDecoder using the captured TextDecoder constructor. Use this instead of
new TextDecoder().Parameters
Returns
TextDecoderA new TextDecoder instance.
(Safe copy) Creates a new TextEncoder using the captured TextEncoder constructor. Use this instead of
new TextEncoder().Returns
TextEncoderA new TextEncoder instance.
● Variables
(Safe copy) Namespace object containing all encoding utilities. Note: Importing this imports all methods in this namespace (no tree-shaking).