bellboy 8.4.1 → 8.5.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.
@@ -1,30 +1,15 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
2
  Object.defineProperty(exports, "__esModule", { value: true });
16
3
  exports.DatabaseProcessor = void 0;
17
- var processor_1 = require("./processor");
18
- var DatabaseProcessor = /** @class */ (function (_super) {
19
- __extends(DatabaseProcessor, _super);
20
- function DatabaseProcessor(config) {
21
- var _this = _super.call(this, config) || this;
4
+ const processor_1 = require("./processor");
5
+ class DatabaseProcessor extends processor_1.Processor {
6
+ query;
7
+ constructor(config) {
8
+ super(config);
22
9
  if (!config.query) {
23
- throw new Error("No query specified.");
10
+ throw new Error(`No query specified.`);
24
11
  }
25
- _this.query = config.query;
26
- return _this;
12
+ this.query = config.query;
27
13
  }
28
- return DatabaseProcessor;
29
- }(processor_1.Processor));
14
+ }
30
15
  exports.DatabaseProcessor = DatabaseProcessor;
@@ -1,47 +1,30 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.DirectoryProcessor = void 0;
20
- var fs_1 = __importDefault(require("fs"));
21
- var processor_1 = require("./processor");
22
- var DirectoryProcessor = /** @class */ (function (_super) {
23
- __extends(DirectoryProcessor, _super);
24
- function DirectoryProcessor(config) {
25
- var _this = _super.call(this, config) || this;
26
- _this.files = [];
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const processor_1 = require("./processor");
7
+ class DirectoryProcessor extends processor_1.Processor {
8
+ path;
9
+ files = [];
10
+ constructor(config) {
11
+ super(config);
27
12
  if (!config.path && (!config.files || config.files.length === 0)) {
28
- throw new Error("No path or files specified.");
13
+ throw new Error(`No path or files specified.`);
29
14
  }
30
- _this.path = config.path || '';
31
- var filePattern = "(.*?)";
15
+ this.path = config.path || '';
16
+ let filePattern = `(.*?)`;
32
17
  if (config.filePattern) {
33
18
  filePattern = config.filePattern;
34
19
  }
35
20
  if (!config.files || config.files.length === 0) {
36
- var dir = fs_1.default.readdirSync(_this.path);
37
- var regex_1 = new RegExp(filePattern, 'g');
38
- _this.files = dir.sort().filter(function (x) { return x.match(regex_1); });
21
+ const dir = fs_1.default.readdirSync(this.path);
22
+ const regex = new RegExp(filePattern, 'g');
23
+ this.files = dir.sort().filter((x) => x.match(regex));
39
24
  }
40
25
  else {
41
- _this.files = config.files;
26
+ this.files = config.files;
42
27
  }
43
- return _this;
44
28
  }
45
- return DirectoryProcessor;
46
- }(processor_1.Processor));
29
+ }
47
30
  exports.DirectoryProcessor = DirectoryProcessor;
@@ -1,56 +1,16 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.Processor = void 0;
40
- var Processor = /** @class */ (function () {
41
- function Processor(config) {
4
+ class Processor {
5
+ rowLimit;
6
+ constructor(config) {
42
7
  this.rowLimit = 0;
43
8
  if (config) {
44
9
  this.rowLimit = config.rowLimit || 0;
45
10
  }
46
11
  }
47
- Processor.prototype.process = function (processStream) {
48
- return __awaiter(this, void 0, void 0, function () {
49
- return __generator(this, function (_a) {
50
- throw new Error('Method not implemented.');
51
- });
52
- });
53
- };
54
- return Processor;
55
- }());
12
+ async process(processStream) {
13
+ throw new Error('Method not implemented.');
14
+ }
15
+ }
56
16
  exports.Processor = Processor;
@@ -1,120 +1,52 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- var __generator = (this && this.__generator) || function (thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (_) try {
31
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- };
51
- var __importDefault = (this && this.__importDefault) || function (mod) {
52
- return (mod && mod.__esModule) ? mod : { "default": mod };
53
- };
54
2
  Object.defineProperty(exports, "__esModule", { value: true });
55
3
  exports.DelimitedProcessor = void 0;
56
- var csv_parse_1 = require("csv-parse");
57
- var fs_1 = __importDefault(require("fs"));
58
- var path_1 = __importDefault(require("path"));
59
- var iconv_lite_1 = __importDefault(require("iconv-lite"));
60
- var utils_1 = require("../utils");
61
- var directory_processor_1 = require("./base/directory-processor");
62
- var DelimitedProcessor = /** @class */ (function (_super) {
63
- __extends(DelimitedProcessor, _super);
64
- function DelimitedProcessor(config) {
65
- var _this = _super.call(this, config) || this;
4
+ const tslib_1 = require("tslib");
5
+ const csv_parse_1 = require("csv-parse");
6
+ const fs_1 = tslib_1.__importDefault(require("fs"));
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const iconv_lite_1 = tslib_1.__importDefault(require("iconv-lite"));
9
+ const utils_1 = require("../utils");
10
+ const directory_processor_1 = require("./base/directory-processor");
11
+ class DelimitedProcessor extends directory_processor_1.DirectoryProcessor {
12
+ rowSeparator;
13
+ hasHeader;
14
+ delimiter;
15
+ qualifier;
16
+ encoding;
17
+ constructor(config) {
18
+ super(config);
66
19
  if (!config.rowSeparator) {
67
20
  throw new Error('No rowSeparator specified.');
68
21
  }
69
- _this.rowSeparator = config.rowSeparator;
70
- _this.hasHeader = !!config.hasHeader;
71
- _this.delimiter = config.delimiter;
72
- _this.qualifier = config.qualifier;
73
- _this.encoding = config.encoding;
74
- return _this;
22
+ this.rowSeparator = config.rowSeparator;
23
+ this.hasHeader = !!config.hasHeader;
24
+ this.delimiter = config.delimiter;
25
+ this.qualifier = config.qualifier;
26
+ this.encoding = config.encoding;
75
27
  }
76
- DelimitedProcessor.prototype.process = function (processStream) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var _i, _a, file, filePath, fileReadStream, streamToParse, parser, readStream, generator;
79
- return __generator(this, function (_b) {
80
- switch (_b.label) {
81
- case 0:
82
- _i = 0, _a = this.files;
83
- _b.label = 1;
84
- case 1:
85
- if (!(_i < _a.length)) return [3 /*break*/, 4];
86
- file = _a[_i];
87
- filePath = path_1.default.join(this.path, file);
88
- fileReadStream = fs_1.default.createReadStream(filePath);
89
- streamToParse = this.encoding ? fileReadStream.pipe(iconv_lite_1.default.decodeStream(this.encoding)) : fileReadStream;
90
- parser = csv_parse_1.parse({
91
- quote: this.qualifier,
92
- delimiter: this.delimiter,
93
- record_delimiter: this.rowSeparator,
94
- raw: true,
95
- relax_quotes: true,
96
- relax_column_count: true,
97
- });
98
- readStream = streamToParse.pipe(parser);
99
- generator = utils_1.getDelimitedGenerator({
100
- hasHeader: this.hasHeader,
101
- readStream: readStream,
102
- });
103
- return [4 /*yield*/, processStream(generator(), file, filePath)];
104
- case 2:
105
- _b.sent();
106
- fileReadStream.destroy();
107
- _b.label = 3;
108
- case 3:
109
- _i++;
110
- return [3 /*break*/, 1];
111
- case 4:
112
- ;
113
- return [2 /*return*/];
114
- }
28
+ async process(processStream) {
29
+ for (const file of this.files) {
30
+ const filePath = path_1.default.join(this.path, file);
31
+ const fileReadStream = fs_1.default.createReadStream(filePath);
32
+ const streamToParse = this.encoding ? fileReadStream.pipe(iconv_lite_1.default.decodeStream(this.encoding)) : fileReadStream;
33
+ const parser = (0, csv_parse_1.parse)({
34
+ quote: this.qualifier,
35
+ delimiter: this.delimiter,
36
+ record_delimiter: this.rowSeparator,
37
+ raw: true,
38
+ relax_quotes: true,
39
+ relax_column_count: true,
40
+ });
41
+ const readStream = streamToParse.pipe(parser);
42
+ const generator = (0, utils_1.getDelimitedGenerator)({
43
+ hasHeader: this.hasHeader,
44
+ readStream,
115
45
  });
116
- });
117
- };
118
- return DelimitedProcessor;
119
- }(directory_processor_1.DirectoryProcessor));
46
+ await processStream(generator(), file, filePath);
47
+ fileReadStream.destroy();
48
+ }
49
+ ;
50
+ }
51
+ }
120
52
  exports.DelimitedProcessor = DelimitedProcessor;
@@ -1,79 +1,19 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- var __generator = (this && this.__generator) || function (thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (_) try {
31
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- };
51
2
  Object.defineProperty(exports, "__esModule", { value: true });
52
3
  exports.DynamicProcessor = void 0;
53
- var stream_1 = require("stream");
54
- var processor_1 = require("./base/processor");
55
- var DynamicProcessor = /** @class */ (function (_super) {
56
- __extends(DynamicProcessor, _super);
57
- function DynamicProcessor(config) {
58
- var _this = _super.call(this, config) || this;
4
+ const stream_1 = require("stream");
5
+ const processor_1 = require("./base/processor");
6
+ class DynamicProcessor extends processor_1.Processor {
7
+ generator;
8
+ constructor(config) {
9
+ super(config);
59
10
  if (!config.generator) {
60
- throw Error("No generator function specified.");
11
+ throw Error(`No generator function specified.`);
61
12
  }
62
- _this.generator = config.generator;
63
- return _this;
13
+ this.generator = config.generator;
14
+ }
15
+ async process(processStream) {
16
+ await processStream(stream_1.Readable.from(this.generator()));
64
17
  }
65
- DynamicProcessor.prototype.process = function (processStream) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0: return [4 /*yield*/, processStream(stream_1.Readable.from(this.generator()))];
70
- case 1:
71
- _a.sent();
72
- return [2 /*return*/];
73
- }
74
- });
75
- });
76
- };
77
- return DynamicProcessor;
78
- }(processor_1.Processor));
18
+ }
79
19
  exports.DynamicProcessor = DynamicProcessor;
