[csv-parse] Remove package (#35378)

This commit is contained in:
Florian Keller
2019-05-17 09:29:09 -07:00
committed by Nathan Shively-Sanders
parent 9d83c3f085
commit 590d20bc54
6 changed files with 6 additions and 223 deletions
+6
View File
@@ -582,6 +582,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/crypto-random-string",
"asOfVersion": "2.0.0"
},
{
"libraryName": "csv-parse",
"typingsPackageName": "csv-parse",
"sourceRepoURL": "https://github.com/adaltas/node-csv-parse",
"asOfVersion": "1.2.2"
},
{
"libraryName": "cycled",
"typingsPackageName": "cycled",
-58
View File
@@ -1,58 +0,0 @@
import parse = require('csv-parse');
function callbackAPITest() {
const input = '#Welcome\n"1","2","3","4"\n"a","b","c","d"';
parse(input, {comment: '#'}, (err, output) => {
output.should.eql([ [ '1', '2', '3', '4' ], [ 'a', 'b', 'c', 'd' ] ]);
});
}
function streamAPITest() {
const output: string[][] = [];
// Create the parser
const parser = parse({delimiter: ':'});
// Use the writable stream api
parser.on('readable', () => {
while (true) {
const record = parser.read();
if (!record) break;
output.push(record);
}
});
// Catch any error
parser.on('error', (err: any) => {
console.log(err.message);
});
parser.on('finish', () => {
console.log(output);
});
// Now that setup is done, write data to the stream
parser.write("root:x:0:0:root:/root:/bin/bash\n");
parser.write("someone:x:1022:1022:a funny cat:/home/someone:/bin/bash\n");
// Close the readable stream
parser.end();
}
import fs = require('fs');
function pipeFunctionTest() {
const transform = require('stream-transform');
const output: any = [];
const parser = parse({delimiter: ':'});
const input = fs.createReadStream('/etc/passwd');
const transformer = transform((record: any[], callback: any) => {
setTimeout(() => {
callback(null, record.join(' ') + '\n');
}, 500);
}, {parallel: 10});
input.pipe(parser).pipe(transformer).pipe(process.stdout);
}
import parseSync = require('csv-parse/lib/sync');
function syncApiTest() {
const input = '"key_1","key_2"\n"value 1","value 2"';
const records = parseSync(input, {columns: true});
records.should.eql([{ key_1: 'value 1', key_2: 'value 2' }]);
}
-131
View File
@@ -1,131 +0,0 @@
// Type definitions for csv-parse 1.1
// Project: https://github.com/wdavidw/node-csv-parse, https://csv.js.org/parse
// Definitions by: David Muller <https://github.com/davidm77>
// Jan Sziegaud <https://github.com/obi-jan-kenobi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as stream from "stream";
export = parse;
declare function parse(input: string, options?: parse.Options, callback?: parse.Callback): any;
declare function parse(options?: parse.Options, callback?: parse.Callback): any;
declare function parse(callback?: parse.Callback): any;
declare namespace parse {
type Callback = (err: any, output: any) => void;
interface Parser extends stream.Transform {}
class Parser {
constructor(options: Options);
__push(line: any): any ;
__write(chars: any, end: any, callback: any): any;
}
interface Options {
/**
* Set the field delimiter. One character only, defaults to comma.
*/
delimiter?: string;
/**
* 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).
*/
rowDelimiter?: string;
/**
* Optional character surrounding a field, one character only, defaults to double quotes.
*/
quote?: string;
/**
* Set the escape character, one character only, defaults to double quotes.
*/
escape?: string;
/**
* List of fields as an array,
* a user defined callback accepting the first line and returning the column names or true if autodiscovered in the first CSV line,
* default to null,
* affect the result data set in the sense that records will be objects instead of arrays.
*/
columns?: any[] | boolean | ((line1: any[]) => boolean | string[]);
/**
* Treat all the characters after this one as a comment, default to '' (disabled).
*/
comment?: string;
/**
* Name of header-record title to name objects by.
*/
objname?: string;
/**
* Preserve quotes inside unquoted field.
*/
relax?: boolean;
/**
* Discard inconsistent columns count, default to false.
*/
relax_column_count?: boolean;
/**
* Dont generate empty values for empty lines.
*/
skip_empty_lines?: boolean;
/**
* Maximum numer of characters to be contained in the field and line buffers before an exception is raised,
* used to guard against a wrong delimiter or rowDelimiter,
* default to 128000 characters.
*/
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.
*/
trim?: boolean;
/**
* 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.
*/
ltrim?: boolean;
/**
* 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;
/**
* If true, the parser will attempt to convert read data types to native types.
*/
auto_parse?: boolean;
/**
* If true, the parser will attempt to convert read data types to dates. It requires the "auto_parse" option.
*/
auto_parse_date?: boolean;
/**
* Start returning records from a particular line.
*/
from?: number;
/**
* Stop returning records after a particular line.
*/
to?: number;
}
// TODO: what is this for?
interface ParserStream extends NodeJS.ReadWriteStream {
read(size?: number): any & string[];
}
}
-4
View File
@@ -1,4 +0,0 @@
import { Options } from "..";
declare function parse(input: string, options?: Options): any;
export = parse;
-24
View File
@@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"lib/sync.d.ts",
"csv-parse-tests.ts"
]
}
-6
View File
@@ -1,6 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-empty-interface": false
}
}