BREAKING CHANGE(core): switch to esm and enable white space trimming.

This commit is contained in:
Philipp Kunz 2022-08-06 18:38:53 +02:00
parent c4194bf037
commit d7c1677c9d
10 changed files with 5586 additions and 19555 deletions

View File

@ -18,17 +18,6 @@ before_script:
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
@ -100,10 +89,9 @@ codequality:
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
@ -123,11 +111,10 @@ trigger:
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
- npmci command npm run buildDocs
tags:
- lossless
- docker

View File

@ -9,7 +9,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartcsv",
"shortDescription": "handle csv data | gitzone standard compliant",
"description": "handle csv data | gitzone standard compliant",
"npmPackagename": "@pushrocks/smartcsv",
"license": "MIT"
}

25043
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,25 +5,27 @@
"description": "handle csv data | gitzone standard compliant",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
"build": "(tsbuild)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.28",
"@gitzone/tsrun": "^1.2.18",
"@gitzone/tstest": "^1.0.60",
"@pushrocks/smartfile": "^9.0.5",
"@pushrocks/tapbundle": "^3.2.15",
"@types/node": "^17.0.7",
"@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsrun": "^1.2.37",
"@gitzone/tstest": "^1.0.73",
"@pushrocks/smartfile": "^10.0.4",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.6.4",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartstring": "^3.0.24"
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartstring": "^4.0.2"
},
"files": [
"ts/**/*",
@ -40,4 +42,4 @@
"browserslist": [
"last 1 chrome versions"
]
}
}

View File

@ -29,7 +29,6 @@ Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20W
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -1,5 +1,5 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartcsv from '../ts/index';
import * as smartcsv from '../ts/index.js';
import * as smartfile from '@pushrocks/smartfile';

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartcsv',
version: '2.0.0',
description: 'handle csv data | gitzone standard compliant'
}

View File

@ -1,8 +1,9 @@
import * as plugins from './smartcsv.plugins';
import * as plugins from './smartcsv.plugins.js';
export interface ICsvConstructorOptions {
headers: boolean;
unquote?: boolean;
trimSpace?: boolean;
removeBomMarkers?: boolean;
}
@ -61,6 +62,7 @@ export class Csv {
public options: ICsvConstructorOptions = {
headers: true,
unquote: true,
trimSpace: true,
removeBomMarkers: true,
};
@ -74,6 +76,9 @@ export class Csv {
if (this.options.removeBomMarkers) {
csvStringToParse = csvStringToParse.replace(/^\uFEFF/, '');
}
// Quotes allow separators to be contained in quoted strings.
// To preserve them, when unquoting, we convert everything in between to base64 here
if (this.options.unquote) {
csvStringToParse = csvStringToParse.replace(
/"(.*?)"/gi,
@ -154,6 +159,13 @@ export class Csv {
}
this.headers = unquotedHeaders;
}
if (this.options.trimSpace) {
const trimmedHeaders = [];
for (const header of this.headers) {
trimmedHeaders.push(header.trim());
}
this.headers = trimmedHeaders;
}
}
return this.headers;
}
@ -170,6 +182,9 @@ export class Csv {
.replace(/['"]+/g, '')
.replace(/['"]+/g, '');
}
if (this.options.trimSpace) {
value = value.trim();
}
resultJson[this.headers[i]] = value;
}
return resultJson;

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

View File

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