@@ -1,131 +1,52 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- var __generator = (this && this.__generator) || function (thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (_) try {
31
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- };
51
- var __importDefault = (this && this.__importDefault) || function (mod) {
52
- return (mod && mod.__esModule) ? mod : { "default": mod };
53
- };
54
2
  Object.defineProperty(exports, "__esModule", { value: true });
55
3
  exports.ExcelProcessor = void 0;
56
- var path_1 = __importDefault(require("path"));
57
- var xlstream_1 = require("xlstream");
58
- var directory_processor_1 = require("./base/directory-processor");
59
- var ExcelProcessor = /** @class */ (function (_super) {
60
- __extends(ExcelProcessor, _super);
61
- function ExcelProcessor(config) {
62
- var _this = _super.call(this, config) || this;
63
- _this.encoding = config.encoding;
64
- _this.hasHeader = config.hasHeader;
65
- _this.ignoreEmpty = config.ignoreEmpty === false ? false : true;
66
- _this.fillMergedCells = !!config.fillMergedCells;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const xlstream_1 = require("xlstream");
7
+ const directory_processor_1 = require("./base/directory-processor");
8
+ class ExcelProcessor extends directory_processor_1.DirectoryProcessor {
9
+ hasHeader;
10
+ ignoreEmpty;
11
+ encoding;
12
+ fillMergedCells;
13
+ sheets;
14
+ constructor(config) {
15
+ super(config);
16
+ this.encoding = config.encoding;
17
+ this.hasHeader = config.hasHeader;
18
+ this.ignoreEmpty = config.ignoreEmpty === false ? false : true;
19
+ this.fillMergedCells = !!config.fillMergedCells;
67
20
  if (config.sheets) {
68
- _this.sheets = config.sheets;
21
+ this.sheets = config.sheets;
69
22
  }
70
23
  else {
71
- _this.sheets = [0];
24
+ this.sheets = [0];
25
+ }
26
+ }
27
+ async process(processStream) {
28
+ for (let file of this.files) {
29
+ const filePath = path_1.default.join(this.path, file);
30
+ let sheets = [];
31
+ if (this.sheets instanceof Function) {
32
+ const allSheets = await (0, xlstream_1.getWorksheets)({ filePath });
33
+ sheets = await this.sheets(allSheets);
34
+ }
35
+ else {
36
+ sheets = this.sheets;
37
+ }
38
+ for (let i = 0; i < sheets.length; i++) {
39
+ const readStream = await (0, xlstream_1.getXlsxStream)({
40
+ filePath,
41
+ sheet: sheets[i],
42
+ withHeader: this.hasHeader,
43
+ ignoreEmpty: this.ignoreEmpty,
44
+ fillMergedCells: this.fillMergedCells,
45
+ encoding: this.encoding,
46
+ });
47
+ await processStream(readStream, file, filePath, sheets[i]);
48
+ }
72
49
  }
73
- return _this;
74
50
  }
75
- ExcelProcessor.prototype.process = function (processStream) {
76
- return __awaiter(this, void 0, void 0, function () {
77
- var _i, _a, file, filePath, sheets, allSheets, i, readStream;
78
- return __generator(this, function (_b) {
79
- switch (_b.label) {
80
- case 0:
81
- _i = 0, _a = this.files;
82
- _b.label = 1;
83
- case 1:
84
- if (!(_i < _a.length)) return [3 /*break*/, 11];
85
- file = _a[_i];
86
- filePath = path_1.default.join(this.path, file);
87
- sheets = [];
88
- if (!(this.sheets instanceof Function)) return [3 /*break*/, 4];
89
- return [4 /*yield*/, xlstream_1.getWorksheets({ filePath: filePath })];
90
- case 2:
91
- allSheets = _b.sent();
92
- return [4 /*yield*/, this.sheets(allSheets)];
93
- case 3:
94
- sheets = _b.sent();
95
- return [3 /*break*/, 5];
96
- case 4:
97
- sheets = this.sheets;
98
- _b.label = 5;
99
- case 5:
100
- i = 0;
101
- _b.label = 6;
102
- case 6:
103
- if (!(i < sheets.length)) return [3 /*break*/, 10];
104
- return [4 /*yield*/, xlstream_1.getXlsxStream({
105
- filePath: filePath,
106
- sheet: sheets[i],
107
- withHeader: this.hasHeader,
108
- ignoreEmpty: this.ignoreEmpty,
109
- fillMergedCells: this.fillMergedCells,
110
- encoding: this.encoding,
111
- })];
112
- case 7:
113
- readStream = _b.sent();
114
- return [4 /*yield*/, processStream(readStream, file, filePath, sheets[i])];
115
- case 8:
116
- _b.sent();
117
- _b.label = 9;
118
- case 9:
119
- i++;
120
- return [3 /*break*/, 6];
121
- case 10:
122
- _i++;
123
- return [3 /*break*/, 1];
124
- case 11: return [2 /*return*/];
125
- }
126
- });
127
- });
128
- };
129
- return ExcelProcessor;
130
- }(directory_processor_1.DirectoryProcessor));
51
+ }
131
52
  exports.ExcelProcessor = ExcelProcessor;