@qp-mongosh/service-provider-core 0.0.0-dev.3 → 0.0.0-dev.8

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 (71) hide show
  1. package/.eslintignore +2 -2
  2. package/.eslintrc.js +1 -1
  3. package/AUTHORS +11 -11
  4. package/LICENSE +200 -200
  5. package/package.json +54 -54
  6. package/src/admin.ts +119 -119
  7. package/src/all-fle-types.ts +17 -17
  8. package/src/all-transport-types.ts +80 -80
  9. package/src/cli-options.ts +49 -49
  10. package/src/closable.ts +14 -14
  11. package/src/connect-info.spec.ts +192 -192
  12. package/src/connect-info.ts +57 -57
  13. package/src/index.ts +62 -62
  14. package/src/platform.ts +6 -6
  15. package/src/printable-bson.spec.ts +75 -75
  16. package/src/printable-bson.ts +103 -103
  17. package/src/readable.ts +242 -242
  18. package/src/service-provider.ts +23 -23
  19. package/src/shell-auth-options.ts +7 -7
  20. package/src/textencoder-polyfill.spec.ts +11 -11
  21. package/src/textencoder-polyfill.ts +30 -30
  22. package/src/uri-generator.spec.ts +481 -481
  23. package/src/uri-generator.ts +265 -265
  24. package/src/writable.ts +367 -367
  25. package/tsconfig.json +12 -12
  26. package/tsconfig.lint.json +8 -8
  27. package/lib/admin.d.ts +0 -28
  28. package/lib/admin.js +0 -3
  29. package/lib/admin.js.map +0 -1
  30. package/lib/all-fle-types.d.ts +0 -2
  31. package/lib/all-fle-types.js +0 -3
  32. package/lib/all-fle-types.js.map +0 -1
  33. package/lib/all-transport-types.d.ts +0 -1
  34. package/lib/all-transport-types.js +0 -3
  35. package/lib/all-transport-types.js.map +0 -1
  36. package/lib/cli-options.d.ts +0 -43
  37. package/lib/cli-options.js +0 -3
  38. package/lib/cli-options.js.map +0 -1
  39. package/lib/closable.d.ts +0 -4
  40. package/lib/closable.js +0 -3
  41. package/lib/closable.js.map +0 -1
  42. package/lib/connect-info.d.ts +0 -19
  43. package/lib/connect-info.js +0 -35
  44. package/lib/connect-info.js.map +0 -1
  45. package/lib/index.d.ts +0 -31
  46. package/lib/index.js +0 -56
  47. package/lib/index.js.map +0 -1
  48. package/lib/platform.d.ts +0 -6
  49. package/lib/platform.js +0 -11
  50. package/lib/platform.js.map +0 -1
  51. package/lib/printable-bson.d.ts +0 -3
  52. package/lib/printable-bson.js +0 -82
  53. package/lib/printable-bson.js.map +0 -1
  54. package/lib/readable.d.ts +0 -18
  55. package/lib/readable.js +0 -3
  56. package/lib/readable.js.map +0 -1
  57. package/lib/service-provider.d.ts +0 -11
  58. package/lib/service-provider.js +0 -19
  59. package/lib/service-provider.js.map +0 -1
  60. package/lib/shell-auth-options.d.ts +0 -7
  61. package/lib/shell-auth-options.js +0 -3
  62. package/lib/shell-auth-options.js.map +0 -1
  63. package/lib/textencoder-polyfill.d.ts +0 -2
  64. package/lib/textencoder-polyfill.js +0 -22
  65. package/lib/textencoder-polyfill.js.map +0 -1
  66. package/lib/uri-generator.d.ts +0 -8
  67. package/lib/uri-generator.js +0 -176
  68. package/lib/uri-generator.js.map +0 -1
  69. package/lib/writable.d.ts +0 -22
  70. package/lib/writable.js +0 -3
  71. package/lib/writable.js.map +0 -1
