Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
catamphetamine committed Oct 19, 2021
1 parent 17dfae9 commit 6c7fcb0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export function parseExcelDate(excelSerialDate: number) : typeof Date;

type Input = File;

function readXlsxFile(input: Input, options: ParseWithSchemaOptions) : Promise<ParsedObjectsResult>;
function readXlsxFile(input: Input, options: ParseWithMapOptions) : Promise<ParsedObjectsResult>;
function readXlsxFile(input: Input, options?: ParseWithoutSchemaOptions) : Promise<Row[]>;
export function readXlsxFile<T extends object>(input: Input, options: ParseWithSchemaOptions<T>) : Promise<ParsedObjectsResult<T>>;
export function readXlsxFile<T extends object>(input: Input, options: ParseWithMapOptions) : Promise<ParsedObjectsResult<T>>;
export function readXlsxFile(input: Input, options?: ParseWithoutSchemaOptions) : Promise<Row[]>;

export default readXlsxFile;
6 changes: 3 additions & 3 deletions node/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function parseExcelDate(excelSerialDate: number) : typeof Date;

type Input = Stream | PathLike;

function readXlsxFile(input: Input, options: ParseWithSchemaOptions) : Promise<ParsedObjectsResult>;
function readXlsxFile(input: Input, options: ParseWithMapOptions) : Promise<ParsedObjectsResult>;
function readXlsxFile(input: Input, options?: ParseWithoutSchemaOptions) : Promise<Row[]>;
export function readXlsxFile<T extends object>(input: Input, options: ParseWithSchemaOptions<T>) : Promise<ParsedObjectsResult<T>>;
export function readXlsxFile<T extends object>(input: Input, options: ParseWithMapOptions) : Promise<ParsedObjectsResult<T>>;
export function readXlsxFile(input: Input, options?: ParseWithoutSchemaOptions) : Promise<Row[]>;

export default readXlsxFile;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "read-excel-file",
"version": "5.2.13",
"version": "5.2.20",
"description": "Read small to medium `*.xlsx` files in a browser or Node.js. Parse to JSON with a strict schema.",
"module": "index.js",
"sideEffects": false,
Expand Down
16 changes: 11 additions & 5 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,33 @@ export type Schema = Record<string, SchemaEntry>
export interface Error {
error: string;
row: number;
column: number;
column: string;
value?: any;
type?: SchemaEntry;
}

type Cell = string | number | boolean | typeof Date
export type Row = Cell[]

export interface ParsedObjectsResult {
rows: object[];
export interface ParsedObjectsResult<T extends object> {
rows: T[];
errors: Error[];
}

export interface ParseWithSchemaOptions {
export interface ParseWithSchemaOptions<T extends object> {
schema: Schema;
transformData?: (rows: Row[]) => Row[];
sheet?: number | string;
}

type MapProperty = string;
type MapObject = {
[key: string]: MapProperty | MapObject;
};
type Map = MapObject;

export interface ParseWithMapOptions {
map: object;
map: Map;
transformData?: (rows: Row[]) => Row[];
sheet?: number | string;
}
Expand Down

0 comments on commit 6c7fcb0

Please sign in to comment.