Skip to content

Commit 3fb3a71

Browse files
committed
feat: updated deprecated code
1 parent 6720684 commit 3fb3a71

7 files changed

Lines changed: 36 additions & 20 deletions

File tree

.idea/.gitignore

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/node-csvtojson.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/csvtojson.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function csvtojson() {
4343
}
4444
function stringToRegExp(str) {
4545
var lastSlash = str.lastIndexOf("/");
46-
var source = str.substring(1, lastSlash);
47-
var flag = str.substring(lastSlash + 1);
46+
var source = str.substr(1, lastSlash);
47+
var flag = str.substr(lastSlash + 1);
4848
return new RegExp(source,flag);
4949
}
5050
function parse() {

src/Converter.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@ import { Transform, TransformOptions, Readable } from "stream";
22
import { CSVParseParam, mergeParams } from "./Parameters";
33
import { ParseRuntime, initParseRuntime } from "./ParseRuntime";
44
import P from "bluebird";
5-
import { stringToLines } from "./fileline";
6-
import { map } from "lodash/map";
7-
import { RowSplit, RowSplitResult } from "./rowSplit";
8-
import getEol from "./getEol";
9-
import lineToJson, { JSONResult } from "./lineToJson";
10-
import { Processor, ProcessLineResult } from "./Processor";
11-
// import { ProcessorFork } from "./ProcessFork";
5+
import { Processor } from "./Processor";
126
import { ProcessorLocal } from "./ProcessorLocal";
137
import { Result } from "./Result";
148
import CSVError from "./CSVError";
15-
import { bufFromString } from "./util";
16-
17-
189

1910
export class Converter extends Transform implements PromiseLike<any[]> {
2011
preRawData(onRawData: PreRawDataCallback): Converter {
@@ -38,12 +29,6 @@ export class Converter extends Transform implements PromiseLike<any[]> {
3829
}
3930
fromFile(filePath: string, options?: string | CreateReadStreamOption | undefined): Converter {
4031
const fs = require("fs");
41-
// var rs = null;
42-
// this.wrapCallback(cb, function () {
43-
// if (rs && rs.destroy) {
44-
// rs.destroy();
45-
// }
46-
// });
4732
fs.exists(filePath, (exist) => {
4833
if (exist) {
4934
const rs = fs.createReadStream(filePath, options);
@@ -66,7 +51,7 @@ export class Converter extends Transform implements PromiseLike<any[]> {
6651
if (idx >= csvString.length) {
6752
this.push(null);
6853
} else {
69-
const str = csvString.substr(idx, size);
54+
const str = csvString.substring(idx, idx + size);
7055
this.push(str);
7156
idx += size;
7257
}

src/rowSplit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class RowSplit {
6969
} else if (this.isQuoteOpen(e)) { //quote open
7070
e = e.substr(1);
7171
if (this.isQuoteClose(e)) { //quote close
72-
e = e.substring(0, e.lastIndexOf(quote));
72+
e = e.substr(0, e.lastIndexOf(quote));
7373
e = this.escapeQuote(e);
7474
row.push(e);
7575
continue;

0 commit comments

Comments
 (0)