csv-parse
Advanced tools
Comparing version 2.4.1 to 2.5.0
# Changelog | ||
## Version 2.5.0 | ||
* typescript: make definition header more relevant | ||
## Version 2.4.1 | ||
@@ -5,0 +9,0 @@ |
@@ -1,5 +0,2 @@ | ||
// Type definitions for csv-parse 1.1 | ||
// Project: https://github.com/wdavidw/node-csv-parse | ||
// Definitions by: David Muller <https://github.com/davidm77> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// Original definitions in https://github.com/DefinitelyTyped/DefinitelyTyped by: David Muller <https://github.com/davidm77> | ||
@@ -12,37 +9,88 @@ /// <reference types="node" /> | ||
declare function parse(input: string, options?: parse.Options, callback?: parse.Callback): any; | ||
declare function parse(input: string, callback?: parse.Callback): any; | ||
declare function parse(options?: parse.Options, callback?: parse.Callback): any; | ||
declare function parse(callback?: parse.Callback): any; | ||
declare function parse(input: string, options?: parse.Options, callback?: parse.Callback): parse.Parser; | ||
declare function parse(input: string, callback?: parse.Callback): parse.Parser; | ||
declare function parse(options?: parse.Options, callback?: parse.Callback): parse.Parser; | ||
declare function parse(callback?: parse.Callback): parse.Parser; | ||
declare namespace parse { | ||
type Callback = (err: any, output: any) => void; | ||
type Callback = (err: any | Error, output: any) => void; | ||
type MatcherFunc = (value: any) => boolean; | ||
interface Parser extends stream.Transform {} | ||
class Parser { | ||
constructor(options: Options); | ||
__push(line: any): any ; | ||
__push(line: any): any; | ||
__write(chars: any, end: any, callback: any): any; | ||
/** | ||
* Internal counter of records being processed. | ||
*/ | ||
readonly count: number; | ||
/** | ||
* Internal counter of empty lines | ||
*/ | ||
readonly empty_line_count: number; | ||
/** | ||
* Number of non uniform lines skipped when relax_column_count is true. | ||
*/ | ||
readonly skipped_line_count: number; | ||
/** | ||
* The number of lines encountered in the source dataset, start at 1 for the first line. | ||
*/ | ||
readonly lines: number; | ||
/** | ||
* The regular expression or function used to determine if a value should be cast to an integer. | ||
*/ | ||
readonly is_int: RegExp | MatcherFunc; | ||
/** | ||
* The regular expression or function used to determine if a value should be cast to a float. | ||
*/ | ||
readonly is_float: RegExp | MatcherFunc | ||
} | ||
interface CastingContext { | ||
column?: string; | ||
count: number; | ||
index: number; | ||
header: boolean; | ||
quoting: boolean; | ||
lines: number; | ||
} | ||
type CastingFunction = (value: string, context: CastingContext) => any; | ||
type CastingDateFunction = (value: string, context: CastingContext) => Date; | ||
interface Options { | ||
/** | ||
* Set the field delimiter. One character only, defaults to comma. | ||
* If true, the parser will attempt to convert read data types to native types. | ||
* @deprecated Use {@link cast} | ||
*/ | ||
delimiter?: string; | ||
auto_parse?: boolean | CastingFunction; | ||
/** | ||
* String used to delimit record rows or a special value; | ||
* special constants are 'auto', 'unix', 'mac', 'windows', 'unicode'; | ||
* defaults to 'auto' (discovered in source or 'unix' if no source is specified). | ||
* If true, the parser will attempt to convert read data types to dates. It requires the "auto_parse" option. | ||
* @deprecated Use {@link cast_date} | ||
*/ | ||
rowDelimiter?: string; | ||
auto_parse_date?: boolean | CastingDateFunction; | ||
/** | ||
* Optional character surrounding a field, one character only, defaults to double quotes. | ||
* If true, the parser will attempt to convert input string to native types. | ||
* If a function, receive the value as first argument, a context as second argument and return a new value. More information about the context properties is available below. | ||
*/ | ||
quote?: string | ||
cast?: boolean | CastingFunction; | ||
/** | ||
* Set the escape character, one character only, defaults to double quotes. | ||
* If true, the parser will attempt to convert input string to dates. | ||
* If a function, receive the value as argument and return a new value. It requires the "auto_parse" option. Be careful, it relies on Date.parse. | ||
*/ | ||
escape?: string | ||
cast_date?: boolean | CastingDateFunction; | ||
@@ -55,3 +103,3 @@ /** | ||
*/ | ||
columns?: any[] | boolean | ((line1: any[]) => boolean | string[]); | ||
columns?: any[] | boolean | ((line1: any) => boolean | string[]); | ||
@@ -61,23 +109,24 @@ /** | ||
*/ | ||
comment?: string | ||
comment?: string; | ||
/** | ||
* Name of header-record title to name objects by. | ||
* Set the field delimiter. One character only, defaults to comma. | ||
*/ | ||
objname?: string | ||
delimiter?: string; | ||
/** | ||
* Preserve quotes inside unquoted field. | ||
* Set the escape character, one character only, defaults to double quotes. | ||
*/ | ||
relax?: boolean | ||
escape?: string; | ||
/** | ||
* Discard inconsistent columns count, default to false. | ||
* Start returning records from a particular line. | ||
*/ | ||
relax_column_count?: boolean | ||
from?: number; | ||
/** | ||
* Dont generate empty values for empty lines. | ||
* If true, ignore whitespace immediately following the delimiter (i.e. left-trim all fields), defaults to false. | ||
* Does not remove whitespace in a quoted field. | ||
*/ | ||
skip_empty_lines?: boolean | ||
ltrim?: boolean; | ||
@@ -89,37 +138,68 @@ /** | ||
*/ | ||
max_limit_on_data_read?: number | ||
max_limit_on_data_read?: number; | ||
/** | ||
* If true, ignore whitespace immediately around the delimiter, defaults to false. | ||
* Does not remove whitespace in a quoted field. | ||
* Name of header-record title to name objects by. | ||
*/ | ||
trim?: boolean | ||
objname?: string; | ||
/** | ||
* If true, ignore whitespace immediately following the delimiter (i.e. left-trim all fields), defaults to false. | ||
* Does not remove whitespace in a quoted field. | ||
* Optional character surrounding a field, one character only, defaults to double quotes. | ||
*/ | ||
ltrim?: boolean | ||
quote?: string | boolean; | ||
/** | ||
* Preserve quotes inside unquoted field. | ||
*/ | ||
relax?: boolean; | ||
/** | ||
* Discard inconsistent columns count, default to false. | ||
*/ | ||
relax_column_count?: boolean; | ||
/** | ||
* Generate two properties raw and row where raw is the original CSV row content and row is the parsed array or object. | ||
*/ | ||
raw?: boolean; | ||
/** | ||
* One or multiple characters used to delimit record rows; defaults to auto discovery if not provided. | ||
* Supported auto discovery method are Linux ("\n"), Apple ("\r") and Windows ("\r\n") row delimiters. | ||
*/ | ||
rowDelimiter?: string | string[]; | ||
/** | ||
* If true, ignore whitespace immediately preceding the delimiter (i.e. right-trim all fields), defaults to false. | ||
* Does not remove whitespace in a quoted field. | ||
*/ | ||
rtrim?: boolean | ||
rtrim?: boolean; | ||
/** | ||
* If true, the parser will attempt to convert read data types to native types. | ||
* Dont generate empty values for empty lines. | ||
* Defaults to false | ||
*/ | ||
auto_parse?: boolean | ||
skip_empty_lines?: boolean; | ||
/** | ||
* If true, the parser will attempt to convert read data types to dates. It requires the "auto_parse" option. | ||
* Skip a line with error found inside and directly go process the next line. | ||
*/ | ||
auto_parse_date?: boolean | ||
} | ||
skip_lines_with_error?: boolean; | ||
// TODO: what is this for? | ||
interface ParserStream extends NodeJS.ReadWriteStream { | ||
read(size?: number): any & string[]; | ||
/** | ||
* Don't generate records for lines containing empty column values (column matching /\s*\/), defaults to false. | ||
*/ | ||
skip_lines_with_empty_values?: boolean; | ||
/** | ||
* Stop returning records after a particular line. | ||
*/ | ||
to?: number; | ||
/** | ||
* If true, ignore whitespace immediately around the delimiter, defaults to false. | ||
* Does not remove whitespace in a quoted field. | ||
*/ | ||
trim?: boolean; | ||
} | ||
} |
{ | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"name": "csv-parse", | ||
@@ -56,3 +56,4 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API", | ||
"test": "mocha test/**/*.coffee" | ||
} | ||
}, | ||
"types": "./lib/index.d.ts" | ||
} |
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
73607
22
1773