@intuitionrobotics/ts-common 0.42.62 → 0.42.64
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/package.json +3 -5
- package/csv.d.ts +0 -1
- package/csv.js +0 -31
- package/csv.js.map +0 -1
- package/modules/CSVModule.d.ts +0 -27
- package/modules/CSVModule.js +0 -77
- package/modules/CSVModule.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuitionrobotics/ts-common",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.64",
|
|
4
4
|
"description": "js and ts infra",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"IR",
|
|
@@ -30,16 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"moment": "^2.24.0",
|
|
33
|
-
"node-forge": "^
|
|
33
|
+
"node-forge": "^1.3.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^16.0.0",
|
|
37
|
-
"@types/node-forge": "^
|
|
37
|
+
"@types/node-forge": "^1.3.2",
|
|
38
38
|
"@typescript-eslint/eslint-plugin": "^2.31.0",
|
|
39
39
|
"@typescript-eslint/parser": "^2.31.0",
|
|
40
|
-
"csv-parser": "^2.3.3",
|
|
41
40
|
"eslint": "^6.8.0",
|
|
42
|
-
"export-to-csv": "^0.2.1",
|
|
43
41
|
"ts-node": "^8.6.2",
|
|
44
42
|
"typescript": "~4.1.0"
|
|
45
43
|
},
|
package/csv.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './modules/CSVModule';
|
package/csv.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* ts-common is the basic building blocks of our typescript projects
|
|
4
|
-
*
|
|
5
|
-
* Copyright (C) 2020 Intuition Robotics
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
-
if (k2 === undefined) k2 = k;
|
|
21
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
22
|
-
}) : (function(o, m, k, k2) {
|
|
23
|
-
if (k2 === undefined) k2 = k;
|
|
24
|
-
o[k2] = m[k];
|
|
25
|
-
}));
|
|
26
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
__exportStar(require("./modules/CSVModule"), exports);
|
|
31
|
-
//# sourceMappingURL=csv.js.map
|
package/csv.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../src/main/csv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAEH,sDAAoC"}
|
package/modules/CSVModule.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by tacb0ss on 07/05/2018.
|
|
3
|
-
*/
|
|
4
|
-
import { ExportToCsv, Options } from 'export-to-csv';
|
|
5
|
-
import { ObjectTS, StringMap } from '../utils/types';
|
|
6
|
-
import { Module } from '../core/module';
|
|
7
|
-
declare type Config = {
|
|
8
|
-
options: Options;
|
|
9
|
-
};
|
|
10
|
-
export declare type ReadPropsMap<K extends ObjectTS = ObjectTS> = {
|
|
11
|
-
[s: string]: keyof K;
|
|
12
|
-
};
|
|
13
|
-
export declare type WritePropsMap<K extends ObjectTS = ObjectTS> = {
|
|
14
|
-
[P in keyof K]: string;
|
|
15
|
-
};
|
|
16
|
-
declare class CSVModule_Class extends Module<Config> {
|
|
17
|
-
private csvExporter;
|
|
18
|
-
constructor();
|
|
19
|
-
protected init(): void;
|
|
20
|
-
static createExporter(options: Options): ExportToCsv;
|
|
21
|
-
export<T>(items: T[], returnCsv?: boolean): any;
|
|
22
|
-
saveToFile<T>(outputFile: string, items: T[], columnsToProps?: WritePropsMap<T>): Promise<void>;
|
|
23
|
-
readCsv<T extends Partial<StringMap>>(inputFile: string, columnsToProps?: ReadPropsMap<T>): Promise<T[]>;
|
|
24
|
-
private createReadParserOptions;
|
|
25
|
-
}
|
|
26
|
-
export declare const CSVModule: CSVModule_Class;
|
|
27
|
-
export {};
|
package/modules/CSVModule.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Created by tacb0ss on 07/05/2018.
|
|
4
|
-
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CSVModule = void 0;
|
|
16
|
-
const export_to_csv_1 = require("export-to-csv");
|
|
17
|
-
const fs_1 = require("fs");
|
|
18
|
-
const csvParser = require("csv-parser/index");
|
|
19
|
-
const module_1 = require("../core/module");
|
|
20
|
-
const DefaultConfig = {
|
|
21
|
-
options: {
|
|
22
|
-
fieldSeparator: ',',
|
|
23
|
-
quoteStrings: '"',
|
|
24
|
-
decimalSeparator: '.',
|
|
25
|
-
showLabels: true,
|
|
26
|
-
showTitle: true,
|
|
27
|
-
title: 'Paired List CSV',
|
|
28
|
-
useTextFile: false,
|
|
29
|
-
useBom: true,
|
|
30
|
-
useKeysAsHeaders: true,
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
class CSVModule_Class extends module_1.Module {
|
|
34
|
-
constructor() {
|
|
35
|
-
super();
|
|
36
|
-
this.setDefaultConfig(DefaultConfig);
|
|
37
|
-
}
|
|
38
|
-
init() {
|
|
39
|
-
this.csvExporter = CSVModule_Class.createExporter(this.config.options);
|
|
40
|
-
}
|
|
41
|
-
static createExporter(options) {
|
|
42
|
-
return new export_to_csv_1.ExportToCsv(options);
|
|
43
|
-
}
|
|
44
|
-
export(items, returnCsv = true) {
|
|
45
|
-
return this.csvExporter.generateCsv(items, returnCsv);
|
|
46
|
-
}
|
|
47
|
-
saveToFile(outputFile, items, columnsToProps) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const csv = this.csvExporter.generateCsv(items, true);
|
|
50
|
-
return fs_1.promises.writeFile(outputFile, csv, { encoding: "utf8" });
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
readCsv(inputFile, columnsToProps) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
const results = [];
|
|
57
|
-
fs_1.createReadStream(inputFile, { encoding: "utf8" })
|
|
58
|
-
.pipe(csvParser(this.createReadParserOptions(columnsToProps)))
|
|
59
|
-
.on('data', (instance) => {
|
|
60
|
-
delete instance["undefined"];
|
|
61
|
-
results.push(instance);
|
|
62
|
-
})
|
|
63
|
-
.on('error', (err) => reject(err))
|
|
64
|
-
.on('end', () => resolve(results));
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
createReadParserOptions(columnsToProps) {
|
|
69
|
-
return {
|
|
70
|
-
mapHeaders: (args) => {
|
|
71
|
-
return (columnsToProps === null || columnsToProps === void 0 ? void 0 : columnsToProps[args.header]) || args.header;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.CSVModule = new CSVModule_Class();
|
|
77
|
-
//# sourceMappingURL=CSVModule.js.map
|
package/modules/CSVModule.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CSVModule.js","sourceRoot":"","sources":["../../src/main/modules/CSVModule.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;AAEH,iDAGuB;AACvB,2BAGY;AACZ,8CAA+C;AAE/C,2CAAwC;AAOxC,MAAM,aAAa,GAAG;IACrB,OAAO,EAAE;QACR,cAAc,EAAE,GAAG;QACnB,YAAY,EAAE,GAAG;QACjB,gBAAgB,EAAE,GAAG;QACrB,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,IAAI;QACZ,gBAAgB,EAAE,IAAI;KACtB;CACD,CAAC;AASF,MAAM,eACL,SAAQ,eAAc;IAItB;QACC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACtC,CAAC;IAES,IAAI;QACb,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,O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