Skip to content

Commit

Permalink
feat: export ts types in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Oct 22, 2021
1 parent f7313bd commit 890bf8d
Show file tree
Hide file tree
Showing 36 changed files with 346 additions and 108 deletions.
14 changes: 0 additions & 14 deletions packages/csv-generate/dist/cjs/index.d.ts
Expand Up @@ -12,76 +12,62 @@ export class Generator extends stream.Readable {
}

export interface Options {

/**
* Define the number of generated fields and the generation method.
*/
columns?: number | string[];

/**
* Set the field delimiter.
*/
delimiter?: string;

/**
* Period to run in milliseconds.
*/
duration?: number;

/**
* If specified, then buffers will be decoded to strings using the specified encoding.
*/
encoding?: string;

/**
* When to stop the generation.
*/
end?: number | Date;

/**
* One or multiple characters to print at the end of the file; only apply when objectMode is disabled.
*/
eof?: boolean | string;

/**
* Generate buffers equals length as defined by the `highWaterMark` option.
*/
fixed_size?: boolean;
fixedSize?: boolean;

/**
* The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
*/
high_water_mark?: number;
highWaterMark?: number;

/**
* Number of lines or records to generate.
*/
length?: number;

/**
* Maximum number of characters per word.
*/
max_word_length?: number;
maxWordLength?: number;

/**
* Whether this stream should behave as a stream of objects.
*/
object_mode?: boolean
objectMode?: boolean;

/**
* One or multiple characters used to delimit records.
*/
row_delimiter?: string;

/**
* Generate idempotent random characters if a number provided.
*/
seed?: boolean | number;

/**
* The time to wait between the generation of each records
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/csv-generate/dist/cjs/sync.d.ts
Expand Up @@ -2,6 +2,5 @@
import { Options } from './index';

declare function generate<T = any>(options: number | Options): string & Array<T>;

// export default generate;
export { generate };
export { generate, Options };
14 changes: 0 additions & 14 deletions packages/csv-generate/dist/esm/index.d.ts
Expand Up @@ -12,76 +12,62 @@ export class Generator extends stream.Readable {
}

export interface Options {

/**
* Define the number of generated fields and the generation method.
*/
columns?: number | string[];

/**
* Set the field delimiter.
*/
delimiter?: string;

/**
* Period to run in milliseconds.
*/
duration?: number;

/**
* If specified, then buffers will be decoded to strings using the specified encoding.
*/
encoding?: string;

/**
* When to stop the generation.
*/
end?: number | Date;

/**
* One or multiple characters to print at the end of the file; only apply when objectMode is disabled.
*/
eof?: boolean | string;

/**
* Generate buffers equals length as defined by the `highWaterMark` option.
*/
fixed_size?: boolean;
fixedSize?: boolean;

/**
* The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
*/
high_water_mark?: number;
highWaterMark?: number;

/**
* Number of lines or records to generate.
*/
length?: number;

/**
* Maximum number of characters per word.
*/
max_word_length?: number;
maxWordLength?: number;

/**
* Whether this stream should behave as a stream of objects.
*/
object_mode?: boolean
objectMode?: boolean;

/**
* One or multiple characters used to delimit records.
*/
row_delimiter?: string;

/**
* Generate idempotent random characters if a number provided.
*/
seed?: boolean | number;

/**
* The time to wait between the generation of each records
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/csv-generate/dist/esm/sync.d.ts
Expand Up @@ -2,6 +2,5 @@
import { Options } from './index';

declare function generate<T = any>(options: number | Options): string & Array<T>;

// export default generate;
export { generate };
export { generate, Options };
14 changes: 0 additions & 14 deletions packages/csv-generate/lib/index.d.ts
Expand Up @@ -12,76 +12,62 @@ export class Generator extends stream.Readable {
}

export interface Options {

/**
* Define the number of generated fields and the generation method.
*/
columns?: number | string[];

/**
* Set the field delimiter.
*/
delimiter?: string;

/**
* Period to run in milliseconds.
*/
duration?: number;

/**
* If specified, then buffers will be decoded to strings using the specified encoding.
*/
encoding?: string;

/**
* When to stop the generation.
*/
end?: number | Date;

/**
* One or multiple characters to print at the end of the file; only apply when objectMode is disabled.
*/
eof?: boolean | string;

/**
* Generate buffers equals length as defined by the `highWaterMark` option.
*/
fixed_size?: boolean;
fixedSize?: boolean;

/**
* The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource.
*/
high_water_mark?: number;
highWaterMark?: number;

/**
* Number of lines or records to generate.
*/
length?: number;

/**
* Maximum number of characters per word.
*/
max_word_length?: number;
maxWordLength?: number;

/**
* Whether this stream should behave as a stream of objects.
*/
object_mode?: boolean
objectMode?: boolean;

/**
* One or multiple characters used to delimit records.
*/
row_delimiter?: string;

/**
* Generate idempotent random characters if a number provided.
*/
seed?: boolean | number;

/**
* The time to wait between the generation of each records
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/csv-generate/lib/sync.d.ts
Expand Up @@ -2,6 +2,5 @@
import { Options } from './index';

declare function generate<T = any>(options: number | Options): string & Array<T>;

// export default generate;
export { generate };
export { generate, Options };
38 changes: 38 additions & 0 deletions packages/csv-generate/test/api.types.sync.ts
@@ -0,0 +1,38 @@

import 'should'
import { generate, Options } from '../lib/sync.js'

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

describe('usage', () => {

it('sync with options as number', () => {
const generator: string = generateSync(1)
generator.should.be.a.String()
})

it('sync with options in string mode', () => {
const generator: string = generateSync({length: 1})
generator.should.be.a.String()
})

it('sync with options in object mode', () => {
const generator: Array<Array<string>> = generateSync({length: 1, objectMode: true})
generator.should.be.an.Array()
})
})

describe('types', () => {
it('generate', () => {
const generator: string = generateSync(1)
return generator;
})
it('Options', () => {
const options: Options = {
columns: 1
}
return options;
})
})

})
16 changes: 0 additions & 16 deletions packages/csv-generate/test/api.types.ts
@@ -1,7 +1,6 @@

import 'should'
import { generate, Options, Generator } from '../lib/index.js'
import { generate as generateSync } from '../lib/sync.js'

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

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

it('sync with options as number', () => {
const generator: string = generateSync(1)
generator.should.be.a.String()
})

it('sync with options in string mode', () => {
const generator: string = generateSync({length: 1})
generator.should.be.a.String()
})

it('sync with options in object mode', () => {
const generator: Array<Array<string>> = generateSync({length: 1, objectMode: true})
generator.should.be.an.Array()
})

})

describe('Generator', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/csv-parse/dist/cjs/index.d.ts
Expand Up @@ -230,7 +230,6 @@ export interface Info {
readonly invalid_field_length: number;
}


export type CsvErrorCode =
'CSV_INVALID_OPTION_BOM'
| 'CSV_INVALID_OPTION_CAST'
Expand Down
6 changes: 5 additions & 1 deletion packages/csv-parse/dist/cjs/sync.d.ts
Expand Up @@ -2,6 +2,10 @@
import { Options } from './index';

declare function parse(input: Buffer | string, options?: Options): any;

// export default parse;
export { parse };

export {
CastingContext, CastingFunction, CastingDateFunction,
ColumnOption, Options, Info, CsvErrorCode, CsvError
} from './index';
1 change: 0 additions & 1 deletion packages/csv-parse/dist/esm/index.d.ts
Expand Up @@ -230,7 +230,6 @@ export interface Info {
readonly invalid_field_length: number;
}


export type CsvErrorCode =
'CSV_INVALID_OPTION_BOM'
| 'CSV_INVALID_OPTION_CAST'
Expand Down
6 changes: 5 additions & 1 deletion packages/csv-parse/dist/esm/sync.d.ts
Expand Up @@ -2,6 +2,10 @@
import { Options } from './index';

declare function parse(input: Buffer | string, options?: Options): any;

// export default parse;
export { parse };

export {
CastingContext, CastingFunction, CastingDateFunction,
ColumnOption, Options, Info, CsvErrorCode, CsvError
} from './index';
1 change: 0 additions & 1 deletion packages/csv-parse/lib/index.d.ts
Expand Up @@ -230,7 +230,6 @@ export interface Info {
readonly invalid_field_length: number;
}


export type CsvErrorCode =
'CSV_INVALID_OPTION_BOM'
| 'CSV_INVALID_OPTION_CAST'
Expand Down
6 changes: 5 additions & 1 deletion packages/csv-parse/lib/sync.d.ts
Expand Up @@ -2,6 +2,10 @@
import { Options } from './index';

declare function parse(input: Buffer | string, options?: Options): any;

// export default parse;
export { parse };

export {
CastingContext, CastingFunction, CastingDateFunction,
ColumnOption, Options, Info, CsvErrorCode, CsvError
} from './index';

0 comments on commit 890bf8d

Please sign in to comment.