Skip to content

Commit

Permalink
feat: updated deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
dogabudak committed Apr 18, 2023
1 parent 6720684 commit 3fb3a71
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/node-csvtojson.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bin/csvtojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function csvtojson() {
}
function stringToRegExp(str) {
var lastSlash = str.lastIndexOf("/");
var source = str.substring(1, lastSlash);
var flag = str.substring(lastSlash + 1);
var source = str.substr(1, lastSlash);
var flag = str.substr(lastSlash + 1);
return new RegExp(source,flag);
}
function parse() {
Expand Down
19 changes: 2 additions & 17 deletions src/Converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ import { Transform, TransformOptions, Readable } from "stream";
import { CSVParseParam, mergeParams } from "./Parameters";
import { ParseRuntime, initParseRuntime } from "./ParseRuntime";
import P from "bluebird";
import { stringToLines } from "./fileline";
import { map } from "lodash/map";
import { RowSplit, RowSplitResult } from "./rowSplit";
import getEol from "./getEol";
import lineToJson, { JSONResult } from "./lineToJson";
import { Processor, ProcessLineResult } from "./Processor";
// import { ProcessorFork } from "./ProcessFork";
import { Processor } from "./Processor";
import { ProcessorLocal } from "./ProcessorLocal";
import { Result } from "./Result";
import CSVError from "./CSVError";
import { bufFromString } from "./util";



export class Converter extends Transform implements PromiseLike<any[]> {
preRawData(onRawData: PreRawDataCallback): Converter {
Expand All @@ -38,12 +29,6 @@ export class Converter extends Transform implements PromiseLike<any[]> {
}
fromFile(filePath: string, options?: string | CreateReadStreamOption | undefined): Converter {
const fs = require("fs");
// var rs = null;
// this.wrapCallback(cb, function () {
// if (rs && rs.destroy) {
// rs.destroy();
// }
// });
fs.exists(filePath, (exist) => {
if (exist) {
const rs = fs.createReadStream(filePath, options);
Expand All @@ -66,7 +51,7 @@ export class Converter extends Transform implements PromiseLike<any[]> {
if (idx >= csvString.length) {
this.push(null);
} else {
const str = csvString.substr(idx, size);
const str = csvString.substring(idx, idx + size);
this.push(str);
idx += size;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rowSplit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class RowSplit {
} else if (this.isQuoteOpen(e)) { //quote open
e = e.substr(1);
if (this.isQuoteClose(e)) { //quote close
e = e.substring(0, e.lastIndexOf(quote));
e = e.substr(0, e.lastIndexOf(quote));
e = this.escapeQuote(e);
row.push(e);
continue;
Expand Down

0 comments on commit 3fb3a71

Please sign in to comment.