tscommons-esm-format 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/enums/ecommons-csv-boolean-format.d.mts +5 -0
- package/dist/enums/ecommons-csv-boolean-format.mjs +7 -0
- package/dist/enums/ecommons-csv-boolean-format.mjs.map +1 -0
- package/dist/enums/ecsv-column-type.d.mts +8 -0
- package/dist/enums/ecsv-column-type.mjs +10 -0
- package/dist/enums/ecsv-column-type.mjs.map +1 -0
- package/dist/enums/ecsv-date-format.d.mts +4 -0
- package/dist/enums/ecsv-date-format.mjs +6 -0
- package/dist/enums/ecsv-date-format.mjs.map +1 -0
- package/dist/helpers/commons-csv.d.mts +27 -0
- package/dist/helpers/commons-csv.mjs +327 -0
- package/dist/helpers/commons-csv.mjs.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/tcsv-column.d.mts +5 -0
- package/dist/types/tcsv-column.mjs +2 -0
- package/dist/types/tcsv-column.mjs.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var ECommonsCsvBooleanFormat;
|
|
2
|
+
(function (ECommonsCsvBooleanFormat) {
|
|
3
|
+
ECommonsCsvBooleanFormat[ECommonsCsvBooleanFormat["NORMAL"] = 0] = "NORMAL";
|
|
4
|
+
ECommonsCsvBooleanFormat[ECommonsCsvBooleanFormat["UPPERCASE"] = 1] = "UPPERCASE";
|
|
5
|
+
ECommonsCsvBooleanFormat[ECommonsCsvBooleanFormat["DIGIT"] = 2] = "DIGIT";
|
|
6
|
+
})(ECommonsCsvBooleanFormat || (ECommonsCsvBooleanFormat = {}));
|
|
7
|
+
//# sourceMappingURL=ecommons-csv-boolean-format.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecommons-csv-boolean-format.mjs","sourceRoot":"","sources":["../../src/enums/ecommons-csv-boolean-format.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,2EAAM,CAAA;IACN,iFAAS,CAAA;IACT,yEAAK,CAAA;AACP,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var ECommonsCsvColumnType;
|
|
2
|
+
(function (ECommonsCsvColumnType) {
|
|
3
|
+
ECommonsCsvColumnType["STRING"] = "string";
|
|
4
|
+
ECommonsCsvColumnType["NUMBER"] = "number";
|
|
5
|
+
ECommonsCsvColumnType["BOOLEAN"] = "boolean";
|
|
6
|
+
ECommonsCsvColumnType["DATE"] = "date";
|
|
7
|
+
ECommonsCsvColumnType["TIME"] = "time";
|
|
8
|
+
ECommonsCsvColumnType["DATETIME"] = "datetime";
|
|
9
|
+
})(ECommonsCsvColumnType || (ECommonsCsvColumnType = {}));
|
|
10
|
+
//# sourceMappingURL=ecsv-column-type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecsv-column-type.mjs","sourceRoot":"","sources":["../../src/enums/ecsv-column-type.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAC/B,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,4CAAmB,CAAA;IACnB,sCAAa,CAAA;IACb,sCAAa,CAAA;IACb,8CAAqB,CAAA;AACvB,CAAC,EAPW,qBAAqB,KAArB,qBAAqB,QAOhC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var ECommonsCsvDateFormat;
|
|
2
|
+
(function (ECommonsCsvDateFormat) {
|
|
3
|
+
ECommonsCsvDateFormat[ECommonsCsvDateFormat["DMYHI"] = 0] = "DMYHI";
|
|
4
|
+
ECommonsCsvDateFormat[ECommonsCsvDateFormat["YMDHIS"] = 1] = "YMDHIS";
|
|
5
|
+
})(ECommonsCsvDateFormat || (ECommonsCsvDateFormat = {}));
|
|
6
|
+
//# sourceMappingURL=ecsv-date-format.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecsv-date-format.mjs","sourceRoot":"","sources":["../../src/enums/ecsv-date-format.mts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,mEAAK,CAAA;IACL,qEAAM,CAAA;AACR,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CommonsFixedDate } from 'tscommons-esm-core';
|
|
2
|
+
import { TCommonsCsvColumn } from '../types/tcsv-column.mjs';
|
|
3
|
+
import { ECommonsCsvDateFormat } from '../enums/ecsv-date-format.mjs';
|
|
4
|
+
import { ECommonsCsvBooleanFormat } from '../enums/ecommons-csv-boolean-format.mjs';
|
|
5
|
+
type TAcceptableValues = string | number | boolean | Date | CommonsFixedDate | undefined;
|
|
6
|
+
export declare class CommonsCsv<NS extends string = string> {
|
|
7
|
+
private headers;
|
|
8
|
+
private separator;
|
|
9
|
+
private textDelimiter;
|
|
10
|
+
private dateFormat;
|
|
11
|
+
private booleanFormat;
|
|
12
|
+
private isNS;
|
|
13
|
+
private iso;
|
|
14
|
+
private fixed;
|
|
15
|
+
static buildGenericStringColumns<NS extends string = string>(source: string, separator?: string, textDelimiter?: string): Record<NS, TAcceptableValues>[];
|
|
16
|
+
constructor(headers: TCommonsCsvColumn<NS>[], separator?: string, textDelimiter?: string, dateFormat?: ECommonsCsvDateFormat, booleanFormat?: ECommonsCsvBooleanFormat, isNS?: (test: unknown) => test is NS, iso?: boolean, fixed?: boolean);
|
|
17
|
+
protected readHeader(source: string): TCommonsCsvColumn<NS>[];
|
|
18
|
+
private consumeNextLine;
|
|
19
|
+
protected splitLine(source: string): string[];
|
|
20
|
+
private parseLine;
|
|
21
|
+
parse(source: string): Record<NS, TAcceptableValues>[];
|
|
22
|
+
private encodeValue;
|
|
23
|
+
encodeLine(values: Record<NS, TAcceptableValues>): string[];
|
|
24
|
+
encodeHeaderRow(): string;
|
|
25
|
+
encode(values: Record<NS, TAcceptableValues>[], withHeaderRow?: boolean): string;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { commonsTypeIsBlank, commonsTypeIsDate, commonsTypeHasProperty, commonsDateIsYmd, commonsDateIsdmY, commonsDateIsHis, commonsDateIsHi, commonsDateIsYmdHis, commonsDateIsdmYHi, commonsDateDateTodmY, commonsDateDateToYmd, commonsDateDateToHi, commonsDateDateToHis, commonsDateDateTodmYHi, commonsDateDateToYmdHis, commonsTypeIsString, commonsTypeAttemptString, commonsTypeAttemptBoolean, commonsTypeAttemptNumber, commonsTypeAttemptDate, commonsTypeAttemptFixedDate, commonsTypeIsFixedDate } from 'tscommons-esm-core';
|
|
2
|
+
import { ECommonsCsvColumnType } from '../enums/ecsv-column-type.mjs';
|
|
3
|
+
import { ECommonsCsvDateFormat } from '../enums/ecsv-date-format.mjs';
|
|
4
|
+
import { ECommonsCsvBooleanFormat } from '../enums/ecommons-csv-boolean-format.mjs';
|
|
5
|
+
function parseValue(data, type, iso, fixed = false) {
|
|
6
|
+
if (commonsTypeIsBlank(data))
|
|
7
|
+
return undefined;
|
|
8
|
+
try {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case ECommonsCsvColumnType.STRING:
|
|
11
|
+
return commonsTypeAttemptString(data);
|
|
12
|
+
case ECommonsCsvColumnType.NUMBER: {
|
|
13
|
+
const match = commonsTypeAttemptNumber(data);
|
|
14
|
+
if (match !== undefined)
|
|
15
|
+
return match;
|
|
16
|
+
throw new Error('Unable to handle number column type for supplied data');
|
|
17
|
+
}
|
|
18
|
+
case ECommonsCsvColumnType.BOOLEAN: {
|
|
19
|
+
const match = commonsTypeAttemptBoolean(data);
|
|
20
|
+
if (match !== undefined)
|
|
21
|
+
return match;
|
|
22
|
+
throw new Error('Unable to handle boolean column type for supplied data');
|
|
23
|
+
}
|
|
24
|
+
case ECommonsCsvColumnType.DATE: {
|
|
25
|
+
let match;
|
|
26
|
+
if (fixed) {
|
|
27
|
+
match = commonsTypeAttemptFixedDate(data);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
match = commonsTypeAttemptDate(data, iso);
|
|
31
|
+
}
|
|
32
|
+
// only accept dates, even if there was a match for a time/datetime
|
|
33
|
+
if (commonsTypeIsString(data) && (commonsDateIsYmd(data) || commonsDateIsdmY(data)))
|
|
34
|
+
return match;
|
|
35
|
+
throw new Error('Unable to handle date column type for supplied data');
|
|
36
|
+
}
|
|
37
|
+
case ECommonsCsvColumnType.TIME: {
|
|
38
|
+
let match;
|
|
39
|
+
if (fixed) {
|
|
40
|
+
match = commonsTypeAttemptFixedDate(data);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
match = commonsTypeAttemptDate(data, iso);
|
|
44
|
+
}
|
|
45
|
+
// only accept times, even if there was a match for a date/datetime
|
|
46
|
+
if (commonsTypeIsString(data) && (commonsDateIsHis(data) || commonsDateIsHi(data)))
|
|
47
|
+
return match;
|
|
48
|
+
throw new Error('Unable to handle time column type for supplied data');
|
|
49
|
+
}
|
|
50
|
+
case ECommonsCsvColumnType.DATETIME: {
|
|
51
|
+
let match;
|
|
52
|
+
if (fixed) {
|
|
53
|
+
match = commonsTypeAttemptFixedDate(data);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
match = commonsTypeAttemptDate(data, iso);
|
|
57
|
+
}
|
|
58
|
+
// only accept datetimes, even if there was a match for a date/time
|
|
59
|
+
if (commonsTypeIsString(data) && (commonsDateIsYmdHis(data) || commonsDateIsdmYHi(data)))
|
|
60
|
+
return match;
|
|
61
|
+
throw new Error('Unable to handle datetime column type for supplied data');
|
|
62
|
+
}
|
|
63
|
+
default:
|
|
64
|
+
throw new Error('Unknown data type');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
throw new Error(`Unable to parse CSV data: ${e.message}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class CommonsCsv {
|
|
72
|
+
headers;
|
|
73
|
+
separator;
|
|
74
|
+
textDelimiter;
|
|
75
|
+
dateFormat;
|
|
76
|
+
booleanFormat;
|
|
77
|
+
isNS;
|
|
78
|
+
iso;
|
|
79
|
+
fixed;
|
|
80
|
+
static buildGenericStringColumns(source, separator = ',', textDelimiter = '"') {
|
|
81
|
+
const dummy = new CommonsCsv([], separator, textDelimiter);
|
|
82
|
+
const header = dummy.readHeader(source);
|
|
83
|
+
const generic = new CommonsCsv(header, separator, textDelimiter);
|
|
84
|
+
return generic
|
|
85
|
+
.parse(source)
|
|
86
|
+
.slice(1);
|
|
87
|
+
}
|
|
88
|
+
constructor(headers, separator = ',', textDelimiter = '"', dateFormat = ECommonsCsvDateFormat.YMDHIS, booleanFormat = ECommonsCsvBooleanFormat.NORMAL, isNS = (_) => commonsTypeIsString(_), iso = false, fixed = false) {
|
|
89
|
+
this.headers = headers;
|
|
90
|
+
this.separator = separator;
|
|
91
|
+
this.textDelimiter = textDelimiter;
|
|
92
|
+
this.dateFormat = dateFormat;
|
|
93
|
+
this.booleanFormat = booleanFormat;
|
|
94
|
+
this.isNS = isNS;
|
|
95
|
+
this.iso = iso;
|
|
96
|
+
this.fixed = fixed;
|
|
97
|
+
}
|
|
98
|
+
readHeader(source) {
|
|
99
|
+
const consumed = this.consumeNextLine(source);
|
|
100
|
+
return this.splitLine(consumed[0].trim())
|
|
101
|
+
.map((column) => {
|
|
102
|
+
if (!this.isNS(column))
|
|
103
|
+
throw new Error('Column name does not match permitted options');
|
|
104
|
+
return {
|
|
105
|
+
name: column,
|
|
106
|
+
type: ECommonsCsvColumnType.STRING
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
consumeNextLine(source) {
|
|
111
|
+
source = source.trim();
|
|
112
|
+
let quoted = false;
|
|
113
|
+
let line = '';
|
|
114
|
+
while (source.length > 0) {
|
|
115
|
+
const c = source.substr(0, 1);
|
|
116
|
+
source = source.substr(1);
|
|
117
|
+
if (c === this.textDelimiter) {
|
|
118
|
+
if (!quoted) {
|
|
119
|
+
quoted = true;
|
|
120
|
+
line = `${line}${c}`;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (quoted) {
|
|
124
|
+
if (source !== '' && source.substr(0, 1) === this.textDelimiter) {
|
|
125
|
+
line = `${line}${c}${c}`;
|
|
126
|
+
source = source.substr(1);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
quoted = false;
|
|
130
|
+
line = `${line}${c}`;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
throw new Error('Unable to parse CSV line');
|
|
134
|
+
}
|
|
135
|
+
if (c === '\n' && !quoted)
|
|
136
|
+
break;
|
|
137
|
+
line = `${line}${c}`; // use this rather than + so that it is always a string append
|
|
138
|
+
}
|
|
139
|
+
return [line, source];
|
|
140
|
+
}
|
|
141
|
+
splitLine(source) {
|
|
142
|
+
source = source.trim();
|
|
143
|
+
const parts = [];
|
|
144
|
+
let part = '';
|
|
145
|
+
let quoted = false;
|
|
146
|
+
let terminal = true;
|
|
147
|
+
while (source.length > 0) {
|
|
148
|
+
terminal = false;
|
|
149
|
+
const c = source.substr(0, 1);
|
|
150
|
+
source = source.substr(1);
|
|
151
|
+
if (c === this.separator && !quoted) {
|
|
152
|
+
parts.push(part.trim());
|
|
153
|
+
part = '';
|
|
154
|
+
source = source.trim();
|
|
155
|
+
terminal = true;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (c === this.textDelimiter) {
|
|
159
|
+
if (!quoted && part === '') {
|
|
160
|
+
quoted = true;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (quoted) {
|
|
164
|
+
if (source !== '' && source.substr(0, 1) === this.textDelimiter) {
|
|
165
|
+
part = `${part}${c}`;
|
|
166
|
+
source = source.substr(1);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
parts.push(part);
|
|
170
|
+
part = '';
|
|
171
|
+
terminal = true;
|
|
172
|
+
quoted = false;
|
|
173
|
+
source = source.trim();
|
|
174
|
+
if (source === '')
|
|
175
|
+
continue;
|
|
176
|
+
if (source.substr(0, 1) !== this.separator)
|
|
177
|
+
throw new Error('Unable to parse CSV line');
|
|
178
|
+
source = source.substr(1).trim();
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
throw new Error('Unable to parse CSV line');
|
|
182
|
+
}
|
|
183
|
+
part = `${part}${c}`; // use this rather than + so that it is always a string append
|
|
184
|
+
}
|
|
185
|
+
if (!terminal)
|
|
186
|
+
parts.push(part.trim());
|
|
187
|
+
return parts;
|
|
188
|
+
}
|
|
189
|
+
parseLine(parts) {
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
191
|
+
const values = {};
|
|
192
|
+
for (let i = this.headers.length; i-- > 0;) {
|
|
193
|
+
const value = parseValue(parts[i], this.headers[i].type, this.iso, this.fixed);
|
|
194
|
+
values[this.headers[i].name] = value;
|
|
195
|
+
}
|
|
196
|
+
return values;
|
|
197
|
+
}
|
|
198
|
+
parse(source) {
|
|
199
|
+
source = source.replace('\r\n', '\n').replace('\r', '\n').trim();
|
|
200
|
+
const parsed = [];
|
|
201
|
+
while (source.length > 0) {
|
|
202
|
+
const consumed = this.consumeNextLine(source);
|
|
203
|
+
source = consumed[1];
|
|
204
|
+
const line = consumed[0].trim();
|
|
205
|
+
if (line === '')
|
|
206
|
+
continue;
|
|
207
|
+
const parts = this.splitLine(line);
|
|
208
|
+
while (parts.length < this.headers.length)
|
|
209
|
+
parts.push('');
|
|
210
|
+
if (parts.length > this.headers.length)
|
|
211
|
+
throw new Error('CSV line is longer than header');
|
|
212
|
+
parsed.push(this.parseLine(parts));
|
|
213
|
+
}
|
|
214
|
+
return parsed;
|
|
215
|
+
}
|
|
216
|
+
encodeValue(data, type) {
|
|
217
|
+
if (data === undefined)
|
|
218
|
+
return '';
|
|
219
|
+
try {
|
|
220
|
+
switch (type) {
|
|
221
|
+
case ECommonsCsvColumnType.STRING: {
|
|
222
|
+
const dual = `${this.textDelimiter}${this.textDelimiter}`;
|
|
223
|
+
return `${this.textDelimiter}${data.toString().replace(this.textDelimiter, dual)}${this.textDelimiter}`;
|
|
224
|
+
}
|
|
225
|
+
case ECommonsCsvColumnType.NUMBER:
|
|
226
|
+
if ('number' === typeof data)
|
|
227
|
+
return data.toString();
|
|
228
|
+
throw new Error('Unable to handle number column type for supplied data');
|
|
229
|
+
case ECommonsCsvColumnType.BOOLEAN:
|
|
230
|
+
if ('boolean' === typeof data) {
|
|
231
|
+
if (this.booleanFormat === ECommonsCsvBooleanFormat.NORMAL)
|
|
232
|
+
return data ? 'true' : 'false';
|
|
233
|
+
if (this.booleanFormat === ECommonsCsvBooleanFormat.UPPERCASE)
|
|
234
|
+
return data ? 'TRUE' : 'FALSE';
|
|
235
|
+
if (this.booleanFormat === ECommonsCsvBooleanFormat.DIGIT)
|
|
236
|
+
return data ? '1' : '0';
|
|
237
|
+
}
|
|
238
|
+
throw new Error('Unable to handle boolean column type for supplied data');
|
|
239
|
+
case ECommonsCsvColumnType.DATE:
|
|
240
|
+
if (this.fixed) {
|
|
241
|
+
if (commonsTypeIsFixedDate(data)) {
|
|
242
|
+
if (this.dateFormat === ECommonsCsvDateFormat.DMYHI)
|
|
243
|
+
return data.dmY;
|
|
244
|
+
if (this.dateFormat === ECommonsCsvDateFormat.YMDHIS)
|
|
245
|
+
return data.Ymd;
|
|
246
|
+
}
|
|
247
|
+
throw new Error('Unable to handle date column type for supplied data');
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
if (commonsTypeIsDate(data)) {
|
|
251
|
+
if (this.dateFormat === ECommonsCsvDateFormat.DMYHI)
|
|
252
|
+
return commonsDateDateTodmY(data, this.iso);
|
|
253
|
+
if (this.dateFormat === ECommonsCsvDateFormat.YMDHIS)
|
|
254
|
+
return commonsDateDateToYmd(data, this.iso);
|
|
255
|
+
}
|
|
256
|
+
throw new Error('Unable to handle date column type for supplied data');
|
|
257
|
+
}
|
|
258
|
+
case ECommonsCsvColumnType.TIME:
|
|
259
|
+
if (this.fixed) {
|
|
260
|
+
if (commonsTypeIsFixedDate(data)) {
|
|
261
|
+
if (this.dateFormat === ECommonsCsvDateFormat.DMYHI)
|
|
262
|
+
return data.Hi;
|
|
263
|
+
if (this.dateFormat === ECommonsCsvDateFormat.YMDHIS)
|
|
264
|
+
return data.His;
|
|
265
|
+
}
|
|
266
|
+
throw new Error('Unable to handle time column type for supplied data');
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
if (commonsTypeIsDate(data)) {
|
|
270
|
+
if (this.dateFormat === ECommonsCsvDateFormat.DMYHI)
|
|
271
|
+
return commonsDateDateToHi(data, this.iso);
|
|
272
|
+
if (this.dateFormat === ECommonsCsvDateFormat.YMDHIS)
|
|
273
|
+
return commonsDateDateToHis(data, this.iso);
|
|
274
|
+
}
|
|
275
|
+
throw new Error('Unable to handle time column type for supplied data');
|
|
276
|
+
}
|
|
277
|
+
case ECommonsCsvColumnType.DATETIME:
|
|
278
|
+
if (this.fixed) {
|
|
279
|
+
if (commonsTypeIsFixedDate(data)) {
|
|
280
|
+
if (this.dateFormat === ECommonsCsvDateFormat.DMYHI)
|
|
281
|
+
return data.dmYHi;
|
|
282
|
+
if (this.dateFormat === ECommonsCsvDateFormat.YMDHIS)
|
|
283
|
+
return data.YmdHis;
|
|
284
|
+
}
|
|
285
|
+
throw new Error('Unable to handle datetime column type for supplied data');
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
if (commonsTypeIsDate(data)) {
|
|
289
|
+
if (this.dateFormat === ECommonsCsvDateFormat.DMYHI)
|
|
290
|
+
return commonsDateDateTodmYHi(data, this.iso);
|
|
291
|
+
if (this.dateFormat === ECommonsCsvDateFormat.YMDHIS)
|
|
292
|
+
return commonsDateDateToYmdHis(data, this.iso);
|
|
293
|
+
}
|
|
294
|
+
throw new Error('Unable to handle datetime column type for supplied data');
|
|
295
|
+
}
|
|
296
|
+
default:
|
|
297
|
+
throw new Error('Unknown data type');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (e) {
|
|
301
|
+
throw new Error(`Unable to encode value to CSV data: ${e.message}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
encodeLine(values) {
|
|
305
|
+
return this.headers
|
|
306
|
+
.map((header) => {
|
|
307
|
+
if (!commonsTypeHasProperty(values, header.name))
|
|
308
|
+
return '';
|
|
309
|
+
return this.encodeValue(values[header.name], header.type);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
encodeHeaderRow() {
|
|
313
|
+
const names = this.headers
|
|
314
|
+
.map((header) => header.name);
|
|
315
|
+
return names.join(this.separator);
|
|
316
|
+
}
|
|
317
|
+
encode(values, withHeaderRow = false) {
|
|
318
|
+
const rows = values
|
|
319
|
+
.map((vs) => this.encodeLine(vs))
|
|
320
|
+
.map((vs) => vs.join(this.separator))
|
|
321
|
+
.join('\n');
|
|
322
|
+
if (withHeaderRow)
|
|
323
|
+
return `${this.encodeHeaderRow()}\n${rows}`;
|
|
324
|
+
return rows;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=commons-csv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commons-csv.mjs","sourceRoot":"","sources":["../../src/helpers/commons-csv.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,E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AAO,EAAE,CAAC,CAAC;QAChF,CAAC;IACF,CAAC;IAEM,UAAU,CAAC,MAAqC;QACtD,OAAO,IAAI,CAAC,OAAO;aAChB,GAAG,CAAC,CAAC,MAA6B,EAAU,EAAE;YAC9C,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;gBAAE,OAAO,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACN,CAAC;IAEM,eAAe;QACrB,MAAM,KAAK,GAAa,IAAI,CAAC,OAAO;aACjC,GAAG,CAAC,CAAC,MAA6B,EAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAEM,MAAM,CAAC,MAAuC,EAAE,gBAAyB,KAAK;QACpF,MAAM,IAAI,GAAW,MAAM;aACxB,GAAG,CAAC,CAAC,EAAiC,EAAY,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;aACzE,GAAG,CAAC,CAAC,EAAY,EAAU,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACtD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,IAAI,aAAa;YAAE,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonsCsv } from './helpers/commons-csv.mjs';
|
|
2
|
+
import { ECommonsCsvColumnType } from './enums/ecsv-column-type.mjs';
|
|
3
|
+
import { ECommonsCsvDateFormat } from './enums/ecsv-date-format.mjs';
|
|
4
|
+
import { ECommonsCsvBooleanFormat } from './enums/ecommons-csv-boolean-format.mjs';
|
|
5
|
+
import { TCommonsCsvColumn } from './types/tcsv-column.mjs';
|
|
6
|
+
export { CommonsCsv, ECommonsCsvColumnType, ECommonsCsvDateFormat, ECommonsCsvBooleanFormat, TCommonsCsvColumn };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonsCsv } from './helpers/commons-csv.mjs';
|
|
2
|
+
import { ECommonsCsvColumnType } from './enums/ecsv-column-type.mjs';
|
|
3
|
+
import { ECommonsCsvDateFormat } from './enums/ecsv-date-format.mjs';
|
|
4
|
+
import { ECommonsCsvBooleanFormat } from './enums/ecommons-csv-boolean-format.mjs';
|
|
5
|
+
export { CommonsCsv, ECommonsCsvColumnType, ECommonsCsvDateFormat, ECommonsCsvBooleanFormat };
|
|
6
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,EACN,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EAExB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcsv-column.mjs","sourceRoot":"","sources":["../../src/types/tcsv-column.mts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tscommons-esm-format",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"tsc": "./node_modules/typescript/bin/tsc",
|
|
7
|
+
"preprepare": "rm -rf ./dist; php ~/Dev/etim.php src/ && npm run tsc",
|
|
8
|
+
"publish-major": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version major && npm install && npm publish && git add . && git commit -m 'publish'",
|
|
9
|
+
"publish-minor": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version minor && npm install && npm publish && git add . && git commit -m 'publish'",
|
|
10
|
+
"publish-patch": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version patch && npm install && npm publish && git add . && git commit -m 'publish'"
|
|
11
|
+
},
|
|
12
|
+
"main": "dist/index.mjs",
|
|
13
|
+
"types": "dist/index.d.mjs",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"author": "Pete Morris",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@stylistic/eslint-plugin-ts": "^2.10.1",
|
|
19
|
+
"eslint-plugin-import": "^2.31.0",
|
|
20
|
+
"eslint-plugin-prefer-arrow-functions": "^3.4.1",
|
|
21
|
+
"typescript": "^5.6.3",
|
|
22
|
+
"typescript-eslint": "^8.14.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/**/*"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"tscommons-esm-core": "^0.0.2"
|
|
29
|
+
}
|
|
30
|
+
}
|