Skip to content

Commit 890bf8d

Browse files
committedOct 22, 2021
feat: export ts types in sync
1 parent f7313bd commit 890bf8d

36 files changed

+346
-108
lines changed
 

‎packages/csv-generate/dist/cjs/index.d.ts

-14
Original file line numberDiff line numberDiff line change
@@ -12,76 +12,62 @@ export class Generator extends stream.Readable {
1212
}
1313

1414
export interface Options {
15-
1615
/**
1716
* Define the number of generated fields and the generation method.
1817
*/
1918
columns?: number | string[];
20-
2119
/**
2220
* Set the field delimiter.
2321
*/
2422
delimiter?: string;
25-
2623
/**
2724
* Period to run in milliseconds.
2825
*/
2926
duration?: number;
30-
3127
/**
3228
* If specified, then buffers will be decoded to strings using the specified encoding.
3329
*/
3430
encoding?: string;
35-
3631
/**
3732
* When to stop the generation.
3833
*/
3934
end?: number | Date;
40-
4135
/**
4236
* One or multiple characters to print at the end of the file; only apply when objectMode is disabled.
4337
*/
4438
eof?: boolean | string;
45-
4639
/**
4740
* Generate buffers equals length as defined by the `highWaterMark` option.
4841
*/
4942
fixed_size?: boolean;
5043
fixedSize?: boolean;
51-
5244
/**
5345
* The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
5446
*/
5547
high_water_mark?: number;
5648
highWaterMark?: number;
57-
5849
/**
5950
* Number of lines or records to generate.
6051
*/
6152
length?: number;
62-
6353
/**
6454
* Maximum number of characters per word.
6555
*/
6656
max_word_length?: number;
6757
maxWordLength?: number;
68-
6958
/**
7059
* Whether this stream should behave as a stream of objects.
7160
*/
7261
object_mode?: boolean
7362
objectMode?: boolean;
74-
7563
/**
7664
* One or multiple characters used to delimit records.
7765
*/
7866
row_delimiter?: string;
79-
8067
/**
8168
* Generate idempotent random characters if a number provided.
8269
*/
8370
seed?: boolean | number;
84-
8571
/**
8672
* The time to wait between the generation of each records
8773
*/

‎packages/csv-generate/dist/cjs/sync.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
import { Options } from './index';
33

44
declare function generate<T = any>(options: number | Options): string & Array<T>;
5-
65
// export default generate;
7-
export { generate };
6+
export { generate, Options };

‎packages/csv-generate/dist/esm/index.d.ts

-14
Original file line numberDiff line numberDiff line change
@@ -12,76 +12,62 @@ export class Generator extends stream.Readable {
1212
}
1313

1414
export interface Options {
15-
1615
/**
1716
* Define the number of generated fields and the generation method.
1817
*/
1918
columns?: number | string[];
20-
2119
/**
2220
* Set the field delimiter.
2321
*/
2422
delimiter?: string;
25-
2623
/**
2724
* Period to run in milliseconds.
2825
*/
2926
duration?: number;
30-
3127
/**
3228
* If specified, then buffers will be decoded to strings using the specified encoding.
3329
*/
3430
encoding?: string;
35-
3631
/**
3732
* When to stop the generation.
3833
*/
3934
end?: number | Date;
40-
4135
/**
4236
* One or multiple characters to print at the end of the file; only apply when objectMode is disabled.
4337
*/
4438
eof?: boolean | string;
45-
4639
/**
4740
* Generate buffers equals length as defined by the `highWaterMark` option.
4841
*/
4942
fixed_size?: boolean;
5043
fixedSize?: boolean;
51-
5244
/**
5345
* The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
5446
*/
5547
high_water_mark?: number;
5648
highWaterMark?: number;
57-
5849
/**
5950
* Number of lines or records to generate.
6051
*/
6152
length?: number;
62-
6353
/**
6454
* Maximum number of characters per word.
6555
*/
6656
max_word_length?: number;
6757
maxWordLength?: number;
68-
6958
/**
7059
* Whether this stream should behave as a stream of objects.
7160
*/
7261
object_mode?: boolean
7362
objectMode?: boolean;
74-
7563
/**
7664
* One or multiple characters used to delimit records.
7765
*/
7866
row_delimiter?: string;
79-
8067
/**
8168
* Generate idempotent random characters if a number provided.
8269
*/
8370
seed?: boolean | number;
84-
8571
/**
8672
* The time to wait between the generation of each records
8773
*/

‎packages/csv-generate/dist/esm/sync.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
import { Options } from './index';
33

44
declare function generate<T = any>(options: number | Options): string & Array<T>;
5-
65
// export default generate;
7-
export { generate };
6+
export { generate, Options };

‎packages/csv-generate/lib/index.d.ts

-14
Original file line numberDiff line numberDiff line change
@@ -12,76 +12,62 @@ export class Generator extends stream.Readable {
1212
}
1313

1414
export interface Options {
15-
1615
/**
1716
* Define the number of generated fields and the generation method.
1817
*/
1918
columns?: number | string[];
20-
2119
/**
2220
* Set the field delimiter.
2321
*/
2422
delimiter?: string;
25-
2623
/**
2724
* Period to run in milliseconds.
2825
*/
2926
duration?: number;
30-
3127
/**
3228
* If specified, then buffers will be decoded to strings using the specified encoding.
3329
*/
3430
encoding?: string;
35-
3631
/**
3732
* When to stop the generation.
3833
*/
3934
end?: number | Date;
40-
4135
/**
4236
* One or multiple characters to print at the end of the file; only apply when objectMode is disabled.
4337
*/
4438
eof?: boolean | string;
45-
4639
/**
4740
* Generate buffers equals length as defined by the `highWaterMark` option.
4841
*/
4942
fixed_size?: boolean;
5043
fixedSize?: boolean;
51-
5244
/**
5345
* The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
5446
*/
5547
high_water_mark?: number;
5648
highWaterMark?: number;
57-
5849
/**
5950
* Number of lines or records to generate.
6051
*/
6152
length?: number;
62-
6353
/**
6454
* Maximum number of characters per word.
6555
*/
6656
max_word_length?: number;
6757
maxWordLength?: number;
68-
6958
/**
7059
* Whether this stream should behave as a stream of objects.
7160
*/
7261
object_mode?: boolean
7362
objectMode?: boolean;
74-
7563
/**
7664
* One or multiple characters used to delimit records.
7765
*/
7866
row_delimiter?: string;
79-
8067
/**
8168
* Generate idempotent random characters if a number provided.
8269
*/
8370
seed?: boolean | number;
84-
8571
/**
8672
* The time to wait between the generation of each records
8773
*/

‎packages/csv-generate/lib/sync.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
import { Options } from './index';
33

44
declare function generate<T = any>(options: number | Options): string & Array<T>;
5-
65
// export default generate;
7-
export { generate };
6+
export { generate, Options };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
import 'should'
3+
import { generate, Options } from '../lib/sync.js'
4+
5+
describe('API Types', () => {
6+
7+
describe('usage', () => {
8+
9+
it('sync with options as number', () => {
10+
const generator: string = generateSync(1)
11+
generator.should.be.a.String()
12+
})
13+
14+
it('sync with options in string mode', () => {
15+
const generator: string = generateSync({length: 1})
16+
generator.should.be.a.String()
17+
})
18+
19+
it('sync with options in object mode', () => {
20+
const generator: Array<Array<string>> = generateSync({length: 1, objectMode: true})
21+
generator.should.be.an.Array()
22+
})
23+
})
24+
25+
describe('types', () => {
26+
it('generate', () => {
27+
const generator: string = generateSync(1)
28+
return generator;
29+
})
30+
it('Options', () => {
31+
const options: Options = {
32+
columns: 1
33+
}
34+
return options;
35+
})
36+
})
37+
38+
})

‎packages/csv-generate/test/api.types.ts

-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
import 'should'
33
import { generate, Options, Generator } from '../lib/index.js'
4-
import { generate as generateSync } from '../lib/sync.js'
54

65
describe('API Types', () => {
76

@@ -18,21 +17,6 @@ describe('API Types', () => {
1817
generate( {length: 1}, (err, records) => err || records )
1918
})
2019

21-
it('sync with options as number', () => {
22-
const generator: string = generateSync(1)
23-
generator.should.be.a.String()
24-
})
25-
26-
it('sync with options in string mode', () => {
27-
const generator: string = generateSync({length: 1})
28-
generator.should.be.a.String()
29-
})
30-
31-
it('sync with options in object mode', () => {
32-
const generator: Array<Array<string>> = generateSync({length: 1, objectMode: true})
33-
generator.should.be.an.Array()
34-
})
35-
3620
})
3721

3822
describe('Generator', () => {

‎packages/csv-parse/dist/cjs/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ export interface Info {
230230
readonly invalid_field_length: number;
231231
}
232232

233-
234233
export type CsvErrorCode =
235234
'CSV_INVALID_OPTION_BOM'
236235
| 'CSV_INVALID_OPTION_CAST'

‎packages/csv-parse/dist/cjs/sync.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import { Options } from './index';
33

44
declare function parse(input: Buffer | string, options?: Options): any;
5-
65
// export default parse;
76
export { parse };
7+
8+
export {
9+
CastingContext, CastingFunction, CastingDateFunction,
10+
ColumnOption, Options, Info, CsvErrorCode, CsvError
11+
} from './index';

‎packages/csv-parse/dist/esm/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ export interface Info {
230230
readonly invalid_field_length: number;
231231
}
232232

233-
234233
export type CsvErrorCode =
235234
'CSV_INVALID_OPTION_BOM'
236235
| 'CSV_INVALID_OPTION_CAST'

‎packages/csv-parse/dist/esm/sync.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import { Options } from './index';
33

44
declare function parse(input: Buffer | string, options?: Options): any;
5-
65
// export default parse;
76
export { parse };
7+
8+
export {
9+
CastingContext, CastingFunction, CastingDateFunction,
10+
ColumnOption, Options, Info, CsvErrorCode, CsvError
11+
} from './index';

‎packages/csv-parse/lib/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ export interface Info {
230230
readonly invalid_field_length: number;
231231
}
232232

233-
234233
export type CsvErrorCode =
235234
'CSV_INVALID_OPTION_BOM'
236235
| 'CSV_INVALID_OPTION_CAST'

‎packages/csv-parse/lib/sync.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import { Options } from './index';
33

44
declare function parse(input: Buffer | string, options?: Options): any;
5-
65
// export default parse;
76
export { parse };
7+
8+
export {
9+
CastingContext, CastingFunction, CastingDateFunction,
10+
ColumnOption, Options, Info, CsvErrorCode, CsvError
11+
} from './index';

0 commit comments

Comments
 (0)
Please sign in to comment.