fix(refactor): update static function/constructor responsibilities

This commit is contained in:
Philipp Kunz 2018-10-14 23:26:54 +02:00
parent feb41df3e2
commit 56d7ae8952
3 changed files with 70 additions and 60 deletions

104
package-lock.json generated
View File

@ -28,9 +28,9 @@
} }
}, },
"@gitzone/tsrun": { "@gitzone/tsrun": {
"version": "1.1.12", "version": "1.1.13",
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.12.tgz", "resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.13.tgz",
"integrity": "sha512-DOxqOg+evoxhgbzhzH4u6LaPF+6bpMsnBVl1QQaHzKPGBlNjaIY4yJ0RsGnWMgX1hlNLvbgHtl0Ky4A2MDvyrg==", "integrity": "sha512-yJLXfqu33zGc1hBX4HGxzlBvb5DU2zs80MUd8UsULJvkgOBofb3XR7eyV7iZfP097sd+ABj17yoeqJcRRjOZTg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.0.22",
@ -84,14 +84,14 @@
} }
}, },
"@pushrocks/smartfile": { "@pushrocks/smartfile": {
"version": "6.0.6", "version": "6.0.8",
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz", "resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.8.tgz",
"integrity": "sha512-vA1+yS6n0kuBZ+Bl30rxOCYvgIj0mo9g303cUpOZR0I781iQVWHcBKRC05FaGDxJD1HuYdvbSK+7vlrzZjVcMw==", "integrity": "sha512-YkAovvQ0pcVphXLynlQ1D4nhEoUqALqqUn2pRXc2vXNy0RDSU22puLlLVhoXT0NPAqYNMazhqc4OAixgEOpdFw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@pushrocks/smartpath": "^4.0.1", "@pushrocks/smartpath": "^4.0.1",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartrequest": "^1.1.12", "@pushrocks/smartrequest": "^1.1.14",
"@types/fs-extra": "^5.0.4", "@types/fs-extra": "^5.0.4",
"@types/vinyl": "^2.0.2", "@types/vinyl": "^2.0.2",
"fs-extra": "^7.0.0", "fs-extra": "^7.0.0",
@ -149,9 +149,9 @@
} }
}, },
"@pushrocks/tapbundle": { "@pushrocks/tapbundle": {
"version": "3.0.5", "version": "3.0.7",
"resolved": "https://registry.npmjs.org/@pushrocks/tapbundle/-/tapbundle-3.0.5.tgz", "resolved": "https://registry.npmjs.org/@pushrocks/tapbundle/-/tapbundle-3.0.7.tgz",
"integrity": "sha512-7K1y4pyJ5O8XRmnW/ADryEoniGKOW0Un6VZpxMcYTndS5AjwKhjRkAAaSQf4g/a8Ei+uk/q8csI9Twjb9KISLQ==", "integrity": "sha512-ZI4fhXPy8XMfiy/QofP0ZDuFdv3cErm+FP/+AXaNKdgCCx01MXNTYSUdER1GPUXW3ZbiXdurkLJlxlhIzD1ZJw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@pushrocks/early": "^3.0.3", "@pushrocks/early": "^3.0.3",
@ -162,9 +162,9 @@
} }
}, },
"@types/chai": { "@types/chai": {
"version": "4.1.4", "version": "4.1.6",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.6.tgz",
"integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", "integrity": "sha512-CBk7KTZt3FhPsEkYioG6kuCIpWISw+YI8o+3op4+NXwTpvAPxE1ES8+PY8zfaK2L98b1z5oq03UHa4VYpeUxnw==",
"dev": true "dev": true
}, },
"@types/chai-as-promised": { "@types/chai-as-promised": {
@ -178,7 +178,7 @@
}, },
"@types/chai-string": { "@types/chai-string": {
"version": "1.4.1", "version": "1.4.1",
"resolved": "https://registry.npmjs.org/@types/chai-string/-/chai-string-1.4.1.tgz", "resolved": "http://registry.npmjs.org/@types/chai-string/-/chai-string-1.4.1.tgz",
"integrity": "sha512-aRNMs6TKgjgPlCHwDfq/YNy5VtRR2hJ4AUWByddrT0TRVVD8eX4MiHW6/iHvmQHRlVuuPZcwnTUE7b4yFt7bEA==", "integrity": "sha512-aRNMs6TKgjgPlCHwDfq/YNy5VtRR2hJ4AUWByddrT0TRVVD8eX4MiHW6/iHvmQHRlVuuPZcwnTUE7b4yFt7bEA==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -210,9 +210,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "10.7.1", "version": "10.11.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.11.7.tgz",
"integrity": "sha512-EGoI4ylB/lPOaqXqtzAyL8HcgOuCtH2hkEaLmkueOYufsTFWBn4VCvlCDC2HW8Q+9iF+QVC3sxjDKQYjHQeZ9w==", "integrity": "sha512-yOxFfkN9xUFLyvWaeYj90mlqTJ41CsQzWKS3gXdOMOyPVacUsymejKxJ4/pMW7exouubuEeZLJawGgcNGYlTeg==",
"dev": true "dev": true
}, },
"@types/vinyl": { "@types/vinyl": {
@ -292,17 +292,17 @@
"dev": true "dev": true
}, },
"chai": { "chai": {
"version": "4.1.2", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",
"integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==",
"dev": true, "dev": true,
"requires": { "requires": {
"assertion-error": "^1.0.1", "assertion-error": "^1.1.0",
"check-error": "^1.0.1", "check-error": "^1.0.2",
"deep-eql": "^3.0.0", "deep-eql": "^3.0.1",
"get-func-name": "^2.0.0", "get-func-name": "^2.0.0",
"pathval": "^1.0.0", "pathval": "^1.1.0",
"type-detect": "^4.0.0" "type-detect": "^4.0.5"
} }
}, },
"chai-as-promised": { "chai-as-promised": {
@ -315,9 +315,9 @@
} }
}, },
"chai-string": { "chai-string": {
"version": "1.4.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.4.0.tgz", "resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.5.0.tgz",
"integrity": "sha1-NZFAwFHTak5LGl/GuRAVL0OKjUk=", "integrity": "sha512-sydDC3S3pNAQMYwJrs6dQX0oBQ6KfIPuOZ78n7rocW0eJJlsHPh2t3kwW7xfwYA/1Bf6/arGtSUo16rxR2JFlw==",
"dev": true "dev": true
}, },
"check-error": { "check-error": {
@ -357,7 +357,7 @@
}, },
"combined-stream": { "combined-stream": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -468,9 +468,9 @@
"dev": true "dev": true
}, },
"glob": { "glob": {
"version": "7.1.2", "version": "7.1.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"fs.realpath": "^1.0.0", "fs.realpath": "^1.0.0",
@ -560,24 +560,24 @@
"dev": true "dev": true
}, },
"make-error": { "make-error": {
"version": "1.3.4", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
"integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==", "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
"dev": true "dev": true
}, },
"mime-db": { "mime-db": {
"version": "1.35.0", "version": "1.36.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz",
"integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==", "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==",
"dev": true "dev": true
}, },
"mime-types": { "mime-types": {
"version": "2.1.19", "version": "2.1.20",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz",
"integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==",
"dev": true, "dev": true,
"requires": { "requires": {
"mime-db": "~1.35.0" "mime-db": "~1.36.0"
} }
}, },
"minimatch": { "minimatch": {
@ -591,13 +591,13 @@
}, },
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true "dev": true
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -606,16 +606,16 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true "dev": true
} }
} }
}, },
"nan": { "nan": {
"version": "2.10.0", "version": "2.11.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==",
"dev": true "dev": true
}, },
"once": { "once": {
@ -659,7 +659,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -711,9 +711,9 @@
"dev": true "dev": true
}, },
"source-map-support": { "source-map-support": {
"version": "0.5.8", "version": "0.5.9",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.8.tgz", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz",
"integrity": "sha512-WqAEWPdb78u25RfKzOF0swBpY0dKrNdjc4GvLwm7ScX/o9bj8Eh/YL8mcMhBHYDGl87UkkSXDOFnW4G7GhWhGg==", "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==",
"dev": true, "dev": true,
"requires": { "requires": {
"buffer-from": "^1.0.0", "buffer-from": "^1.0.0",

View File

@ -14,11 +14,11 @@
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.12", "@gitzone/tsrun": "^1.1.13",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.15",
"@pushrocks/smartfile": "^6.0.6", "@pushrocks/smartfile": "^6.0.8",
"@pushrocks/tapbundle": "^3.0.5", "@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.7.1" "@types/node": "^10.11.7"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^2.0.5" "@pushrocks/smartpromise": "^2.0.5"

View File

@ -7,11 +7,9 @@ export interface ICsvConstructorOptions {
export class Csv { export class Csv {
public static async createCsvFromString( public static async createCsvFromString(
csvStringArg: string, csvStringArg: string,
options: ICsvConstructorOptions optionsArg: ICsvConstructorOptions
): Promise<Csv> { ): Promise<Csv> {
const csvInstance = new Csv(); const csvInstance = new Csv(csvStringArg, optionsArg);
csvInstance.csvString = csvStringArg;
csvInstance.determineKeyframe();
return csvInstance; return csvInstance;
} }
public csvString: string; public csvString: string;
@ -22,6 +20,15 @@ export class Csv {
headers: true headers: true
}; };
constructor(csvStringArg: string, optionsArg: ICsvConstructorOptions) {
this.csvString = csvStringArg;
this.options = optionsArg;
this.determineKeyframe();
}
/**
* determines the keyframe of the csv string
*/
public determineKeyframe() { public determineKeyframe() {
let commaLength = 0; let commaLength = 0;
let semicolonLength = 0; let semicolonLength = 0;
@ -41,6 +48,9 @@ export class Csv {
} }
} }
/**
* serializes the csv string
*/
public serializeCsvString() { public serializeCsvString() {
const rowArray = this.getRows(); const rowArray = this.getRows();
const resultArray = []; const resultArray = [];