File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,24 @@ import * as stream from "stream";
4
4
5
5
export type Callback = ( err : Error | undefined , output : string ) => void
6
6
export type RecordDelimiter = string | Buffer | 'auto' | 'unix' | 'mac' | 'windows' | 'ascii' | 'unicode'
7
- export type Cast < T > = ( value : T , context : CastingContext ) => string
7
+
8
+ export type CastReturnObject = { value : string } & Pick <
9
+ Options ,
10
+ | 'delimiter'
11
+ | 'escape'
12
+ | 'quote'
13
+ | 'quoted'
14
+ | 'quoted_empty'
15
+ | 'quoted_string'
16
+ | 'quoted_match'
17
+ | 'record_delimiter'
18
+ >
19
+
20
+ export type Cast < T > = (
21
+ value : T ,
22
+ context : CastingContext
23
+ ) => string | CastReturnObject ;
24
+
8
25
export type PlainObject < T > = Record < string , T >
9
26
export type Input = any [ ]
10
27
export interface ColumnOption {
Original file line number Diff line number Diff line change @@ -37,5 +37,17 @@ describe('API Types', () => {
37
37
}
38
38
return options
39
39
} )
40
+
41
+ it ( 'allows cast to return an object' , ( ) => {
42
+ const options : Options = {
43
+ cast : {
44
+ boolean : ( value : boolean ) => ( {
45
+ value : value . toString ( ) ,
46
+ delimiter : ';' ,
47
+ quote : false
48
+ } )
49
+ }
50
+ }
51
+ } )
40
52
41
53
} )
You can’t perform that action at this time.
0 commit comments