fix(repo structure): update to latest standards
This commit is contained in:
parent
3f52942987
commit
bfa20f38bd
16
dist/index.d.ts
vendored
16
dist/index.d.ts
vendored
@ -1,16 +0,0 @@
|
||||
export interface ICsvConstructorOptions {
|
||||
headers: boolean;
|
||||
}
|
||||
export declare class Csv {
|
||||
static createCsvFromString(csvStringArg: string, options: ICsvConstructorOptions): Promise<Csv>;
|
||||
csvString: string;
|
||||
headers: string[];
|
||||
keyFrame: string;
|
||||
options: ICsvConstructorOptions;
|
||||
determineKeyframe(): void;
|
||||
serializeCsvString(): any[];
|
||||
getRows(): string[];
|
||||
getHeaders(): string[];
|
||||
createDataObject(dataArray: string[]): any;
|
||||
exportAsObject(): Promise<any>;
|
||||
}
|
88
dist/index.js
vendored
88
dist/index.js
vendored
@ -1,88 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Csv {
|
||||
constructor() {
|
||||
this.keyFrame = null;
|
||||
this.options = {
|
||||
headers: true
|
||||
};
|
||||
}
|
||||
static createCsvFromString(csvStringArg, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const csvInstance = new Csv();
|
||||
csvInstance.csvString = csvStringArg;
|
||||
csvInstance.determineKeyframe();
|
||||
return csvInstance;
|
||||
});
|
||||
}
|
||||
determineKeyframe() {
|
||||
let commaLength = 0;
|
||||
let semicolonLength = 0;
|
||||
const commaRegexResult = this.csvString.match(/,/g);
|
||||
const semicolonRegexResult = this.csvString.match(/;/g);
|
||||
if (commaRegexResult) {
|
||||
commaLength = commaRegexResult.length;
|
||||
}
|
||||
if (semicolonRegexResult) {
|
||||
semicolonLength = semicolonRegexResult.length;
|
||||
}
|
||||
// tslint:disable-next-line:prefer-conditional-expression
|
||||
if (commaLength < semicolonLength) {
|
||||
this.keyFrame = ';';
|
||||
}
|
||||
else {
|
||||
this.keyFrame = ',';
|
||||
}
|
||||
}
|
||||
serializeCsvString() {
|
||||
const rowArray = this.getRows();
|
||||
const resultArray = [];
|
||||
if (this.options.headers) {
|
||||
this.getHeaders();
|
||||
rowArray.shift();
|
||||
}
|
||||
for (const row of rowArray) {
|
||||
resultArray.push(row.split(this.keyFrame));
|
||||
}
|
||||
return resultArray;
|
||||
}
|
||||
getRows() {
|
||||
return this.csvString.split('\n');
|
||||
}
|
||||
getHeaders() {
|
||||
const rowArray = this.getRows();
|
||||
if (this.options.headers) {
|
||||
let headerRow = rowArray[0];
|
||||
this.headers = headerRow.split(this.keyFrame);
|
||||
}
|
||||
return this.headers;
|
||||
}
|
||||
createDataObject(dataArray) {
|
||||
const neededIterations = dataArray.length;
|
||||
let resultJson = {};
|
||||
for (let i = 0; i < neededIterations; i++) {
|
||||
resultJson[this.headers[i]] = dataArray[i];
|
||||
}
|
||||
return resultJson;
|
||||
}
|
||||
exportAsObject() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const serializedData = this.serializeCsvString();
|
||||
const dataObjects = [];
|
||||
for (const dataArray of serializedData) {
|
||||
dataObjects.push(this.createDataObject(dataArray));
|
||||
}
|
||||
return dataObjects;
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.Csv = Csv;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBTUE7SUFBQTt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yxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsZ0JBQWdCLEVBQUUsQ0FBQyxFQUFFLEVBQUU7WUFDekMsVUFBVSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDNUM7UUFDRCxPQUFPLFVBQVUsQ0FBQztJQUNwQixDQUFDO0lBRVksY0FBYzs7WUFDekIsTUFBTSxjQUFjLEdBQUcsSUFBSSxDQUFDLGtCQUFrQixFQUFFLENBQUM7WUFDakQsTUFBTSxXQUFXLEdBQUcsRUFBRSxDQUFDO1lBQ3ZCLEtBQUssTUFBTSxTQUFTLElBQUksY0FBYyxFQUFFO2dCQUN0QyxXQUFXLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDO2FBQ3BEO1lBQ0QsT0FBTyxXQUFXLENBQUM7UUFDckIsQ0FBQztLQUFBO0NBQ0Y7QUFoRkQsa0JBZ0ZDIn0=
|
2
dist/smartcsv.plugins.d.ts
vendored
2
dist/smartcsv.plugins.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
import * as smartq from 'smartq';
|
||||
export { smartq };
|
5
dist/smartcsv.plugins.js
vendored
5
dist/smartcsv.plugins.js
vendored
@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const smartq = require("smartq");
|
||||
exports.smartq = smartq;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjc3YucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y3N2LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxpQ0FBaUM7QUFFeEIsd0JBQU0ifQ==
|
@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "@pushrocks/smartcsv",
|
||||
"version": "1.0.5",
|
||||
"description": "handle csv data",
|
||||
"description": "handle csv data | gitzone standard compliant",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(ts-node -O '{\"lib\": [ \"es2015\" ]}' test/test.ts)",
|
||||
"build": "(npmts)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user