Skip to content
Closed

umd #292

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions browser/browser.js

This file was deleted.

1,281 changes: 1,281 additions & 0 deletions browser/csvtojson.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions browser/csvtojson.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@
"sinon": "^3.2.3",
"ts-node": "^6.0.3",
"typescript": "^2.8.3",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.16.4",
"webpack-cli": "^3.1.0"
},
Expand All @@ -298,8 +297,8 @@
"scripts": {
"dev": "tsc -w",
"build": "rm -Rf ./v2 && tsc && npm run build:browser && npm run build:browser:window",
"build:browser": "webpack --config ./webpack.config.js",
"build:browser:window": "webpack --config ./webpack.config.js --output-library-target=window --output-library=csv --output-filename=csvtojson.min.js",
"build:browser": "webpack",
"build:browser:window": "webpack -p --output-filename=csvtojson.min.js",
"test": "rm -Rf .ts-node && TS_NODE_CACHE_DIRECTORY=.ts-node mocha -r ts-node/register src/**/*.test.ts ./test/*.ts -R spec",
"travis": "nyc --reporter lcov mocha -r ts-node/register src/**/*.test.ts ./test/*.ts -R spec",
"test:debug": "mocha debug -r ts-node/register src/**/*.test.ts ./test/*.ts -R spec",
Expand Down
2 changes: 1 addition & 1 deletion v2/CSVError.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default class CSVError extends Error {
err: string;
line: number;
extra: string | undefined;
extra?: string | undefined;
static column_mismatched(index: number, extra?: string): CSVError;
static unclosed_quote(index: number, extra?: string): CSVError;
static fromJSON(obj: any): CSVError;
Expand Down
2 changes: 1 addition & 1 deletion v2/Converter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export declare class Converter extends Transform implements PromiseLike<Array<an
constructor(param?: Partial<CSVParseParam>, options?: TransformOptions);
_transform(chunk: any, encoding: string, cb: Function): void;
_flush(cb: Function): void;
private processEnd(cb);
private processEnd;
readonly parsedLineNumber: number;
}
export interface CreateReadStreamOption {
Expand Down
9 changes: 4 additions & 5 deletions v2/ProcessFork.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="bluebird" />
/// <reference types="node" />
import { Processor, ProcessLineResult } from "./Processor";
import P from "bluebird";
Expand All @@ -15,10 +14,10 @@ export declare class ProcessorFork extends Processor {
private finalChunk;
private next?;
constructor(converter: Converter);
private prepareParam(param);
private initWorker();
private flushResult();
private appendBuf(data);
private prepareParam;
private initWorker;
private flushResult;
private appendBuf;
process(chunk: Buffer): P<ProcessLineResult[]>;
}
export interface Message {
Expand Down
1 change: 0 additions & 1 deletion v2/Processor.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="node" />
/// <reference types="bluebird" />
import { Converter } from "./Converter";
import P from "bluebird";
import { JSONResult } from "./lineToJson";
Expand Down
13 changes: 6 additions & 7 deletions v2/ProcessorLocal.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="bluebird" />
/// <reference types="node" />
import { Processor, ProcessLineResult } from "./Processor";
import P from "bluebird";
Expand All @@ -13,10 +12,10 @@ export declare class ProcessorLocal extends Processor {
private _needEmitHead?;
private readonly needEmitHead;
process(chunk: Buffer, finalChunk?: boolean): P<ProcessLineResult[]>;
private processCSV(csv, finalChunk);
private processDataWithHead(lines);
private filterHeader();
private processCSVBody(lines);
private prependLeftBuf(buf);
private runPreLineHook(lines);
private processCSV;
private processDataWithHead;
private filterHeader;
private processCSVBody;
private prependLeftBuf;
private runPreLineHook;
}
1 change: 0 additions & 1 deletion v2/Result.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="bluebird" />
import { Converter } from "./Converter";
import { ProcessLineResult } from "./Processor";
import P from "bluebird";
Expand Down
10 changes: 5 additions & 5 deletions v2/rowSplit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export declare class RowSplit {
private readonly needEmitDelimiter;
constructor(conv: Converter);
parse(fileline: Fileline): RowSplitResult;
private toCSVRow(rowArr, trim, quote, delimiter);
private getDelimiter(fileline);
private isQuoteOpen(str);
private isQuoteClose(str);
private escapeQuote(segment);
private toCSVRow;
private getDelimiter;
private isQuoteOpen;
private isQuoteClose;
private escapeQuote;
parseMultiLines(lines: Fileline[]): MultipleRowResult;
}
export interface MultipleRowResult {
Expand Down
2 changes: 1 addition & 1 deletion v2/rowSplit.js.map

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

40 changes: 6 additions & 34 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ var path = require('path')
*
*/

/*
* We've enabled UglifyJSPlugin for you! This minifies your app
* in order to load faster and run less javascript.
*
* https://github.com/webpack-contrib/uglifyjs-webpack-plugin
*
*/

var UglifyJSPlugin = require('uglifyjs-webpack-plugin');




module.exports = {
module: {
rules: []
Expand All @@ -38,29 +25,14 @@ module.exports = {
entry: "./index.js",

output: {
filename: 'browser.js',
library: "csv",
filename: 'csvtojson.js',
path: path.resolve(__dirname, 'browser'),
libraryTarget: "commonjs2"
libraryTarget: "umd"
},

mode: 'production',
mode: 'development',
plugins: [
new UglifyJSPlugin(),
new webpack.IgnorePlugin(/fs/),
],
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
priority: -10,
test: /[\\/]node_modules[\\/]/
}
},

chunks: 'async',
minChunks: 1,
minSize: 30000,
name: true
}
}
}
]
}