@nberlette/utf8 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +298 -0
  3. package/cjs/_dnt.shims.d.ts +1 -0
  4. package/cjs/_dnt.shims.js +61 -0
  5. package/cjs/_dnt.shims.js.map +1 -0
  6. package/cjs/_internal.d.ts +54 -0
  7. package/cjs/_internal.js +173 -0
  8. package/cjs/_internal.js.map +1 -0
  9. package/cjs/index.d.ts +28 -0
  10. package/cjs/index.js +45 -0
  11. package/cjs/index.js.map +1 -0
  12. package/cjs/package.json +3 -0
  13. package/cjs/text_decoder.d.ts +58 -0
  14. package/cjs/text_decoder.js +242 -0
  15. package/cjs/text_decoder.js.map +1 -0
  16. package/cjs/text_decoder_stream.d.ts +41 -0
  17. package/cjs/text_decoder_stream.js +120 -0
  18. package/cjs/text_decoder_stream.js.map +1 -0
  19. package/cjs/text_encoder.d.ts +39 -0
  20. package/cjs/text_encoder.js +78 -0
  21. package/cjs/text_encoder.js.map +1 -0
  22. package/cjs/text_encoder_stream.d.ts +27 -0
  23. package/cjs/text_encoder_stream.js +75 -0
  24. package/cjs/text_encoder_stream.js.map +1 -0
  25. package/esm/_dnt.shims.d.ts +1 -0
  26. package/esm/_dnt.shims.js +58 -0
  27. package/esm/_dnt.shims.js.map +1 -0
  28. package/esm/_internal.d.ts +54 -0
  29. package/esm/_internal.js +143 -0
  30. package/esm/_internal.js.map +1 -0
  31. package/esm/index.d.ts +28 -0
  32. package/esm/index.js +29 -0
  33. package/esm/index.js.map +1 -0
  34. package/esm/package.json +3 -0
  35. package/esm/text_decoder.d.ts +58 -0
  36. package/esm/text_decoder.js +238 -0
  37. package/esm/text_decoder.js.map +1 -0
  38. package/esm/text_decoder_stream.d.ts +41 -0
  39. package/esm/text_decoder_stream.js +116 -0
  40. package/esm/text_decoder_stream.js.map +1 -0
  41. package/esm/text_encoder.d.ts +39 -0
  42. package/esm/text_encoder.js +74 -0
  43. package/esm/text_encoder.js.map +1 -0
  44. package/esm/text_encoder_stream.d.ts +27 -0
  45. package/esm/text_encoder_stream.js +71 -0
  46. package/esm/text_encoder_stream.js.map +1 -0
  47. package/package.json +187 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2024+ Nicholas Berlette. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the “Software”), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,298 @@
