fix(core): update

This commit is contained in:
Philipp Kunz 2019-05-23 17:28:21 +02:00
parent bdebb3308c
commit 94f2620161
9 changed files with 899 additions and 195 deletions

18
.gitignore vendored
View File

@ -1,6 +1,22 @@
.nogit/ .nogit/
node_modules/
# artifacts
coverage/ coverage/
public/ public/
pages/ pages/
# installs
node_modules/
# caches
.yarn/ .yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -37,18 +37,6 @@ snyk:
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLEGACY:
stage: test
script:
- npmci npm prepare
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS: testLTS:
stage: test stage: test
@ -121,10 +109,10 @@ pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command tsdoc
tags: tags:
- docker - docker
- notpriv - notpriv
@ -135,13 +123,3 @@ pages:
paths: paths:
- public - public
allow_failure: true allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@ -2,5 +2,15 @@
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartcsv",
"shortDescription": "handle csv data | gitzone standard compliant",
"npmPackagename": "@pushrocks/smartcsv",
"license": "MIT"
}
} }
} }

926
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,14 +13,14 @@
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.1.13", "@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.21",
"@pushrocks/smartfile": "^6.0.8", "@pushrocks/smartfile": "^7.0.2",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.9",
"@types/node": "^10.11.7" "@types/node": "^12.0.2"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^2.0.5" "@pushrocks/smartpromise": "^3.0.2"
} }
} }

26
readme.md Normal file
View File

@ -0,0 +1,26 @@
# @pushrocks/smartcsv
handle csv data | gitzone standard compliant
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcsv)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartcsv)
* [github.com (source mirror)](https://github.com/pushrocks/smartcsv)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartcsv/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartcsv/badges/master/build.svg)](https://gitlab.com/pushrocks/smartcsv/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartcsv/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartcsv/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartcsv.svg)](https://www.npmjs.com/package/@pushrocks/smartcsv)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartcsv/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartcsv)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -18,4 +18,12 @@ tap.test('should create a valid csv', async () => {
console.log(result); console.log(result);
}); });
tap.test('should create a valid csv string', async () => {
const createdCsvString = await smartcsv.Csv.createCsvStringFromArray([
{ wow: 'hi', wow2: 'there' },
{ wow: 'really', wow3: 'yes' }
]);
console.log(createdCsvString);
});
tap.start(); tap.start();

View File

@ -5,6 +5,13 @@ export interface ICsvConstructorOptions {
} }
export class Csv { export class Csv {
// STATIC
/**
* creates a Csv Object from string
* @param csvStringArg
* @param optionsArg
*/
public static async createCsvFromString( public static async createCsvFromString(
csvStringArg: string, csvStringArg: string,
optionsArg: ICsvConstructorOptions optionsArg: ICsvConstructorOptions
@ -12,6 +19,35 @@ export class Csv {
const csvInstance = new Csv(csvStringArg, optionsArg); const csvInstance = new Csv(csvStringArg, optionsArg);
return csvInstance; return csvInstance;
} }
public static async createCsvStringFromArray(arrayArg: any[]): Promise<string> {
const foundKeys: string[] = [];
// lets deal with the keys
for (const objectArg of arrayArg) {
for (const key of Object.keys(objectArg)) {
foundKeys.includes(key) ? null : foundKeys.push(key);
}
}
// lets deal with the data
const dataRows: string[] = [];
for (const objectArg of arrayArg) {
const dataRowArray: string[] = [];
for (const key of foundKeys) {
dataRowArray.push(objectArg[key]);
}
dataRows.push(dataRowArray.join(','));
}
// lets put togehter the csv string and return it
const headerString = foundKeys.join(',');
const dataString = dataRows.join('\n');
const csvString = `${headerString}\n${dataString}\n`;
return csvString;
}
// INSTANCE
public csvString: string; public csvString: string;
public headers: string[]; public headers: string[];
public keyFrame: string = null; public keyFrame: string = null;

View File

@ -1,13 +1,17 @@
{ {
"extends": [ "extends": ["tslint:latest", "tslint-config-prettier"],
"tslint:latest", "rules": {
"tslint-config-prettier" "semicolon": [true, "always"],
], "no-console": false,
"rules": { "ordered-imports": false,
"semicolon": [ "object-literal-sort-keys": false,
true, "member-ordering": {
"always" "options":{
] "order": [
"static-method"
]
}
} }
} },
"defaultSeverity": "warning"
}