ctx-core 5.18.9 → 5.19.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.
@@ -0,0 +1,11 @@
1
+ /// <reference lib="dom" />
2
+ import { Encoding } from 'node:crypto'
3
+ export class TextDecoderStream extends TransformStream<Uint8Array, string> {
4
+ readonly encoding:string
5
+ readonly fatal:boolean
6
+ readonly ignoreBOM:boolean
7
+ constructor(
8
+ encoding?:Encoding,
9
+ params?:ConstructorParameters<typeof TextDecoder>[1]
10
+ )
11
+ }
@@ -0,0 +1,49 @@
1
+ // Copyright 2016 Google Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ // Polyfill for TextEncoderStream and TextDecoderStream
15
+ // Modified by Sukka (https://skk.moe) to increase compatibility and performance with Bun.
16
+ // TODO: Remove when https://github.com/oven-sh/bun/issues/5648 is implemented
17
+ export class TextDecoderStream extends TransformStream {
18
+ constructor(
19
+ encoding = 'utf-8',
20
+ {
21
+ fatal = false,
22
+ ignoreBOM = false,
23
+ } = {},
24
+ ) {
25
+ const decoder = new TextDecoder(encoding, { fatal, ignoreBOM })
26
+ super({
27
+ transform(chunk, controller) {
28
+ const decoded = decoder.decode(chunk)
29
+ if (decoded.length > 0) {
30
+ controller.enqueue(decoded)
31
+ }
32
+ },
33
+ flush(controller) {
34
+ // If {fatal: false} is in options (the default), then the final call to
35
+ // decode() can produce extra output (usually the unicode replacement
36
+ // character 0xFFFD). When fatal is true, this call is just used for its
37
+ // side-effect of throwing a TypeError exception if the input is
38
+ // incomplete.
39
+ const output = decoder.decode()
40
+ if (output.length > 0) {
41
+ controller.enqueue(output)
42
+ }
43
+ }
44
+ })
45
+ this.encoding = encoding
46
+ this.fatal = fatal
47
+ this.ignoreBOM = ignoreBOM
48
+ }
49
+ }
@@ -0,0 +1,24 @@
1
+ /// <reference lib="dom" />
2
+ import { test } from 'uvu'
3
+ import { equal } from 'uvu/assert'
4
+ import { TextDecoderStream } from './index.js'
5
+ test('TestDecoderStream', async ()=>{
6
+ const encoder = new TextEncoder()
7
+ const encoded = encoder.encode('foo\nbar\nbaz')
8
+ let decoded = ''
9
+ const stream = new ReadableStream({
10
+ start(controller) {
11
+ controller.enqueue(encoded)
12
+ controller.close()
13
+ }
14
+ })
15
+ .pipeThrough(new TextDecoderStream())
16
+ .pipeTo(new WritableStream({
17
+ write(chunk) {
18
+ decoded += chunk
19
+ },
20
+ }))
21
+ await stream
22
+ equal(decoded, 'foo\nbar\nbaz')
23
+ })
24
+ test.run()
@@ -0,0 +1,4 @@
1
+ /// <reference lib="dom" />
2
+ export class TextEncoderStream extends TransformStream<string, Uint8Array>{
3
+ constructor()
4
+ }
@@ -0,0 +1,39 @@
1
+ // Copyright 2016 Google Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ // Polyfill for TextEncoderStream and TextDecoderStream
15
+ // TODO: Remove when https://github.com/oven-sh/bun/issues/5648 is implemented
16
+ export class TextEncoderStream extends TransformStream {
17
+ constructor() {
18
+ const decoder = new TextEncoder()
19
+ super({
20
+ transform(chunk, controller) {
21
+ const encoded = decoder.encode(chunk)
22
+ if (encoded.length > 0) {
23
+ controller.enqueue(encoded)
24
+ }
25
+ },
26
+ flush(controller) {
27
+ // If {fatal: false} is in options (the default), then the final call to
28
+ // decode() can produce extra output (usually the unicode replacement
29
+ // character 0xFFFD). When fatal is true, this call is just used for its
30
+ // side-effect of throwing a TypeError exception if the input is
31
+ // incomplete.
32
+ const output = decoder.encode()
33
+ if (output.length > 0) {
34
+ controller.enqueue(output)
35
+ }
36
+ }
37
+ })
38
+ }
39
+ }
@@ -0,0 +1,24 @@
1
+ /// <reference lib="dom" />
2
+ import { test } from 'uvu'
3
+ import { equal } from 'uvu/assert'
4
+ import { TextEncoderStream } from './index.js'
5
+ test('TestEncoderStream', async ()=>{
6
+ const decoded = 'foo\nbar\nbaz'
7
+ let uint8:Uint8Array|undefined = undefined
8
+ const stream = new ReadableStream({
9
+ start(controller) {
10
+ controller.enqueue(decoded)
11
+ controller.close()
12
+ }
13
+ })
14
+ .pipeThrough(new TextEncoderStream())
15
+ .pipeTo(new WritableStream({
16
+ write(chunk) {
17
+ uint8 = chunk
18
+ },
19
+ }))
20
+ await stream
21
+ const decoder = new TextDecoder()
22
+ equal(decoder.decode(uint8), 'foo\nbar\nbaz')
23
+ })
24
+ test.run()
package/all/index.d.ts CHANGED
@@ -14,6 +14,8 @@ export * from './NumericUnit/index.js'
14
14
  export * from './PHI/index.js'