1
+ <div align="center">
2
+
3
+ # [`@nick/utf8`]
4
+
5
+ ##### Blazing fast ponyfills for `TextEncoder`, `TextDecoder`, and more.
6
+
7
+ </div>
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ This package provides a set of high performance [ponyfill]s for `TextEncoder`
14
+ and `TextDecoder`. They're dependency-free and platform-agnostic, suitable for
15
+ use in any ES2015+ environment.
16
+
17
+ - [`TextEncoder`](#textencoder)
18
+ - [`TextDecoder`](#textdecoder)
19
+ - [`TextEncoderStream`](#textencoderstream)[^1]
20
+ - [`TextDecoderStream`](#textdecoderstream)[^1]
21
+
22
+ [^1]: Requires the `TransformStream` API to be available in the environment.
23
+
24
+ ---
25
+
26
+ ## Install
27
+
28
+ <picture align="left" width="32" height="48">
29
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.iconify.design/simple-icons:deno.svg?height=2.75rem&width=3rem&color=%23fff" />
30
+ <img align="left" src="https://api.iconify.design/simple-icons:deno.svg?height=2.75rem&width=3rem" alt="Deno" width="32" height="48" />
31
+ </picture>
32
+
33
+ ```sh
34
+ deno add @nick/utf8
35
+ ```
36
+
37
+ <img align="left" src="https://api.iconify.design/simple-icons:jsr.svg?color=%23fc0" alt="JSR" width="32" height="48" />
38
+
39
+ ```sh
40
+ npx jsr add @nick/utf8
41
+ ```
42
+
43
+ <img align="left" src="https://api.iconify.design/logos:bun.svg" alt="Bun" width="32" height="48" />
44
+
45
+ ```sh
46
+ bunx jsr add @nick/utf8
47
+ ```
48
+
49
+ <img align="left" src="https://api.iconify.design/devicon:pnpm.svg?height=2.5rem&width=2.5rem&inline=true" alt="PNPM" width="32" height="48" />
50
+
51
+ ```sh
52
+ pnpm dlx jsr add @nick/utf8
53
+ ```
54
+
55
+ <img align="left" src="https://api.iconify.design/logos:yarn.svg?height=2rem&width=2rem&inline=true" alt="Yarn" width="32" height="48" />
56
+
57
+ ```sh
58
+ yarn add @nick/utf8
59
+ ```
60
+
61
+ <br>
62
+
63
+ **Mirrored on NPM as `@nberlette/utf8`**:
64
+
65
+ <img align="left" src="https://api.iconify.design/logos:npm.svg?height=2rem&width=2rem&inline=true" alt="NPM" width="32" height="48" />
66
+
67
+ ```sh
68
+ npm install @nberlette/utf8
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Usage
74
+
75
+ ```ts
76
+ import { TextDecoder, TextEncoder } from "@nick/utf8";
77
+
78
+ const encoder = new TextEncoder();
79
+ const decoder = new TextDecoder();
80
+
81
+ const encoded = encoder.encode("Hello, World!");
82
+ const decoded = decoder.decode(encoded);
83
+
84
+ console.log(decoded); // Hello, World!
85
+ ```
86
+
87
+ ---
88
+
89
+ ## API
90
+
91
+ ### `TextEncoder`
92
+
93
+ The `TextEncoder` class encodes strings into UTF-8 byte sequences.
94
+
95
+ #### `encode(input?: string)`
96
+
97
+ Encodes the given `input` into a new `Uint8Array`.
98
+
99
+ **Returns**: a new `Uint8Array` containing the encoded bytes.
100
+
101
+ ```ts
102
+ import { TextEncoder } from "@nick/utf8";
103
+
104
+ const encoder = new TextEncoder();
105
+ const encoded = encoder.encode("Hello, World!");
106
+ console.log(encoded); // Uint8Array([...])
107
+ ```
108
+
109
+ #### `encodeInto(input: string, output: Uint8Array)`
110
+
111
+ Encodes an `input` string into an existing `Uint8Array` output buffer.
112
+
113
+ **Returns**: the number of characters read and bytes written.
114
+
115
+ ```ts
116
+ import { TextEncoder } from "@nick/utf8";
117
+
118
+ const encoder = new TextEncoder();
119
+ const output = new Uint8Array(16);
120
+ const input = "Hello, my name is Nick!"; // 23 characters
121
+ const { read, written } = encoder.encodeInto(input, output);
122
+ ```
123
+
124
+ <br /><div align="center">·<b>·</b>•<b>•</b>•<b>·</b>·</div>
125
+
126
+ ### `TextDecoder`
127
+
128
+ The `TextDecoder` class decodes UTF-8 byte sequences into strings.
129
+
130
+ #### `decode(input?: BufferSource, options?: TextDecodeOptions)`
131
+
132
+ Decodes UTF-8 bytes from the given `BufferSource` into a string.
133
+
134
+ ```ts
135
+ import { TextDecoder } from "@nick/utf8";
136
+
137
+ const decoder = new TextDecoder();
138
+ const encoded = new Uint8Array([72, 101, 108, 108, 111, 33]);
139
+ const decoded = decoder.decode(encoded);
140
+ console.log(decoded); // Hello!
141
+ ```
142
+
143
+ <br /><div align="center">·<b>·</b>•<b>•</b>•<b>·</b>·</div>
144
+
145
+ ### `TextEncoderStream`
146
+
147
+ Provides a full-duplex UTF-8 encoding stream, allowing strings to be written to
148
+ its writable side, and the encoded bytes to be read from its readable side.
149
+
150
+ > **Note**: Requires `TransformStream` to be available in the environment.
151
+
152
+ #### Usage
153
+
154
+ ```ts ignore
155
+ import { TextEncoderStream } from "@nick/utf8";
156
+
157
+ const chunks = ["Hello", ", ", "World!", "\n"];
158
+
159
+ // encode the strings and write them to stdout
160
+ await ReadableStream
161
+ .from(chunks)
162
+ .pipeThrough(new TextEncoderStream())
163
+ .pipeTo(Deno.stdout.writable, { preventClose: true });
164
+ ```
165
+
166
+ #### Properties
167
+
168
+ ##### `encoding: string`
169
+
170
+ The encoding used. Always `"utf-8"`.
171
+
172
+ ##### `readable: ReadableStream<Uint8Array>`
173
+
174
+ Returns a readable stream of encoded UTF-8 bytes.
175
+
176
+ ##### `writable: WritableStream<string>`
177
+
178
+ Returns a writable stream, to which strings can be written for encoding.
179
+
180
+ <br /><div align="center">·<b>·</b>•<b>•</b>•<b>·</b>·</div>
181
+
182
+ ### `TextDecoderStream`
183
+
184
+ Provides a full-duplex UTF-8 decoding stream, allowing UTF-8 bytes to be written
185
+ to its writable side, and the decoded strings to be read from its readable side.
186
+
187
+ Just like the [`TextDecoder`](#textdecoder) API, this class supports any type of
188
+ `BufferSource` containing UTF-8 bytes, such as `Uint8Array`, `DataView`,
189
+ `ArrayBuffer`, and more. It also supports the same `fatal` and `ignoreBOM`
190
+ decoding options, which can be passed to the constructor.
191
+
192
+ > **Note**: Requires `TransformStream` to be available in the environment.
193
+
194
+ #### Usage
195
+
196
+ ```ts
197
+ import { TextDecoderStream } from "@nick/utf8";
198
+
199
+ const decoderStream = new TextDecoderStream();
200
+
201
+ const writer = decoderStream.writable.getWriter();
202
+ writer.write(new Uint8Array([72, 101, 108, 108, 111]));
203
+ writer.close();
204
+
205
+ const reader = decoderStream.readable.getReader();
206
+ reader.read().then(({ value, done }) => {
207
+ console.log(value); // Hello
208
+ });
209
+ ```
210
+
211
+ #### Properties
212
+
213
+ ##### `encoding: string`
214
+
215
+ The encoding used by the underlying decoder.
216
+
217
+ ##### `readable: ReadableStream<string>`
218
+
219
+ The readable stream of decoded strings.
220
+
221
+ ##### `writable: WritableStream<BufferSource>`
222
+
223
+ The writable stream to which UTF-8 bytes can be written for decoding.
224
+
225
+ ---
226
+
227
+ ## Performance
228
+
229
+ The implementations in this package are highly optimized for performance. They
230
+ are written in a way that minimizes the number of allocations and copies, and
231
+ they take advantage of the fastest available APIs in the environment.
232
+
233
+ Take a look at the benchmarks below to see how this package compares to the
234
+ native APIs in Deno:
235
+
236
+ ```scala
237
+ > deno bench -A --no-check
238
+
239
+ CPU | Apple M1 Pro
240
+ Runtime | Deno 2.1.2+7c03677 (x86_64-apple-darwin)
241
+
242
+
243
+ benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
244
+ ---------------------------- ----------------------------- --------------------- --------------------------
245
+
246
+ Native TextDecoder 1.8 µs 543,200 ( 1.4 µs … 13.7 ms) 1.6 µs 2.9 µs 3.6 µs
247
+ Ponyfill TextDecoder 769.0 ns 1,300,000 (583.0 ns … 1.5 ms) 708.0 ns 1.4 µs 1.8 µs
248
+
249
+ summary
250
+ Ponyfill TextDecoder
251
+ 2.39x faster than Native TextDecoder
252
+
253
+
254
+
255
+ Native TextDecoderStream 24.6 µs 40,730 ( 13.3 µs … 5.6 ms) 18.9 µs 219.8 µs 574.2 µs
256
+ Ponyfill TextDecoderStream 5.4 µs 185,700 ( 4.5 µs … 1.5 ms) 5.1 µs 7.4 µs 9.2 µs
257
+
258
+ summary
259
+ Ponyfill TextDecoderStream
260
+ 4.56x faster than Native TextDecoderStream
261
+
262
+
263
+
264
+ Native TextEncoder 1.1 µs 926,900 (630.1 ns … 1.6 µs) 1.3 µs 1.6 µs 1.6 µs
265
+ Ponyfill TextEncoder 1.1 µs 870,300 (708.0 ns … 6.9 ms) 1.0 µs 3.6 µs 6.1 µs
266
+
267
+ summary
268
+ Ponyfill TextEncoder
269
+ 1.06x slower than Native TextEncoder
270
+
271
+
272
+
273
+ Native TextEncoderStream 8.0 µs 124,500 ( 4.9 µs … 3.6 ms) 6.0 µs 19.9 µs 44.6 µs
274
+ Ponyfill TextEncoderStream 5.8 µs 171,100 ( 4.7 µs … 1.1 ms) 5.4 µs 9.2 µs 14.9 µs
275
+
276
+ summary
277
+ Ponyfill TextEncoderStream
278
+ 1.37x faster than Native TextEncoderStream
279
+ ```
280
+
281
+ ---
282
+
283
+ <div align="center">
284
+
285
+ ##### [MIT] © [Nicholas Berlette]. All rights reserved.
286
+
287
+ ###### [GitHub] · [JSR] · [NPM] · [Bugs]
288
+
289
+ </div>
290
+
291
+ [MIT]: https://nick.mit-license.org "MIT © Nicholas Berlette. All rights reserved."
292
+ [Nicholas Berlette]: https://github.com/nberlette "Nicholas Berlette's GitHub Profile"
293
+ [`@nick/utf8`]: https://jsr.io/@nick/utf8 "Blazing fast ponyfills for `TextEncoder`, `TextDecoder`, and more."
294
+ [ponyfill]: https://ponyfill.com "A polyfill that doesn't overwrite the native implementation."
295
+ [GitHub]: https://github.com/nberlette/utf8#readme "Give me a star on GitHub! :) 🌟"
296
+ [JSR]: https://jsr.io/@nick/utf8 "View on JSR - The JavaScript Registry"
297
+ [NPM]: https://www.npmjs.com/package/@nick/utf8 "View @nberlette/utf8 on NPM"
298
+ [Bugs]: https://github.com/nberlette/utf8/issues "Submit a bug report or feature request"
@@ -0,0 +1 @@
1
+ export declare const dntGlobalThis: Omit<typeof globalThis, never>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dntGlobalThis = void 0;
4
+ const dntGlobals = {};
5
+ exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
6
+ function createMergeProxy(baseObj, extObj) {
7
+ return new Proxy(baseObj, {
8
+ get(_target, prop, _receiver) {
9
+ if (prop in extObj) {
10
+ return extObj[prop];
11
+ }
12
+ else {
13
+ return baseObj[prop];
14
+ }
15
+ },
16
+ set(_target, prop, value) {
17
+ if (prop in extObj) {
18
+ delete extObj[prop];
19
+ }
20
+ baseObj[prop] = value;
21
+ return true;
22
+ },
23
+ deleteProperty(_target, prop) {
24
+ let success = false;
25
+ if (prop in extObj) {
26
+ delete extObj[prop];
27
+ success = true;
28
+ }
29
+ if (prop in baseObj) {
30
+ delete baseObj[prop];
31
+ success = true;
32
+ }
33
+ return success;
34
+ },
35
+ ownKeys(_target) {
36
+ const baseKeys = Reflect.ownKeys(baseObj);
37
+ const extKeys = Reflect.ownKeys(extObj);
38
+ const extKeysSet = new Set(extKeys);
39
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
40
+ },
41
+ defineProperty(_target, prop, desc) {
42
+ if (prop in extObj) {
43
+ delete extObj[prop];
44
+ }
45
+ Reflect.defineProperty(baseObj, prop, desc);
46
+ return true;
47
+ },
48
+ getOwnPropertyDescriptor(_target, prop) {
49
+ if (prop in extObj) {
50
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
51
+ }
52
+ else {
53
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
54
+ }
55
+ },
56
+ has(_target, prop) {
57
+ return prop in extObj || prop in baseObj;
58
+ },
59
+ });
60
+ }
61
+ //# sourceMappingURL=_dnt.shims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.js","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":";;;AAAA,MAAM,UAAU,GAAG,EAClB,CAAC;AACW,QAAA,aAAa,GAAG,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEtE,SAAS,gBAAgB,CACvB,OAAU,EACV,MAAS;IAET,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxB,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS;YAC1B,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAQ,OAAe,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;QACH,CAA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d,CAAC;QACD,wBAAwB,CAAC,OAAO,EAAE,IAAI;YACpC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,OAAO,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC;QAC3C,CAAC;KACF,CAAQ,CAAC;AACZ,CAAC"}
@@ -0,0 +1,54 @@
1
+ export declare var undefined: undefined;
2
+ type Uncurry<T, This = void> = T extends (this: infer ThisArg, ...args: infer A) => infer R ? [This] extends [void] ? (thisArg: ThisArg, ...args: A) => R : (thisArg: This, ...args: A) => R : T extends (...args: infer A) => infer R ? (thisArg: [This] extends [void] ? unknown : This, ...args: A) => R : never;
3
+ export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float16ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor;
4
+ export type TypedArray = InstanceType<TypedArrayConstructor>;
5
+ type TypedArrayToStringTag = TypedArray[typeof Symbol.toStringTag];
6
+ type TypedArrayFromTag<T extends TypedArrayToStringTag> = TypedArray extends infer A extends TypedArray ? A extends {
7
+ [Symbol.toStringTag]: T;
8
+ } ? A : never : never;
9
+ export declare function isTypedArray<T extends TypedArrayToStringTag = TypedArrayToStringTag>(it: unknown, type?: T | undefined): it is TypedArrayFromTag<T>;
10
+ export declare const Object: typeof globalThis.Object;
11
+ export declare const ObjectGetPrototypeOf: (o: any) => any;
12
+ export declare const ObjectDefineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
13
+ export declare const ObjectGetOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
14
+ export declare const toString: (thisArg: unknown) => string;
15
+ export declare const Error: typeof globalThis.Error;
16
+ export declare const TypeError: typeof globalThis.TypeError;
17
+ export declare const RangeError: typeof globalThis.RangeError;
18
+ export declare const ReferenceError: typeof globalThis.ReferenceError;
19
+ export declare const Array: typeof globalThis.Array;
20
+ export declare const Symbol: typeof globalThis.Symbol;
21
+ export declare const ArrayBuffer: typeof globalThis.ArrayBuffer;
22
+ export declare const ArrayBufferIsView: (arg: any) => arg is ArrayBufferView;
23
+ export declare const ArrayBufferPrototypeGetByteLength: (thisArg: ArrayBuffer) => number;
24
+ export declare const SharedArrayBuffer: typeof globalThis.SharedArrayBuffer;
25
+ export declare const SharedArrayBufferPrototypeGetByteLength: (thisArg: SharedArrayBuffer) => number;
26
+ export declare const Uint8Array: typeof globalThis.Uint8Array;
27
+ export declare const Uint8ArrayPrototypeSlice: Uncurry<typeof Uint8Array.prototype.slice, Uint8Array>;
28
+ export declare const Uint8ArrayPrototypeSubarray: Uncurry<typeof Uint8Array.prototype.subarray, Uint8Array>;
29
+ export declare const TypedArray: TypedArrayConstructor;
30
+ export declare const TypedArrayPrototype: InstanceType<TypedArrayConstructor>;
31
+ export declare const TypedArrayPrototypeGetToStringTag: any;
32
+ export declare const TypedArrayPrototypeSubarray: Uncurry<typeof TypedArrayPrototype.subarray, typeof TypedArrayPrototype>;
33
+ export declare const String: typeof globalThis.String;
34
+ export declare const StringFromCharCode: typeof String.fromCharCode;
35
+ export declare const StringPrototype: typeof String.prototype;
36
+ export declare const StringPrototypeCharCodeAt: Uncurry<typeof String.prototype.charCodeAt, string>;
37
+ export declare const StringPrototypeReplace: Uncurry<typeof String.prototype.replace, string>;
38
+ export declare const StringPrototypeSlice: Uncurry<typeof String.prototype.slice, string>;
39
+ export declare const StringPrototypeCodePointAt: Uncurry<typeof String.prototype.codePointAt, string>;
40
+ export declare const StringPrototypeToLowerCase: Uncurry<typeof String.prototype.toLowerCase, string>;
41
+ export declare const StringPrototypeTrim: Uncurry<typeof String.prototype.trim, string>;
42
+ export declare const Promise: typeof globalThis.Promise;
43
+ export declare const PromiseResolve: {
44
+ (): Promise<void>;
45
+ <T>(value: T): Promise<Awaited<T>>;
46
+ <T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
47
+ };
48
+ export declare const PromiseReject: <T = never>(reason?: any) => Promise<T>;
49
+ export declare const TransformStream: typeof globalThis.TransformStream;
50
+ export declare function getCodePoint(input: string, index: number): number;
51
+ export declare function utf8BytesNeeded(codePoint: number): number;
52
+ export declare function normalizeEncoding(label: string): string;
53
+ export declare function toUint8Array(input?: BufferSource | null): Uint8Array;
54
+ export {};
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.TransformStream = exports.PromiseReject = exports.PromiseResolve = exports.Promise = exports.StringPrototypeTrim = exports.StringPrototypeToLowerCase = exports.StringPrototypeCodePointAt = exports.StringPrototypeSlice = exports.StringPrototypeReplace = exports.StringPrototypeCharCodeAt = exports.StringPrototype = exports.StringFromCharCode = exports.String = exports.TypedArrayPrototypeSubarray = exports.TypedArrayPrototypeGetToStringTag = exports.TypedArrayPrototype = exports.TypedArray = exports.Uint8ArrayPrototypeSubarray = exports.Uint8ArrayPrototypeSlice = exports.Uint8Array = exports.SharedArrayBufferPrototypeGetByteLength = exports.SharedArrayBuffer = exports.ArrayBufferPrototypeGetByteLength = exports.ArrayBufferIsView = exports.ArrayBuffer = exports.Symbol = exports.Array = exports.ReferenceError = exports.RangeError = exports.TypeError = exports.Error = exports.toString = exports.ObjectGetOwnPropertyDescriptor = exports.ObjectDefineProperty = exports.ObjectGetPrototypeOf = exports.Object = exports.undefined = void 0;
27
+ exports.isTypedArray = isTypedArray;
28
+ exports.getCodePoint = getCodePoint;
29
+ exports.utf8BytesNeeded = utf8BytesNeeded;
30
+ exports.normalizeEncoding = normalizeEncoding;
31
+ exports.toUint8Array = toUint8Array;
32
+ // deno-lint-ignore no-var
33
+ const dntShim = __importStar(require("./_dnt.shims.js"));
34
+ const $global = (() => {
35
+ try {
36
+ if (typeof dntShim.dntGlobalThis === "object")
37
+ return dntShim.dntGlobalThis;
38
+ return (0, eval)("this");
39
+ }
40
+ catch {
41
+ if (typeof dntShim.dntGlobalThis === "object")
42
+ return dntShim.dntGlobalThis;
43
+ if (typeof self === "object")
44
+ return self;
45
+ if (typeof global === "object")
46
+ return global;
47
+ if (typeof root === "object")
48
+ return root;
49
+ if (typeof this === "object")
50
+ return this;
51
+ // ewww
52
+ throw "Unable to locate global `this`";
53
+ }
54
+ })();
55
+ function isTypedArray(it, type) {
56
+ try {
57
+ return (0, exports.TypedArrayPrototypeGetToStringTag)(it) === type;
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }
63
+ exports.Object = $global.Object;
64
+ exports.ObjectGetPrototypeOf = exports.Object.getPrototypeOf;
65
+ exports.ObjectDefineProperty = exports.Object.defineProperty;
66
+ exports.ObjectGetOwnPropertyDescriptor = exports.Object.getOwnPropertyDescriptor;
67
+ const Function = $global.Function;
68
+ const FunctionPrototype = Function.prototype;
69
+ const { bind, call } = FunctionPrototype;
70
+ const uncurryThis = (fn) => {
71
+ const bound = bind.call(call, fn);
72
+ (0, exports.ObjectDefineProperty)(bound, "name", { value: fn.name });
73
+ return bound;
74
+ };
75
+ const FunctionPrototypeBind = uncurryThis(bind);
76
+ function uncurryGetter(o, p) {
77
+ return uncurryThis(lookupGetter(o, p));
78
+ }
79
+ function lookupGetter(o, p, _allowUndefined) {
80
+ return (0, exports.ObjectGetOwnPropertyDescriptor)(o, p)?.get ?? (() => exports.undefined);
81
+ }
82
+ // deno-lint-ignore no-explicit-any
83
+ function bindAndRename(fn, thisArg, name = fn.name) {
84
+ const bound = FunctionPrototypeBind(fn, thisArg);
85
+ (0, exports.ObjectDefineProperty)(bound, "name", { value: name });
86
+ return bound;
87
+ }
88
+ exports.toString = uncurryThis(exports.Object.prototype.toString);
89
+ exports.Error = $global.Error;
90
+ exports.TypeError = $global.TypeError;
91
+ exports.RangeError = $global.RangeError;
92
+ exports.ReferenceError = $global.ReferenceError;
93
+ exports.Array = $global.Array;
94
+ exports.Symbol = $global.Symbol;
95
+ exports.ArrayBuffer = $global.ArrayBuffer;
96
+ exports.ArrayBufferIsView = exports.ArrayBuffer.isView;
97
+ exports.ArrayBufferPrototypeGetByteLength = uncurryGetter(exports.ArrayBuffer.prototype, "byteLength");
98
+ exports.SharedArrayBuffer = $global.SharedArrayBuffer;
99
+ exports.SharedArrayBufferPrototypeGetByteLength = uncurryGetter(exports.SharedArrayBuffer.prototype, "byteLength");
100
+ exports.Uint8Array = $global.Uint8Array;
101
+ exports.Uint8ArrayPrototypeSlice = uncurryThis(exports.Uint8Array.prototype.slice);
102
+ exports.Uint8ArrayPrototypeSubarray = uncurryThis(exports.Uint8Array.prototype.subarray);
103
+ exports.TypedArray = (0, exports.ObjectGetPrototypeOf)(exports.Uint8Array);
104
+ exports.TypedArrayPrototype = exports.TypedArray?.prototype;
105
+ exports.TypedArrayPrototypeGetToStringTag = uncurryGetter(exports.TypedArrayPrototype, exports.Symbol.toStringTag);
106
+ exports.TypedArrayPrototypeSubarray // deno-lint-ignore no-explicit-any
107
+ = uncurryThis(exports.TypedArrayPrototype.subarray);
108
+ exports.String = $global.String;
109
+ exports.StringFromCharCode = exports.String.fromCharCode;
110
+ exports.StringPrototype = exports.String.prototype;
111
+ exports.StringPrototypeCharCodeAt = uncurryThis(exports.StringPrototype.charCodeAt);
112
+ exports.StringPrototypeReplace = uncurryThis(exports.StringPrototype.replace);
113
+ exports.StringPrototypeSlice = uncurryThis(exports.StringPrototype.slice);
114
+ exports.StringPrototypeCodePointAt = uncurryThis(exports.StringPrototype.codePointAt);
115
+ exports.StringPrototypeToLowerCase = uncurryThis(exports.StringPrototype.toLowerCase);
116
+ exports.StringPrototypeTrim = uncurryThis(exports.StringPrototype.trim);
117
+ exports.Promise = $global.Promise;
118
+ exports.PromiseResolve = bindAndRename(exports.Promise.resolve, exports.Promise);
119
+ exports.PromiseReject = bindAndRename(exports.Promise.reject, exports.Promise);
120
+ exports.TransformStream = $global.TransformStream;
121
+ function getCodePoint(input, index) {
122
+ const first = (0, exports.StringPrototypeCharCodeAt)(input, index);
123
+ if (first >= 0xd800 && first <= 0xdbff) {
124
+ const second = (0, exports.StringPrototypeCharCodeAt)(input, index + 1);
125
+ if (second >= 0xdc00 && second <= 0xdfff) {
126
+ return ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
127
+ }
128
+ }
129
+ return first;
130
+ }
131
+ function utf8BytesNeeded(codePoint) {
132
+ if (codePoint <= 0x7f)
133
+ return 1;
134
+ if (codePoint <= 0x7ff)
135
+ return 2;
136
+ if (codePoint <= 0xffff)
137
+ return 3;
138
+ return 4;
139
+ }
140
+ function normalizeEncoding(label) {
141
+ let encoding = (0, exports.StringPrototypeToLowerCase)(label);
142
+ encoding = (0, exports.StringPrototypeTrim)(encoding);
143
+ if (encoding === "utf8" || encoding === "utf-8")
144
+ return "utf-8";
145
+ throw new exports.TypeError(`The encoding label provided ('${label}') is invalid.`);
146
+ }
147
+ function toUint8Array(input) {
148
+ if (input == null) {
149
+ return new exports.Uint8Array();
150
+ }
151
+ else if (isTypedArray(input, "Uint8Array")) {
152
+ return input;
153
+ }
154
+ else if ((0, exports.ArrayBufferIsView)(input)) {
155
+ return new exports.Uint8Array(input.buffer, input.byteOffset, input.byteLength);
156
+ }
157
+ else {
158
+ try {
159
+ (0, exports.SharedArrayBufferPrototypeGetByteLength)(input);
160
+ return new exports.Uint8Array(input);
161
+ }
162
+ catch (_) {
163
+ try {
164
+ (0, exports.ArrayBufferPrototypeGetByteLength)(input);
165
+ return new exports.Uint8Array(input);
166
+ }
167
+ catch (_) {
168
+ throw new exports.TypeError('The "input" argument must be of type BufferSource');
169
+ }
170
+ }
171
+ }
172
+ }
173
+ //# sourceMappingURL=_internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_internal.js","sourceRoot":"","sources":["../src/_internal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,oCAWC;AAuID,oCASC;AAED,0CAKC;AAED,8CAKC;AAED,oCAsBC;AA5QD,0BAA0B;AAC1B,yDAA2C;AAO3C,MAAM,OAAO,GAAiC,CAAC,GAAG,EAAE;IAClD,IAAI,CAAC;QACH,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,aAAa,CAAC;QAC5E,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,aAAa,CAAC;QAC5E,IAAI,OAAO,IAAI,KAAK,QAAQ;YAA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CAAC,KAA2B;IACtD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,kBAAU,EAAE,CAAC;IAC1B,CAAC;SAAM,IAAI,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;SAAM,IAAI,IAAA,yBAAiB,EAAC,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,kBAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,IAAI,CAAC;YACH,IAAA,+CAAuC,EAAC,KAA0B,CAAC,CAAC;YACpE,OAAO,IAAI,kBAAU,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC;gBACH,IAAA,yCAAiC,EAAC,KAAK,CAAC,CAAC;gBACzC,OAAO,IAAI,kBAAU,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,iBAAS,CACjB,mDAAmD,CACpD,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
package/cjs/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * # `@nick/utf8`
3
+ *
4
+ * This package provides blazing-fast, zero-dependency ponyfills for the native
5
+ * `TextEncoder` and `TextDecoder` APIs, as well as the streaming counterparts,
6
+ * `TextEncoderStream` and `TextDecoderStream`.
7
+ *
8
+ * The ponyfills are based on the WHATWG Encoding standard, and are designed to
9
+ * work in any ES2015+ environment, including Deno, Node, Bun, and the browser.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { TextEncoder, TextDecoder } from "@nick/utf8";
14
+ *
15
+ * const encoder = new TextEncoder();
16
+ * const decoder = new TextDecoder();
17
+ *
18
+ * const buffer = encoder.encode("Hello, world!");
19
+ * const text = decoder.decode(buffer);
20
+ *
21
+ * console.log(text); // Outputs: "Hello, world!"
22
+ * ```
23
+ * @module utf8
24
+ */
25
+ export * from "./text_encoder.js";
26
+ export * from "./text_decoder.js";
27
+ export * from "./text_encoder_stream.js";
28
+ export * from "./text_decoder_stream.js";