mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[jsonexport] Add new definition for jsonexport (#47678)
* Add jsonexport * Remove esModuleInterop config for backward compatibility
This commit is contained in:
parent
252becaa9f
commit
4923c0dc8d
47
types/jsonexport/index.d.ts
vendored
Normal file
47
types/jsonexport/index.d.ts
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// Type definitions for jsonexport 3.0
|
||||
// Project: https://github.com/kaue/jsonexport
|
||||
// Definitions by: Guillaume Ongenae <https://github.com/g-ongenae>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
import { Transform } from 'stream';
|
||||
|
||||
declare namespace jsonexport {
|
||||
interface UserOptions {
|
||||
headers?: string[];
|
||||
rename?: string[];
|
||||
headerPathString?: string;
|
||||
rowDelimiter?: string;
|
||||
textDelimiter?: string;
|
||||
arrayPathString?: string;
|
||||
undefinedString?: string;
|
||||
endOfLine?: string;
|
||||
mainPathItem?: string;
|
||||
booleanTrueString?: string;
|
||||
booleanFalseString?: string;
|
||||
includeHeaders?: boolean;
|
||||
fillGaps?: boolean;
|
||||
verticalOutput?: boolean;
|
||||
forceTextDelimiter?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main declare function that converts json to csv
|
||||
*
|
||||
* @param json - object or array to convert
|
||||
* @param options - csv options
|
||||
* @param callback(err, csv) - Callback declare function
|
||||
* if error, returning error in call back.
|
||||
* if csv is created successfully, returning csv output to callback.
|
||||
*/
|
||||
declare function jsonexport(userOptions?: jsonexport.UserOptions): Transform;
|
||||
declare function jsonexport(json: object | object[], userOptions?: jsonexport.UserOptions): Promise<string>;
|
||||
declare function jsonexport(json: object | object[], cb: (err: Error, csv: string) => void): void;
|
||||
declare function jsonexport(
|
||||
json: object | object[],
|
||||
userOptions: jsonexport.UserOptions,
|
||||
cb: (err: Error, csv: string) => void,
|
||||
): void;
|
||||
|
||||
export = jsonexport;
|
||||
18
types/jsonexport/jsonexport-tests.ts
Normal file
18
types/jsonexport/jsonexport-tests.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import jsonexport = require('jsonexport');
|
||||
import { Transform } from 'stream';
|
||||
|
||||
// No user options
|
||||
const a: Transform = jsonexport();
|
||||
const b: Promise<string> = jsonexport({ key: 'value' });
|
||||
// $ExpectType void
|
||||
jsonexport({ key: 'value' }, (err: Error, csv: string) => undefined);
|
||||
|
||||
// With user options
|
||||
const userOptions: jsonexport.UserOptions = {
|
||||
textDelimiter: ';',
|
||||
};
|
||||
|
||||
const c: Transform = jsonexport(userOptions);
|
||||
const d: Promise<string> = jsonexport({ key: 'value' }, userOptions);
|
||||
// $ExpectType void
|
||||
jsonexport({ key: 'value' }, userOptions, (err: Error, csv: string) => undefined);
|
||||
16
types/jsonexport/tsconfig.json
Normal file
16
types/jsonexport/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "jsonexport-tests.ts"]
|
||||
}
|
||||
1
types/jsonexport/tslint.json
Normal file
1
types/jsonexport/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user