File tree Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Expand file tree Collapse file tree 4 files changed +36
-3
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ /// <reference lib="dom" />
2
+
3
+ import type { ReadableStream as NodeWebReadableStream } from 'node:stream/web' ;
4
+ type DomReadableStream < R > = ReadableStream < R > ;
5
+
6
+ type Data = Uint8Array | string ;
7
+
8
+ export type WebStream < T extends Data > = DomReadableStream < T >
9
+ export type NodeWebStream < T extends Data > = NodeWebReadableStream < T > ;
10
+
11
+ type Stream < T extends Data > = WebStream < T > | NodeWebStream < T > ;
12
+ type MaybeStream < T extends Data > = T | Stream < T > ;
13
+
14
+ export function readToEnd < T extends Data , JoinFn extends ( chunks : T [ ] ) => any = ( chunks : T [ ] ) => T > (
15
+ input : MaybeStream < T > ,
16
+ join ?: JoinFn
17
+ ) : Promise < ReturnType < JoinFn > > ;
18
+
19
+ export function toStream < T extends Data , InputType extends MaybeStream < T > > (
20
+ input : InputType
21
+ ) : InputType extends T ? Stream < InputType > : InputType ;
22
+
23
+ export function isStream < T extends Data > ( input : MaybeStream < T > ) : input is Stream < T > ;
24
+
25
+ export function slice < T extends Data , InputType extends MaybeStream < T > > (
26
+ input : InputType ,
27
+ begin : number ,
28
+ end ?: number | typeof Infinity
29
+ ) : InputType ; // same as 'typeof input'
Original file line number Diff line number Diff line change 8
8
" tsconfig.json"
9
9
],
10
10
"exports" : {
11
- "types" : " ./lib/index.d.ts" ,
11
+ "types@<5.5" : " ./lib/types/v4.7-v5.4/index.d.ts" ,
12
+ "types" : " ./lib/types/index.d.ts" ,
12
13
"import" : " ./lib/index.js"
13
14
},
14
- "types" : " ./lib/index.d.ts" ,
15
+ "typesVersions" : {
16
+ ">=5.5" : { "." : [" lib/types/index.d.ts" ] },
17
+ ">=4.7" : { "." : [" lib/types/v4.7-v5.4/index.d.ts" ] }
18
+ },
15
19
"main" : " ./lib/index.js" ,
16
20
"engines" : {
17
21
"node" : " >= 18.0.0"
66
70
"test-type-definitions" : " tsc --project test/tsconfig.json && tsx test/typescript.test.ts && npm run test-type-definitions-es5" ,
67
71
"test-type-definitions-es5" : " tsc --project test/tsconfig.es5.json && tsx --tsconfig test/tsconfig.es5.json test/typescript.test.ts" ,
68
72
"test-browser" : " karma start karma.conf.cjs" ,
69
- "test-node" : " ts-mocha -n loader=ts-node/esm ./test/node.test.ts ./test/common.test.ts" ,
73
+ "test-node" : " NODE_OPTIONS='--import=tsx' mocha ./test/node.test.ts ./test/common.test.ts" ,
70
74
"lint" : " eslint lib test" ,
71
75
"docs" : " jsdoc --configure .jsdocrc.cjs --destination docs --readme README.md lib && printf '%s' 'web-stream-tools.openpgpjs.org' > docs/CNAME" ,
72
76
"preversion" : " rm -rf docs" ,
You can’t perform that action at this time.
0 commit comments