package/src/readable.ts CHANGED
@@ -1,242 +1,242 @@
1
- import type {
2
- Document,
3
- AggregateOptions,
4
- CountOptions,
5
- CountDocumentsOptions,
6
- DistinctOptions,
7
- EstimatedDocumentCountOptions,
8
- FindOptions,
9
- ListCollectionsOptions,
10
- CollStatsOptions,
11
- ListIndexesOptions,
12
- AggregationCursor,
13
- FindCursor,
14
- DbOptions,
15
- ReadPreferenceFromOptions,
16
- ReadPreferenceLike
17
- } from './all-transport-types';
18
- import { ChangeStream, ChangeStreamOptions } from './all-transport-types';
19
-
20
- /**
21
- * Interface for read operations in the CRUD specification.
22
- */
23
- export default interface Readable {
24
- /**
25
- * Run an aggregation pipeline.
26
- *
27
- *
28
- * @param {String} database - The database name.
29
- * @param {String} collection - The collection name.
30
- * @param {Array} pipeline - The aggregation pipeline.
31
- * @param {Document} options - The pipeline options.
32
- * @param {DbOptions} dbOptions - The database options
33
- * @returns {Cursor} A cursor.
34
- */
35
- aggregate(
36
- database: string,
37
- collection: string,
38
- pipeline: Document[],
39
- options?: AggregateOptions,
40
- dbOptions?: DbOptions): AggregationCursor;
41
-
42
- /**
43
- * Run an aggregation pipeline on the DB.
44
- *
45
- * @param {String} database - The database name.
46
- * @param {Array} pipeline - The aggregation pipeline.
47
- * @param {Document} options - The pipeline options.
48
- * @param {Object} dbOptions - Optional options.
49
- *
50
- * @returns {Cursor} A cursor.
51
- */
52
- aggregateDb(
53
- database: string,
54
- pipeline: Document[],
55
- options?: AggregateOptions,
56
- dbOptions?: DbOptions
57
- ): AggregationCursor;
58
-
59
- /**
60
- * Returns the count of documents that would match a find() query for the
61
- * collection or view. The db.collection.count() method does not perform the
62
- * find() operation but instead counts and returns the number of results
63
- * that match a query.
64
- *
65
- * @param {String} db - the db name
66
- * @param {String} coll - the collection name
67
- * @param query
68
- * @param options
69
- * @param {DbOptions} dbOptions - The database options
70
- *
71
- * @returns {Promise} A promise of the result.
72
- */
73
- count(
74
- db: string,
75
- coll: string,
76
- query?: Document,
77
- options?: CountOptions,
78
- dbOptions?: DbOptions): Promise<number>;
79
-
80
- /**
81
- * Get an exact document count from the collection.
82
- *
83
- * @param {String} database - The database name.
84
- * @param {String} collection - The collection name.
85
- * @param {Document} filter - The filter.
86
- * @param {Document} options - The count options.
87
- * @param {DbOptions} dbOptions - The database options
88
- *
89
- * @returns {Promise} A promise of the result.
90
- */
91
- countDocuments(
92
- database: string,
93
- collection: string,
94
- filter?: Document,
95
- options?: CountDocumentsOptions,
96
- dbOptions?: DbOptions): Promise<number>;
97
-
98
- /**
99
- * Get distinct values for the field.
100
- *
101
- * @param {String} database - The database name.
102
- * @param {String} collection - The collection name.
103
- * @param {String} fieldName - The field name.
104
- * @param {Document} filter - The filter.
105
- * @param {Document} options - The distinct options.
106
- * @param {DbOptions} dbOptions - The database options
107
- *
108
- * @returns {Document}.
109
- */
110
- distinct(
111
- database: string,
112
- collection: string,
113
- fieldName: string,
114
- filter?: Document,
115
- options?: DistinctOptions,
116
- dbOptions?: DbOptions): Promise<Document>;
117
-
118
- /**
119
- * Get an estimated document count from the collection.
120
- *
121
- * @param {String} database - The database name.
122
- * @param {String} collection - The collection name.
123
- * @param {Document} options - The count options.
124
- * @param {DbOptions} dbOptions - The database options
125
- *
126
- * @returns {Promise} The promise of the result.
127
- */
128
- estimatedDocumentCount(
129
- database: string,
130
- collection: string,
131
- options?: EstimatedDocumentCountOptions,
132
- dbOptions?: DbOptions): Promise<number>;
133
-
134
- /**
135
- * Find documents in the collection.
136
- *
137
- * @param {String} database - The database name.
138
- * @param {String} collection - The collection name.
139
- * @param {Document} filter - The filter.
140
- * @param {Document} options - The find options.
141
- * @param {DbOptions} dbOptions - The database options
142
- *
143
- * @returns {Promise} The promise of the cursor.
144
- */
145
- find(
146
- database: string,
147
- collection: string,
148
- filter?: Document,
149
- options?: FindOptions,
150
- dbOptions?: DbOptions): FindCursor;
151
-
152
- /**
153
- * Get currently known topology information.
154
- */
155
- getTopology(): any;
156
-
157
- /**
158
- * Is the collection capped?
159
- *
160
- * @param {String} database - The database name.
161
- * @param {String} collection - The collection name.
162
- * @param {DbOptions} dbOptions - The database options
163
- *
164
- * @returns {Promise} The promise of the result.
165
- */
166
- isCapped(
167
- database: string,
168
- collection: string,
169
- dbOptions?: DbOptions): Promise<boolean>;
170
-
171
- /**
172
- * Returns an array that holds a list of documents that identify and
173
- * describe the existing indexes on the collection.
174
- *
175
- * @param {String} database - The db name.
176
- * @param {String} collection - The collection name.
177
- * @param options
178
- * @param {DbOptions} dbOptions - The database options
179
- *
180
- * @return {Promise}
181
- */
182
- getIndexes(
183
- database: string,
184
- collection: string,
185
- options: ListIndexesOptions,
186
- dbOptions?: DbOptions): Promise<Document[]>;
187
-
188
- /**
189
- * Returns an array of collection infos
190
- *
191
- * @param {String} database - The db name.
192
- * @param {Document} filter - The filter.
193
- * @param {Document} options - The command options.
194
- * @param {DbOptions} dbOptions - The database options
195
- *
196
- * @return {Promise}
197
- */
198
- listCollections(
199
- database: string,
200
- filter?: Document,
201
- options?: ListCollectionsOptions,
202
- dbOptions?: DbOptions): Promise<Document[]>;
203
-
204
- /**
205
- * Create a ReadPreference object from a set of options
206
- */
207
- readPreferenceFromOptions(options?: Omit<ReadPreferenceFromOptions, 'session'>): ReadPreferenceLike | undefined;
208
-
209
- /**
210
- * Get all the collection statistics.
211
- *
212
- * @param {String} database - The db name.
213
- * @param {String} collection - The collection name.
214
- * @param {Object} options - The count options.
215
- * @param {DbOptions} dbOptions - The database options
216
- *
217
- * @return {Promise} returns Promise
218
- */
219
- stats(
220
- database: string,
221
- collection: string,
222
- options?: CollStatsOptions,
223
- dbOptions?: DbOptions
224
- ): Promise<Document>;
225
-
226
- /**
227
- * Start a change stream cursor on either the client, db, or collection.
228
- * @param pipeline
229
- * @param options
230
- * @param db
231
- * @param dbOptions
232
- * @param coll
233
- */
234
- watch(
235
- pipeline: Document[],
236
- options: ChangeStreamOptions,
237
- dbOptions?: DbOptions,
238
- db?: string,
239
- coll?: string
240
- ): ChangeStream<Document>;
241
- }
242
-
1
+ import type {
2
+ Document,
3
+ AggregateOptions,
4
+ CountOptions,
5
+ CountDocumentsOptions,
6
+ DistinctOptions,
7
+ EstimatedDocumentCountOptions,
8
+ FindOptions,
9
+ ListCollectionsOptions,
10
+ CollStatsOptions,
11
+ ListIndexesOptions,
12
+ AggregationCursor,
13
+ FindCursor,
14
+ DbOptions,
15
+ ReadPreferenceFromOptions,
16
+ ReadPreferenceLike
17
+ } from './all-transport-types';
18
+ import { ChangeStream, ChangeStreamOptions } from './all-transport-types';
19
+
20
+ /**
21
+ * Interface for read operations in the CRUD specification.
22
+ */
23
+ export default interface Readable {
24
+ /**
25
+ * Run an aggregation pipeline.
26
+ *
27
+ *
28
+ * @param {String} database - The database name.
29
+ * @param {String} collection - The collection name.
30
+ * @param {Array} pipeline - The aggregation pipeline.
31
+ * @param {Document} options - The pipeline options.
32
+ * @param {DbOptions} dbOptions - The database options
33
+ * @returns {Cursor} A cursor.
34
+ */
35
+ aggregate(
36
+ database: string,
37
+ collection: string,
38
+ pipeline: Document[],
39
+ options?: AggregateOptions,
40
+ dbOptions?: DbOptions): AggregationCursor;
41
+
42
+ /**
43
+ * Run an aggregation pipeline on the DB.
44
+ *
45
+ * @param {String} database - The database name.
46
+ * @param {Array} pipeline - The aggregation pipeline.
47
+ * @param {Document} options - The pipeline options.
48
+ * @param {Object} dbOptions - Optional options.
49
+ *
50
+ * @returns {Cursor} A cursor.
51
+ */
52
+ aggregateDb(
53
+ database: string,
54
+ pipeline: Document[],
55
+ options?: AggregateOptions,
56
+ dbOptions?: DbOptions
57
+ ): AggregationCursor;
58
+
59
+ /**
60
+ * Returns the count of documents that would match a find() query for the
61
+ * collection or view. The db.collection.count() method does not perform the
62
+ * find() operation but instead counts and returns the number of results
63
+ * that match a query.
64
+ *
65
+ * @param {String} db - the db name
66
+ * @param {String} coll - the collection name
67
+ * @param query
68
+ * @param options
69
+ * @param {DbOptions} dbOptions - The database options
70
+ *
71
+ * @returns {Promise} A promise of the result.
72
+ */
73
+ count(
74
+ db: string,
75
+ coll: string,
76
+ query?: Document,
77
+ options?: CountOptions,
78
+ dbOptions?: DbOptions): Promise<number>;
79
+
80
+ /**
81
+ * Get an exact document count from the collection.
82
+ *
83
+ * @param {String} database - The database name.
84
+ * @param {String} collection - The collection name.
85
+ * @param {Document} filter - The filter.
86
+ * @param {Document} options - The count options.
87
+ * @param {DbOptions} dbOptions - The database options
88
+ *
89
+ * @returns {Promise} A promise of the result.
90
+ */
91
+ countDocuments(
92
+ database: string,
93
+ collection: string,
94
+ filter?: Document,
95
+ options?: CountDocumentsOptions,
96
+ dbOptions?: DbOptions): Promise<number>;
97
+
98
+ /**
99
+ * Get distinct values for the field.
100
+ *
101
+ * @param {String} database - The database name.
102
+ * @param {String} collection - The collection name.
103
+ * @param {String} fieldName - The field name.
104
+ * @param {Document} filter - The filter.
105
+ * @param {Document} options - The distinct options.
106
+ * @param {DbOptions} dbOptions - The database options
107
+ *
108
+ * @returns {Document}.
109
+ */
110
+ distinct(
111
+ database: string,
112
+ collection: string,
113
+ fieldName: string,
114
+ filter?: Document,
115
+ options?: DistinctOptions,
116
+ dbOptions?: DbOptions): Promise<Document>;
117
+
118
+ /**
119
+ * Get an estimated document count from the collection.
120
+ *
121
+ * @param {String} database - The database name.
122
+ * @param {String} collection - The collection name.
123
+ * @param {Document} options - The count options.
124
+ * @param {DbOptions} dbOptions - The database options
125
+ *
126
+ * @returns {Promise} The promise of the result.
127
+ */
128
+ estimatedDocumentCount(
129
+ database: string,
130
+ collection: string,
131
+ options?: EstimatedDocumentCountOptions,
132
+ dbOptions?: DbOptions): Promise<number>;
133
+
134
+ /**
135
+ * Find documents in the collection.
136
+ *
137
+ * @param {String} database - The database name.
138
+ * @param {String} collection - The collection name.
139
+ * @param {Document} filter - The filter.
140
+ * @param {Document} options - The find options.
141
+ * @param {DbOptions} dbOptions - The database options
142
+ *
143
+ * @returns {Promise} The promise of the cursor.
144
+ */
145
+ find(
146
+ database: string,
147
+ collection: string,
148
+ filter?: Document,
149
+ options?: FindOptions,
150
+ dbOptions?: DbOptions): FindCursor;
151
+
152
+ /**
153
+ * Get currently known topology information.
154
+ */
155
+ getTopology(): any;
156
+
157
+ /**
158
+ * Is the collection capped?
159
+ *
160
+ * @param {String} database - The database name.
161
+ * @param {String} collection - The collection name.
162
+ * @param {DbOptions} dbOptions - The database options
163
+ *
164
+ * @returns {Promise} The promise of the result.
165
+ */
166
+ isCapped(
167
+ database: string,
168
+ collection: string,
169
+ dbOptions?: DbOptions): Promise<boolean>;
170
+
171
+ /**
172
+ * Returns an array that holds a list of documents that identify and
173
+ * describe the existing indexes on the collection.
174
+ *
175
+ * @param {String} database - The db name.
176
+ * @param {String} collection - The collection name.
177
+ * @param options
178
+ * @param {DbOptions} dbOptions - The database options
179
+ *
180
+ * @return {Promise}
181
+ */
182
+ getIndexes(
183
+ database: string,
184
+ collection: string,
185
+ options: ListIndexesOptions,
186
+ dbOptions?: DbOptions): Promise<Document[]>;
187
+
188
+ /**
189
+ * Returns an array of collection infos
190
+ *
191
+ * @param {String} database - The db name.
192
+ * @param {Document} filter - The filter.
193
+ * @param {Document} options - The command options.
194
+ * @param {DbOptions} dbOptions - The database options
195
+ *
196
+ * @return {Promise}
197
+ */
198
+ listCollections(
199
+ database: string,
200
+ filter?: Document,
201
+ options?: ListCollectionsOptions,
202
+ dbOptions?: DbOptions): Promise<Document[]>;
203
+
204
+ /**
205
+ * Create a ReadPreference object from a set of options
206
+ */
207
+ readPreferenceFromOptions(options?: Omit<ReadPreferenceFromOptions, 'session'>): ReadPreferenceLike | undefined;
208
+
209
+ /**
210
+ * Get all the collection statistics.
211
+ *
212
+ * @param {String} database - The db name.
213
+ * @param {String} collection - The collection name.
214
+ * @param {Object} options - The count options.
215
+ * @param {DbOptions} dbOptions - The database options
216
+ *
217
+ * @return {Promise} returns Promise
218
+ */
219
+ stats(
220
+ database: string,
221
+ collection: string,
222
+ options?: CollStatsOptions,
223
+ dbOptions?: DbOptions
224
+ ): Promise<Document>;
225
+
226
+ /**
227
+ * Start a change stream cursor on either the client, db, or collection.
228
+ * @param pipeline
229
+ * @param options
230
+ * @param db
231
+ * @param dbOptions
232
+ * @param coll
233
+ */
234
+ watch(
235
+ pipeline: Document[],
236
+ options: ChangeStreamOptions,
237
+ dbOptions?: DbOptions,
238
+ db?: string,
239
+ coll?: string
240
+ ): ChangeStream<Document>;
241
+ }
242
+
@@ -1,23 +1,23 @@
1
- import { MongoshInternalError } from '@qp-mongosh/errors';
2
- import Admin from './admin';
3
- import Closable from './closable';
4
- import makePrintableBson from './printable-bson';
5
- import Readable from './readable';
6
- import Writable from './writable';
7
- import type { bson as BSON } from './index';
8
-
9
- /**
10
- * Interface for all service providers.
11
- */
12
- export default interface ServiceProvider extends Readable, Writable, Closable, Admin {}
13
-
14
- export class ServiceProviderCore {
15
- public bsonLibrary: typeof BSON;
16
- constructor(bsonLibrary?: typeof BSON) {
17
- if (bsonLibrary === undefined) {
18
- throw new MongoshInternalError('BSON Library is undefined.');
19
- }
20
- makePrintableBson(bsonLibrary);
21
- this.bsonLibrary = bsonLibrary;
22
- }
23
- }
1
+ import { MongoshInternalError } from '@qp-mongosh/errors';
2
+ import Admin from './admin';
3
+ import Closable from './closable';
4
+ import makePrintableBson from './printable-bson';
5
+ import Readable from './readable';
6
+ import Writable from './writable';
7
+ import type { bson as BSON } from './index';
8
+
9
+ /**
10
+ * Interface for all service providers.
11
+ */
12
+ export default interface ServiceProvider extends Readable, Writable, Closable, Admin {}
13
+
14
+ export class ServiceProviderCore {
15
+ public bsonLibrary: typeof BSON;
16
+ constructor(bsonLibrary?: typeof BSON) {
17
+ if (bsonLibrary === undefined) {
18
+ throw new MongoshInternalError('BSON Library is undefined.');
19
+ }
20
+ makePrintableBson(bsonLibrary);
21
+ this.bsonLibrary = bsonLibrary;
22
+ }
23
+ }
@@ -1,7 +1,7 @@
1
- export default interface ShellAuthOptions {
2
- user: string;
3
- pwd: string;
4
- mechanism?: string;
5
- digestPassword?: boolean;
6
- authDb?: string;
7
- }
1
+ export default interface ShellAuthOptions {
2
+ user: string;
3
+ pwd: string;
4
+ mechanism?: string;
5
+ digestPassword?: boolean;
6
+ authDb?: string;
7
+ }
@@ -1,11 +1,11 @@
1
- import { textEncodingPolyfill } from './textencoder-polyfill';
2
- import { expect } from 'chai';
3
-
4
- describe('TextDecoder/TextEncoder polyfill', () => {
5
- it('does simplistic UTF-8 encoding/decoding', () => {
6
- const { TextEncoder, TextDecoder } = textEncodingPolyfill();
7
- // This test was written in winter.
8
- const str = '☃️';
9
- expect(new TextDecoder().decode(new TextEncoder().encode(str))).to.equal(str);
10
- });
11
- });
1
+ import { textEncodingPolyfill } from './textencoder-polyfill';
2
+ import { expect } from 'chai';
3
+
4
+ describe('TextDecoder/TextEncoder polyfill', () => {
5
+ it('does simplistic UTF-8 encoding/decoding', () => {
6
+ const { TextEncoder, TextDecoder } = textEncodingPolyfill();
7
+ // This test was written in winter.
8
+ const str = '☃️';
9
+ expect(new TextDecoder().decode(new TextEncoder().encode(str))).to.equal(str);
10
+ });
11
+ });
@@ -1,30 +1,30 @@
1
- // The java-shell doesn't have URL, so we fall back to a pure-JS implementation.
2
- // And, because it's so much fun, it also doesn't have TextEncoder/TextDecoder,
3
- // so we need to (crudely) polyfill that as well in order to use that
4
- // pure-JS implementation.
5
- if (
6
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
- // @ts-ignore
8
- typeof TextDecoder !== 'function' || typeof TextEncoder !== 'function'
9
- ) {
10
- // eslint-disable-next-line no-new-func
11
- Object.assign(Function('return this')(), textEncodingPolyfill());
12
- }
13
-
14
- // Basic encoder/decoder polyfill for java-shell environment (see above)
15
- function textEncodingPolyfill(): any {
16
- class TextEncoder {
17
- encode(string: string): Uint8Array {
18
- return Buffer.from(string, 'utf8');
19
- }
20
- }
21
- class TextDecoder {
22
- decode(bytes: Uint8Array): string {
23
- const str = Buffer.from(bytes).toString('utf8');
24
- return str.slice(+str.startsWith('\ufeff'));
25
- }
26
- }
27
- return { TextDecoder, TextEncoder };
28
- }
29
-
30
- export { textEncodingPolyfill };
1
+ // The java-shell doesn't have URL, so we fall back to a pure-JS implementation.
2
+ // And, because it's so much fun, it also doesn't have TextEncoder/TextDecoder,
3
+ // so we need to (crudely) polyfill that as well in order to use that
4
+ // pure-JS implementation.
5
+ if (
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ // @ts-ignore
8
+ typeof TextDecoder !== 'function' || typeof TextEncoder !== 'function'
9
+ ) {
10
+ // eslint-disable-next-line no-new-func
11
+ Object.assign(Function('return this')(), textEncodingPolyfill());
12
+ }
13
+
14
+ // Basic encoder/decoder polyfill for java-shell environment (see above)
15
+ function textEncodingPolyfill(): any {
16
+ class TextEncoder {
17
+ encode(string: string): Uint8Array {
18
+ return Buffer.from(string, 'utf8');
19
+ }
20
+ }
21
+ class TextDecoder {
22
+ decode(bytes: Uint8Array): string {
23
+ const str = Buffer.from(bytes).toString('utf8');
24
+ return str.slice(+str.startsWith('\ufeff'));
25
+ }
26
+ }
27
+ return { TextDecoder, TextEncoder };
28
+ }
29
+
30
+ export { textEncodingPolyfill };