BREAKING CHANGE(core): switch to esm and enable white space trimming.
This commit is contained in:
parent
c4194bf037
commit
d7c1677c9d
@ -18,17 +18,6 @@ before_script:
|
|||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
auditProductionDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
@ -100,10 +89,9 @@ codequality:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@ -123,11 +111,10 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartcsv",
|
"gitrepo": "smartcsv",
|
||||||
"shortDescription": "handle csv data | gitzone standard compliant",
|
"description": "handle csv data | gitzone standard compliant",
|
||||||
"npmPackagename": "@pushrocks/smartcsv",
|
"npmPackagename": "@pushrocks/smartcsv",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
24983
package-lock.json
generated
24983
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -5,25 +5,27 @@
|
|||||||
"description": "handle csv data | gitzone standard compliant",
|
"description": "handle csv data | gitzone standard compliant",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.28",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsrun": "^1.2.18",
|
"@gitzone/tsrun": "^1.2.37",
|
||||||
"@gitzone/tstest": "^1.0.60",
|
"@gitzone/tstest": "^1.0.73",
|
||||||
"@pushrocks/smartfile": "^9.0.5",
|
"@pushrocks/smartfile": "^10.0.4",
|
||||||
"@pushrocks/tapbundle": "^3.2.15",
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^17.0.7",
|
"@types/node": "^18.6.4",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@pushrocks/smartstring": "^3.0.24"
|
"@pushrocks/smartstring": "^4.0.2"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
@ -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). :)
|
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
|
## 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). :)
|
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). :)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
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';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal 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'
|
||||||
|
}
|
17
ts/index.ts
17
ts/index.ts
@ -1,8 +1,9 @@
|
|||||||
import * as plugins from './smartcsv.plugins';
|
import * as plugins from './smartcsv.plugins.js';
|
||||||
|
|
||||||
export interface ICsvConstructorOptions {
|
export interface ICsvConstructorOptions {
|
||||||
headers: boolean;
|
headers: boolean;
|
||||||
unquote?: boolean;
|
unquote?: boolean;
|
||||||
|
trimSpace?: boolean;
|
||||||
removeBomMarkers?: boolean;
|
removeBomMarkers?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ export class Csv {
|
|||||||
public options: ICsvConstructorOptions = {
|
public options: ICsvConstructorOptions = {
|
||||||
headers: true,
|
headers: true,
|
||||||
unquote: true,
|
unquote: true,
|
||||||
|
trimSpace: true,
|
||||||
removeBomMarkers: true,
|
removeBomMarkers: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,6 +76,9 @@ export class Csv {
|
|||||||
if (this.options.removeBomMarkers) {
|
if (this.options.removeBomMarkers) {
|
||||||
csvStringToParse = csvStringToParse.replace(/^\uFEFF/, '');
|
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) {
|
if (this.options.unquote) {
|
||||||
csvStringToParse = csvStringToParse.replace(
|
csvStringToParse = csvStringToParse.replace(
|
||||||
/"(.*?)"/gi,
|
/"(.*?)"/gi,
|
||||||
@ -154,6 +159,13 @@ export class Csv {
|
|||||||
}
|
}
|
||||||
this.headers = unquotedHeaders;
|
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;
|
return this.headers;
|
||||||
}
|
}
|
||||||
@ -170,6 +182,9 @@ export class Csv {
|
|||||||
.replace(/['"]+/g, '')
|
.replace(/['"]+/g, '')
|
||||||
.replace(/['"]+/g, '');
|
.replace(/['"]+/g, '');
|
||||||
}
|
}
|
||||||
|
if (this.options.trimSpace) {
|
||||||
|
value = value.trim();
|
||||||
|
}
|
||||||
resultJson[this.headers[i]] = value;
|
resultJson[this.headers[i]] = value;
|
||||||
}
|
}
|
||||||
return resultJson;
|
return resultJson;
|
||||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -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"
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user