Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/csv-generate/dist/cjs/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as stream from "stream";
type Callback = (err?: Error, records?: unknown) => void;

export class Generator extends stream.Readable {
end(): void;
constructor(options?: Options);

readonly options: Options;
Expand All @@ -14,7 +15,9 @@ export type ColumnsFunctionArgs = {
options: Options;
state: State;
};
export type ColumnsFunction = (args: ColumnsFunctionArgs) => string;
export type ColumnsFunction = (
args: ColumnsFunctionArgs,
) => string | number | null;

export type State = {
start_time: number;
Expand Down
5 changes: 4 additions & 1 deletion packages/csv-generate/dist/esm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as stream from "stream";
type Callback = (err?: Error, records?: unknown) => void;

export class Generator extends stream.Readable {
end(): void;
constructor(options?: Options);

readonly options: Options;
Expand All @@ -14,7 +15,9 @@ export type ColumnsFunctionArgs = {
options: Options;
state: State;
};
export type ColumnsFunction = (args: ColumnsFunctionArgs) => string;
export type ColumnsFunction = (
args: ColumnsFunctionArgs,
) => string | number | null;

export type State = {
start_time: number;
Expand Down
5 changes: 4 additions & 1 deletion packages/csv-generate/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as stream from "stream";
type Callback = (err?: Error, records?: unknown) => void;

export class Generator extends stream.Readable {
end(): void;
constructor(options?: Options);

readonly options: Options;
Expand All @@ -14,7 +15,9 @@ export type ColumnsFunctionArgs = {
options: Options;
state: State;
};
export type ColumnsFunction = (args: ColumnsFunctionArgs) => string;
export type ColumnsFunction = (
args: ColumnsFunctionArgs,
) => string | number | null;

export type State = {
start_time: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("Option `columns`", function () {
it("as number", function (next) {
this.timeout(1000000);
let count = 0;
const data = [];
const data: Buffer[] = [];
const generator = generate({ columns: 3 });
generator.on("readable", () => {
let d;
Expand All @@ -26,7 +26,7 @@ describe("Option `columns`", function () {
it("as types", function (next) {
this.timeout(1000000);
let count = 0;
const data = [];
const data: Buffer[] = [];
const generator = generate({ columns: ["int", "bool"], seed: 1 });
generator.on("readable", () => {
let d;
Expand All @@ -52,7 +52,7 @@ describe("Option `columns`", function () {
try {
generate({ columns: ["int", "bool", "invalid"] });
} catch (err) {
err.message.should.eql(
(err as Error).message.should.eql(
'Invalid column type: got "invalid", default values are ["ascii","int","bool"]',
);
}
Expand All @@ -61,7 +61,7 @@ describe("Option `columns`", function () {
describe("user function", function () {
it("accept string or null or number", function (next) {
this.timeout(1000000);
const data = [];
const data: string[] = [];
const generator = generate({
length: 1,
columns: [() => "a", () => null, () => 1],
Expand All @@ -81,6 +81,7 @@ describe("Option `columns`", function () {

it("validate return argument", function (next) {
this.timeout(1000000);
// @ts-expect-error Exercise runtime rejection of unsupported return values.
const generator = generate({
objectMode: true,
columns: [() => ({})],
Expand All @@ -104,7 +105,7 @@ describe("Option `columns`", function () {

it("validate arguments in objectMode", function (next) {
this.timeout(1000000);
const data = [];
const data: unknown[] = [];
const generator = generate({
objectMode: true,
length: 1,
Expand Down
Loading