aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/@exodus/bytes/whatwg.d.ts
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
commit76cb9c2a39d477a64824a985ade40507e3bbade1 (patch)
tree41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/@exodus/bytes/whatwg.d.ts
parent819a39a21ac992b1393244a4c283bbb125208c69 (diff)
downloadneko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/@exodus/bytes/whatwg.d.ts')
-rw-r--r--vanilla/node_modules/@exodus/bytes/whatwg.d.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/vanilla/node_modules/@exodus/bytes/whatwg.d.ts b/vanilla/node_modules/@exodus/bytes/whatwg.d.ts
new file mode 100644
index 0000000..b0bbed7
--- /dev/null
+++ b/vanilla/node_modules/@exodus/bytes/whatwg.d.ts
@@ -0,0 +1,48 @@
+/**
+ * WHATWG helpers
+ *
+ * ```js
+ * import '@exodus/bytes/encoding.js' // For full legacy multi-byte encodings support
+ * import { percentEncodeAfterEncoding } from '@exodus/bytes/whatwg.js'
+ * ```
+ *
+ * @module @exodus/bytes/whatwg.js
+ */
+
+/**
+ * Implements [percent-encode after encoding](https://url.spec.whatwg.org/#string-percent-encode-after-encoding)
+ * per WHATWG URL specification.
+ *
+ * > [!IMPORTANT]
+ * > You must import `@exodus/bytes/encoding.js` for this API to accept legacy multi-byte encodings.
+ *
+ * Encodings `utf16-le`, `utf16-be`, and `replacement` are not accepted.
+ *
+ * [C0 control percent-encode set](https://url.spec.whatwg.org/#c0-control-percent-encode-set) is
+ * always percent-encoded.
+ *
+ * `percentEncodeSet` is an addition to that, and must be a string of unique increasing codepoints
+ * in range 0x20 - 0x7e, e.g. `' "#<>'`.
+ *
+ * This method accepts [DOMStrings](https://webidl.spec.whatwg.org/#idl-DOMString) and converts them
+ * to [USVStrings](https://webidl.spec.whatwg.org/#idl-USVString).
+ * This is different from e.g. `encodeURI` and `encodeURIComponent` which throw on surrogates:
+ * ```js
+ * > percentEncodeAfterEncoding('utf8', '\ud800', ' "#$%&+,/:;<=>?@[\\]^`{|}') // component
+ * '%EF%BF%BD'
+ * > encodeURIComponent('\ud800')
+ * Uncaught URIError: URI malformed
+ * ```
+ *
+ * @param encoding - The encoding label per WHATWG Encoding spec
+ * @param input - Input scalar-value string to encode
+ * @param percentEncodeSet - A string of ASCII chars to escape in addition to C0 control percent-encode set
+ * @param spaceAsPlus - Whether to encode space as `'+'` instead of `'%20'` or `' '` (default: false)
+ * @returns The percent-encoded string
+ */
+export function percentEncodeAfterEncoding(
+ encoding: string,
+ input: string,
+ percentEncodeSet: string,
+ spaceAsPlus?: boolean
+): string;