File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Changelog
22
3- ## 5 .0.0-beta.36
3+ ## 4 .0.0-beta.36
44
55** Initial TypeScript Release**
66
Original file line number Diff line number Diff line change 11{
22 "name" : " @eggjs/co-busboy" ,
3- "version" : " 5 .0.0-beta.36" ,
3+ "version" : " 4 .0.0-beta.36" ,
44 "description" : " co-busboy for egg - multipart form data handling with async/await support" ,
55 "keywords" : [
66 " busboy" ,
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ export interface FileStream extends Readable {
2828 transferEncoding : string ;
2929 mime : string ;
3030 mimeType : string ;
31+ /**
32+ * Set by busboy when file size limit is reached
33+ */
34+ truncated ?: boolean ;
3135}
3236
3337/**
@@ -94,6 +98,10 @@ export interface Parts {
9498 ( ) : Promise < Part | null > ;
9599 field : Record < string , string | string [ ] > ;
96100 fields : FieldTuple [ ] ;
101+ /**
102+ * Allow adding async iterator at runtime for for-await-of support
103+ */
104+ [ Symbol . asyncIterator ] ?: ( ) => AsyncIterator < Part > ;
97105}
98106
99107/**
Original file line number Diff line number Diff line change 5959 "typecheck" : " tsgo --noEmit"
6060 },
6161 "dependencies" : {
62+ "@eggjs/co-busboy" : " workspace:*" ,
6263 "@eggjs/path-matching" : " workspace:*" ,
6364 "bytes" : " catalog:" ,
64- "co-busboy" : " catalog:" ,
6565 "dayjs" : " catalog:"
6666 },
6767 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ import path from 'node:path';
66import { Readable , PassThrough } from 'node:stream' ;
77import { pipeline } from 'node:stream/promises' ;
88
9- // @ts -expect-error no types
10- import parse from 'co-busboy' ;
9+ import { parse , type Part } from '@eggjs/co-busboy' ;
1110import dayjs from 'dayjs' ;
1211import { Context } from 'egg' ;
1312
@@ -120,7 +119,7 @@ export default class MultipartContext extends Context {
120119 // mount asyncIterator, so we can use `for await` to get parts
121120 const parts = parse ( this , parseOptions ) ;
122121 parts [ Symbol . asyncIterator ] = async function * ( ) {
123- let part : MultipartFileStream | undefined ;
122+ let part : Part | null ;
124123 do {
125124 part = await parts ( ) ;
126125
@@ -157,10 +156,10 @@ export default class MultipartContext extends Context {
157156 }
158157
159158 // dispatch part to outter logic such as for-await-of
160- yield part ;
161- } while ( part !== undefined ) ;
159+ yield part as MultipartFileStream ;
160+ } while ( part !== null ) ;
162161 } ;
163- return parts ;
162+ return parts as unknown as AsyncIterable < MultipartFileStream > ;
164163 }
165164
166165 /**
You can’t perform that action at this time.
0 commit comments