15
15
  export * from './Request/index.js'
16
16
  export * from './Response/index.js'
17
+ export * from './TextDecoderStream/index.js'
18
+ export * from './TextEncoderStream/index.js'
17
19
  export * from './VERSION/index.js'
18
20
  export * from './a/index.js'
19
21
  export * from './a_assign/index.js'
package/all/index.js CHANGED
@@ -14,6 +14,8 @@ export * from './NumericUnit/index.js'
14
14
  export * from './PHI/index.js'
15
15
  export * from './Request/index.js'
16
16
  export * from './Response/index.js'
17
+ export * from './TextDecoderStream/index.js'
18
+ export * from './TextEncoderStream/index.js'
17
19
  export * from './VERSION/index.js'
18
20
  export * from './a/index.js'
19
21
  export * from './a_assign/index.js'
package/package.json CHANGED
@@ -1,250 +1,251 @@
1
1
  {
2
- "name": "ctx-core",
3
- "version": "5.18.9",
4
- "description": "ctx-core core library",
5
- "keywords": [
6
- "ctx-core",
7
- "array",
8
- "combinators",
9
- "function",
10
- "object",
11
- "set"
12
- ],
13
- "homepage": "https://github.com/ctx-core/ctx-core#readme",
14
- "bugs": {
15
- "url": "https://github.com/ctx-core/ctx-core/issues"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/ctx-core/ctx-core.git"
20
- },
21
- "license": "Apache-2.0",
22
- "author": "Brian Takita",
23
- "type": "module",
24
- "files": [
25
- "*.d.ts",
26
- "*.js",
27
- "*.json",
28
- "all",
29
- "array",
30
- "atob",
31
- "base16",
32
- "be",
33
- "btoa",
34
- "buffer",
35
- "chain",
36
- "class",
37
- "cli-args",
38
- "color",
39
- "combinators",
40
- "crypto",
41
- "currency",
42
- "data",
43
- "date",
44
- "debounce",
45
- "deep_equal",
46
- "env",
47
- "error",
48
- "falsy",
49
- "fetch",
50
- "fibonacci",
51
- "fs",
52
- "function",
53
- "functional",
54
- "html",
55
- "http",
56
- "math",
57
- "matrix",
58
- "nullish",
59
- "number",
60
- "object",
61
- "promise",
62
- "queue",
63
- "random",
64
- "regex",
65
- "rmemo",
66
- "run",
67
- "set",
68
- "sleep",
69
- "string",
70
- "tempfile",
71
- "test",
72
- "time",
73
- "tuple",
74
- "types",
75
- "uri",
76
- "uuid",
77
- "package.json"
78
- ],
79
- "exports": {
80
- ".": "./index.js",
81
- "./all": "./all/index.js",
82
- "./array": "./array/index.js",
83
- "./atob": "./atob/index.js",
84
- "./base16": "./base16/index.js",
85
- "./be": "./be/index.js",
86
- "./btoa": "./btoa/index.js",
87
- "./buffer": "./buffer/index.js",
88
- "./chain": "./chain/index.js",
89
- "./class": "./class/index.js",
90
- "./cli-args": "./cli-args/index.js",
91
- "./color": "./color/index.js",
92
- "./combinators": "./combinators/index.js",
93
- "./crypto": "./crypto/index.js",
94
- "./currency": "./currency/index.js",
95
- "./data": "./data/index.js",
96
- "./date": "./date/index.js",
97
- "./debounce": "./debounce/index.js",
98
- "./deep_equal": "./deep_equal/index.js",
99
- "./env": "./env/index.js",
100
- "./error": "./error/index.js",
101
- "./falsy": "./falsy/index.js",
102
- "./fetch": "./fetch/index.js",
103
- "./fibonacci": "./fibonacci/index.js",
104
- "./fs": "./fs/index.js",
105
- "./function": "./function/index.js",
106
- "./functional": "./functional/index.js",
107
- "./html": "./html/index.js",
108
- "./http": "./http/index.js",
109
- "./math": "./math/index.js",
110
- "./matrix": "./matrix/index.js",
111
- "./nullish": "./nullish/index.js",
112
- "./number": "./number/index.js",
113
- "./object": "./object/index.js",
114
- "./promise": "./promise/index.js",
115
- "./queue": "./queue/index.js",
116
- "./random": "./random/index.js",
117
- "./regex": "./regex/index.js",
118
- "./rmemo": "./rmemo/index.js",
119
- "./run": "./run/index.js",
120
- "./set": "./set/index.js",
121
- "./sleep": "./sleep/index.js",
122
- "./string": "./string/index.js",
123
- "./tempfile": "./tempfile/index.js",
124
- "./test": "./test/index.js",
125
- "./time": "./time/index.js",
126
- "./tuple": "./tuple/index.js",
127
- "./types": "./types/index.js",
128
- "./uri": "./uri/index.js",
129
- "./uuid": "./uuid/index.js",
130
- "./package.json": "./package.json"
131
- },
132
- "scripts": {
133
- "build": ":",
134
- "clean": ":",
135
- "exec": "$@",
136
- "prepublishOnly": "pnpm clean && pnpm build && pnpm test",
137
- "test": "pnpm run /^test:/",
138
- "test:size": "size-limit",
139
- "test:type": "check-dts",
140
- "test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
141
- "disable:test:coverage": "c8 pnpm test:unit"
142
- },
143
- "devDependencies": {
144
- "@arethetypeswrong/cli": "^0.13.5",
145
- "@ctx-core/preprocess": "^0.1.1",
146
- "@size-limit/preset-small-lib": "^11.0.1",
147
- "@types/node": "^20.11.2",
148
- "@types/sinon": "^17.0.3",
149
- "c8": "^9.1.0",
150
- "check-dts": "^0.7.2",
151
- "esbuild": "^0.19.11",
152
- "esmock": "^2.6.2",
153
- "sinon": "^17.0.1",
154
- "size-limit": "^11.0.1",
155
- "tsx": "^4.7.0",
156
- "typescript": "next",
157
- "uvu": "^0.5.6"
158
- },
159
- "publishConfig": {
160
- "access": "public",
161
- "cache": "~/.npm"
162
- },
163
- "sideEffects": false,
164
- "size-limit": [
165
- {
166
- "name": "ctx_",
167
- "import": {
168
- "./be": "{ ctx_ }"
169
- },
170
- "limit": "33 B"
171
- },
172
- {
173
- "name": "ns_ctx_",
174
- "import": {
175
- "./be": "{ ns_ctx_ }"
176
- },
177
- "limit": "85 B"
178
- },
179
- {
180
- "name": "be_",
181
- "import": {
182
- "./be": "{ be_ }"
183
- },
184
- "limit": "99 B"
185
- },
186
- {
187
- "name": "be_ ctx_",
188
- "import": {
189
- "./be": "{ be_, ctx_ }"
190
- },
191
- "limit": "131 B"
192
- },
193
- {
194
- "name": "be_ ns_ctx_",
195
- "import": {
196
- "./be": "{ be_, ctx_, ns_ctx_ }"
197
- },
198
- "limit": "190 B"
199
- },
200
- {
201
- "name": "be_ ctx_ ns_ctx_",
202
- "import": {
203
- "./be": "{ be_, ctx_, ns_ctx_ }"
204
- },
205
- "limit": "190 B"
206
- },
207
- {
208
- "name": "memo_",
209
- "import": {
210
- "./rmemo": "{ memo_ }"
211
- },
212
- "limit": "352 B"
213
- },
214
- {
215
- "name": "memo_ sig_",
216
- "import": {
217
- "./rmemo": "{ sig_, memo_ }"
218
- },
219
- "limit": "370 B"
220
- },
221
- {
222
- "name": "memo_ sig_ be_ ctx_",
223
- "import": {
224
- "./rmemo": "{ sig_, memo_, be_, ctx_ }"
225
- },
226
- "limit": "471 B"
227
- },
228
- {
229
- "name": "memo_ sig_ be_ ctx_ be_memo_pair_ be_sig_triple_",
230
- "import": {
231
- "./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
232
- },
233
- "limit": "576 B"
234
- },
235
- {
236
- "name": "uuid",
237
- "import": {
238
- "./uuid": "{ uuid_ }"
239
- },
240
- "limit": "39 B"
241
- },
242
- {
243
- "name": "short uuid",
244
- "import": {
245
- "./uuid": "{ short_uuid_ }"
246
- },
247
- "limit": "116 B"
248
- }
249
- ]
250
- }
2
+ "name": "ctx-core",
3
+ "version": "5.19.0",
4
+ "description": "ctx-core core library",
5
+ "keywords": [
6
+ "ctx-core",
7
+ "array",
8
+ "combinators",
9
+ "function",
10
+ "object",
11
+ "set"
12
+ ],
13
+ "homepage": "https://github.com/ctx-core/ctx-core#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/ctx-core/ctx-core/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/ctx-core/ctx-core.git"
20
+ },
21
+ "license": "Apache-2.0",
22
+ "author": "Brian Takita",
23
+ "type": "module",
24
+ "files": [
25
+ "*.d.ts",
26
+ "*.js",
27
+ "*.json",
28
+ "all",
29
+ "array",
30
+ "atob",
31
+ "base16",
32
+ "be",
33
+ "btoa",
34
+ "buffer",
35
+ "chain",
36
+ "class",
37
+ "cli-args",
38
+ "color",
39
+ "combinators",
40
+ "crypto",
41
+ "currency",
42
+ "data",
43
+ "date",
44
+ "debounce",
45
+ "deep_equal",
46
+ "env",
47
+ "error",
48
+ "falsy",
49
+ "fetch",
50
+ "fibonacci",
51
+ "fs",
52
+ "function",
53
+ "functional",
54
+ "html",
55
+ "http",
56
+ "math",
57
+ "matrix",
58
+ "nullish",
59
+ "number",
60
+ "object",
61
+ "promise",
62
+ "queue",
63
+ "random",
64
+ "regex",
65
+ "rmemo",
66
+ "run",
67
+ "set",
68
+ "sleep",
69
+ "stream",
70
+ "string",
71
+ "tempfile",
72
+ "test",
73
+ "time",
74
+ "tuple",
75
+ "types",
76
+ "uri",
77
+ "uuid",
78
+ "package.json"
79
+ ],
80
+ "exports": {
81
+ ".": "./index.js",
82
+ "./all": "./all/index.js",
83
+ "./array": "./array/index.js",
84
+ "./atob": "./atob/index.js",
85
+ "./base16": "./base16/index.js",
86
+ "./be": "./be/index.js",
87
+ "./btoa": "./btoa/index.js",
88
+ "./buffer": "./buffer/index.js",
89
+ "./chain": "./chain/index.js",
90
+ "./class": "./class/index.js",
91
+ "./cli-args": "./cli-args/index.js",
92
+ "./color": "./color/index.js",
93
+ "./combinators": "./combinators/index.js",
94
+ "./crypto": "./crypto/index.js",
95
+ "./currency": "./currency/index.js",
96
+ "./data": "./data/index.js",
97
+ "./date": "./date/index.js",
98
+ "./debounce": "./debounce/index.js",
99
+ "./deep_equal": "./deep_equal/index.js",
100
+ "./env": "./env/index.js",
101
+ "./error": "./error/index.js",
102
+ "./falsy": "./falsy/index.js",
103
+ "./fetch": "./fetch/index.js",
104
+ "./fibonacci": "./fibonacci/index.js",
105
+ "./fs": "./fs/index.js",
106
+ "./function": "./function/index.js",
107
+ "./functional": "./functional/index.js",
108
+ "./html": "./html/index.js",
109
+ "./http": "./http/index.js",
110
+ "./math": "./math/index.js",
111
+ "./matrix": "./matrix/index.js",
112
+ "./nullish": "./nullish/index.js",
113
+ "./number": "./number/index.js",
114
+ "./object": "./object/index.js",
115
+ "./promise": "./promise/index.js",
116
+ "./queue": "./queue/index.js",
117
+ "./random": "./random/index.js",
118
+ "./regex": "./regex/index.js",
119
+ "./rmemo": "./rmemo/index.js",
120
+ "./run": "./run/index.js",
121
+ "./set": "./set/index.js",
122
+ "./sleep": "./sleep/index.js",
123
+ "./stream": "./stream/index.js",
124
+ "./string": "./string/index.js",
125
+ "./tempfile": "./tempfile/index.js",
126
+ "./test": "./test/index.js",
127
+ "./time": "./time/index.js",
128
+ "./tuple": "./tuple/index.js",
129
+ "./types": "./types/index.js",
130
+ "./uri": "./uri/index.js",
131
+ "./uuid": "./uuid/index.js",
132
+ "./package.json": "./package.json"
133
+ },
134
+ "devDependencies": {
135
+ "@arethetypeswrong/cli": "^0.13.5",
136
+ "@ctx-core/preprocess": "^0.1.1",
137
+ "@size-limit/preset-small-lib": "^11.0.1",
138
+ "@types/node": "^20.11.3",
139
+ "@types/sinon": "^17.0.3",
140
+ "c8": "^9.1.0",
141
+ "check-dts": "^0.7.2",
142
+ "esbuild": "^0.19.11",
143
+ "esmock": "^2.6.2",
144
+ "sinon": "^17.0.1",
145
+ "size-limit": "^11.0.1",
146
+ "tsx": "^4.7.0",
147
+ "typescript": "next",
148
+ "uvu": "^0.5.6"
149
+ },
150
+ "publishConfig": {
151
+ "access": "public",
152
+ "cache": "~/.npm"
153
+ },
154
+ "sideEffects": false,
155
+ "size-limit": [
156
+ {
157
+ "name": "ctx_",
158
+ "import": {
159
+ "./be": "{ ctx_ }"
160
+ },
161
+ "limit": "33 B"
162
+ },
163
+ {
164
+ "name": "ns_ctx_",
165
+ "import": {
166
+ "./be": "{ ns_ctx_ }"
167
+ },
168
+ "limit": "85 B"
169
+ },
170
+ {
171
+ "name": "be_",
172
+ "import": {
173
+ "./be": "{ be_ }"
174
+ },
175
+ "limit": "99 B"
176
+ },
177
+ {
178
+ "name": "be_ ctx_",
179
+ "import": {
180
+ "./be": "{ be_, ctx_ }"
181
+ },
182
+ "limit": "131 B"
183
+ },
184
+ {
185
+ "name": "be_ ns_ctx_",
186
+ "import": {
187
+ "./be": "{ be_, ctx_, ns_ctx_ }"
188
+ },
189
+ "limit": "190 B"
190
+ },
191
+ {
192
+ "name": "be_ ctx_ ns_ctx_",
193
+ "import": {
194
+ "./be": "{ be_, ctx_, ns_ctx_ }"
195
+ },
196
+ "limit": "190 B"
197
+ },
198
+ {
199
+ "name": "memo_",
200
+ "import": {
201
+ "./rmemo": "{ memo_ }"
202
+ },
203
+ "limit": "352 B"
204
+ },
205
+ {
206
+ "name": "memo_ sig_",
207
+ "import": {
208
+ "./rmemo": "{ sig_, memo_ }"
209
+ },
210
+ "limit": "370 B"
211
+ },
212
+ {
213
+ "name": "memo_ sig_ be_ ctx_",
214
+ "import": {
215
+ "./rmemo": "{ sig_, memo_, be_, ctx_ }"
216
+ },
217
+ "limit": "471 B"
218
+ },
219
+ {
220
+ "name": "memo_ sig_ be_ ctx_ be_memo_pair_ be_sig_triple_",
221
+ "import": {
222
+ "./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
223
+ },
224
+ "limit": "576 B"
225
+ },
226
+ {
227
+ "name": "uuid",
228
+ "import": {
229
+ "./uuid": "{ uuid_ }"
230
+ },
231
+ "limit": "39 B"
232
+ },
233
+ {
234
+ "name": "short uuid",
235
+ "import": {
236
+ "./uuid": "{ short_uuid_ }"
237
+ },
238
+ "limit": "116 B"
239
+ }
240
+ ],
241
+ "scripts": {
242
+ "build": ":",
243
+ "clean": ":",
244
+ "exec": "$@",
245
+ "test": "pnpm run /^test:/",
246
+ "test:size": "size-limit",
247
+ "test:type": "check-dts",
248
+ "test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
249
+ "disable:test:coverage": "c8 pnpm test:unit"
250
+ }
251
+ }
@@ -0,0 +1,2 @@
1
+ export * from '../all/TextDecoderStream/index.js'
2
+ export * from '../all/TextEncoderStream/index.js'
@@ -0,0 +1,2 @@
1
+ export * from '../all/TextDecoderStream/index.js'
2
+ export * from '../all/TextEncoderStream/index.js'