本文整理匯總了TypeScript中csv-stringify類的典型用法代碼示例。如果您正苦於以下問題:TypeScript csv-stringify類的具體用法?TypeScript csv-stringify怎麽用?TypeScript csv-stringify使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了csv-stringify類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createWriteStream
static createWriteStream(dest: string, opts: WriteOptions = {}): CSVWriteStream {
if (!opts.delimiter) opts.delimiter = this.getDefaultDelimiter(dest);
const stringifyOptions = this.getStringifyOptions(opts);
const stringifyTransform = stringify(stringifyOptions);
stringifyTransform.pipe(createWriteStream(dest));
return stringifyTransform;
}
示例2: csvStringify
return new Promise<string>((resolve, reject) => {
csvStringify(rows, (error, output) => {
if (error) {
reject(error);
} else {
resolve(output);
}
});
});
示例3: write
static write(dest: string, data: any[], arg1: any, arg2?: any): void {
const writeOptions = arg2 ? arg1 : {};
const cb = arg2 ? arg2 : arg1;
if (!writeOptions.delimiter) writeOptions.delimiter = this.getDefaultDelimiter(dest);
const stringifyOptions = this.getStringifyOptions(writeOptions, data);
const nestedArrayData = this.getNestedArrayData(data, stringifyOptions.columns);
stringify(nestedArrayData, stringifyOptions, (err, stringData) => {
if (err) { return cb(err); }
writeFile(dest, stringData, cb);
});
}
示例4: csvStringify
services.history.onNewRecord.subscribe(record => csvStringify(
[Object.values(record)],
(_error, output) => appendFileSync(historyFilePath, output),
));
示例5: stringify
static stringify(data: any[], opts: WriteOptions, cb: ResultCb<string>) {
if (!opts.delimiter) opts.delimiter = ',';
const stringifyOptions = this.getStringifyOptions(opts, data);
const nestedArrayData = this.getNestedArrayData(data, stringifyOptions.columns);
stringify(nestedArrayData, stringifyOptions, cb);
}