@types/d3-dsv
Advanced tools
Comparing version 1.0.34 to 1.0.35
@@ -18,12 +18,21 @@ // Type definitions for D3JS d3-dsv module 1.0 | ||
* An object representing a DSV parsed row with values represented as strings. | ||
* When the DSV content is not well-structured and some column-values are missing, `undefined` is used as value. | ||
*/ | ||
export interface DSVRowString { | ||
[key: string]: string | undefined; | ||
} | ||
export type DSVRowString<Columns extends string = string> = { | ||
[key in Columns]: string | undefined; | ||
}; | ||
/** | ||
* An object in raw format before parsing, that is with only string values. | ||
* When the DSV content is not well-structured and some column-values are missing, `undefined` is used as value. | ||
*/ | ||
export type DSVRaw<T extends object> = { | ||
[key in keyof T]: string | undefined; | ||
}; | ||
/** | ||
* An object representing a DSV parsed row with values represented as an arbitrary datatype, depending | ||
* on the performed parsed row mapping. | ||
* | ||
* @deprecated | ||
* @deprecated Use `object` instead. | ||
*/ | ||
@@ -35,2 +44,13 @@ export interface DSVRowAny { | ||
/** | ||
* An array object representing all deserialized rows. The array is enhanced with a property listing | ||
* the names of the parsed columns. | ||
*/ | ||
export interface DSVRowArray<Columns extends string = string> extends Array<DSVRowString<Columns>> { | ||
/** | ||
* List of column names. | ||
*/ | ||
columns: Columns[]; | ||
} | ||
/** | ||
* An array object representing all parsed rows. The array is enhanced with a property listing | ||
@@ -43,3 +63,3 @@ * the names of the parsed columns. | ||
*/ | ||
columns: string[]; | ||
columns: Array<keyof T>; | ||
} | ||
@@ -61,7 +81,8 @@ | ||
* | ||
* Equivalent to dsvFormat(",").parse. | ||
* Equivalent to `dsvFormat(",").parse`. | ||
* | ||
* @param csvString A string, which must be in the comma-separated values format. | ||
*/ | ||
export function csvParse(csvString: string): DSVParsedArray<DSVRowString>; | ||
// tslint:disable-next-line:no-unnecessary-generics | ||
export function csvParse<Columns extends string>(csvString: string): DSVRowArray<Columns>; | ||
/** | ||
@@ -75,3 +96,3 @@ * Parses the specified string, which must be in the comma-separated values format, returning an array of objects representing the parsed rows. | ||
* | ||
* Equivalent to dsvFormat(",").parse. | ||
* Equivalent to `dsvFormat(",").parse`. | ||
* | ||
@@ -84,5 +105,5 @@ * @param csvString A string, which must be in the comma-separated values format. | ||
*/ | ||
export function csvParse<ParsedRow extends object>( | ||
export function csvParse<ParsedRow extends object, Columns extends string>( | ||
csvString: string, | ||
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null | ||
row: (rawRow: DSVRowString<Columns>, index: number, columns: Columns[]) => ParsedRow | undefined | null | ||
): DSVParsedArray<ParsedRow>; | ||
@@ -101,3 +122,3 @@ | ||
* | ||
* Equivalent to dsvFormat(",").parseRows. | ||
* Equivalent to `dsvFormat(",").parseRows`. | ||
* | ||
@@ -113,3 +134,3 @@ * @param csvString A string, which must be in the comma-separated values format. | ||
* | ||
* Equivalent to dsvFormat(",").parseRows. | ||
* Equivalent to `dsvFormat(",").parseRows`. | ||
* | ||
@@ -138,3 +159,3 @@ * @param csvString A string, which must be in the comma-separated values format. | ||
* | ||
* Equivalent to dsvFormat(",").format. | ||
* Equivalent to `dsvFormat(",").format`. | ||
* | ||
@@ -157,3 +178,3 @@ * @param rows Array of object rows. | ||
* | ||
* Equivalent to dsvFormat(",").formatRows. | ||
* Equivalent to `dsvFormat(",").formatRows`. | ||
* | ||
@@ -178,7 +199,8 @@ * @param rows An array of array of string rows. | ||
* | ||
* Equivalent to dsvFormat("\t").parse. | ||
* Equivalent to `dsvFormat("\t").parse`. | ||
* | ||
* @param tsvString A string, which must be in the tab-separated values format. | ||
*/ | ||
export function tsvParse(tsvString: string): DSVParsedArray<DSVRowString>; | ||
// tslint:disable-next-line:no-unnecessary-generics | ||
export function tsvParse<Columns extends string>(tsvString: string): DSVRowArray<Columns>; | ||
/** | ||
@@ -192,3 +214,3 @@ * Parses the specified string, which must be in the tab-separated values format, returning an array of objects representing the parsed rows. | ||
* | ||
* Equivalent to dsvFormat("\t").parse. | ||
* Equivalent to `dsvFormat("\t").parse`. | ||
* | ||
@@ -201,6 +223,6 @@ * @param tsvString A string, which must be in the tab-separated values format. | ||
*/ | ||
export function tsvParse<MappedRow extends object>( | ||
export function tsvParse<ParsedRow extends object, Columns extends string>( | ||
tsvString: string, | ||
row: (rawRow: DSVRowString, index: number, columns: string[]) => MappedRow | undefined | null | ||
): DSVParsedArray<MappedRow>; | ||
row: (rawRow: DSVRowString<Columns>, index: number, columns: Columns[]) => ParsedRow | undefined | null | ||
): DSVParsedArray<ParsedRow>; | ||
@@ -218,3 +240,3 @@ // tsvParseRows(...) ======================================================================== | ||
* | ||
* Equivalent to dsvFormat("\t").parseRows. | ||
* Equivalent to `dsvFormat("\t").parseRows`. | ||
* | ||
@@ -230,3 +252,3 @@ * @param tsvString A string, which must be in the tab-separated values format. | ||
* | ||
* Equivalent to dsvFormat("\t").parseRows. | ||
* Equivalent to `dsvFormat("\t").parseRows`. | ||
* | ||
@@ -239,6 +261,6 @@ * @param tsvString A string, which must be in the tab-separated values format. | ||
*/ | ||
export function tsvParseRows<MappedRow extends object>( | ||
export function tsvParseRows<ParsedRow extends object>( | ||
tsvString: string, | ||
row: (rawRow: string[], index: number) => MappedRow | undefined | null | ||
): MappedRow[]; | ||
row: (rawRow: string[], index: number) => ParsedRow | undefined | null | ||
): ParsedRow[]; | ||
@@ -256,3 +278,3 @@ // tsvFormat(...) ============================================================================ | ||
* | ||
* Equivalent to dsvFormat("\t").format. | ||
* Equivalent to `dsvFormat("\t").format`. | ||
* | ||
@@ -275,3 +297,3 @@ * @param rows Array of object rows. | ||
* | ||
* Equivalent to dsvFormat("\t").formatRows. | ||
* Equivalent to `dsvFormat("\t").formatRows`. | ||
* | ||
@@ -300,3 +322,4 @@ * @param rows An array of array of string rows. | ||
*/ | ||
parse(dsvString: string): DSVParsedArray<DSVRowString>; | ||
// tslint:disable-next-line:no-unnecessary-generics | ||
parse<Columns extends string>(dsvString: string): DSVRowArray<Columns>; | ||
/** | ||
@@ -316,5 +339,5 @@ * Parses the specified string, which must be in the delimiter-separated values format with the appropriate delimiter, returning an array of objects representing the parsed rows. | ||
*/ | ||
parse<ParsedRow extends object>( | ||
parse<ParsedRow extends object, Columns extends string>( | ||
dsvString: string, | ||
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null | ||
row: (rawRow: DSVRowString<Columns>, index: number, columns: Columns[]) => ParsedRow | undefined | null | ||
): DSVParsedArray<ParsedRow>; | ||
@@ -321,0 +344,0 @@ |
{ | ||
"name": "@types/d3-dsv", | ||
"version": "1.0.34", | ||
"version": "1.0.35", | ||
"description": "TypeScript definitions for D3JS d3-dsv module", | ||
@@ -36,4 +36,4 @@ "license": "MIT", | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "2f2217a992671ed51f3489eebb8e968407f8790d1a80f371e3c04a935f2e8119", | ||
"typesPublisherContentHash": "0acb116e698aa51c37d4bfefbb03fc9b0558729bc0092bc487d608c1543c0ce7", | ||
"typeScriptVersion": "2.3" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Thu, 15 Nov 2018 02:17:52 GMT | ||
* Last updated: Wed, 02 Jan 2019 22:37:55 GMT | ||
* Dependencies: none | ||
@@ -14,0 +14,0 @@ * Global values: none |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24833
357