@engine9-io/input-tools 1.7.6 → 1.7.8
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/.prettierrc +7 -0
- package/file/FileUtilities.js +5 -4
- package/file/R2.js +1 -0
- package/file/S3.js +4 -2
- package/package.json +1 -1
package/.prettierrc
ADDED
package/file/FileUtilities.js
CHANGED
|
@@ -153,7 +153,7 @@ Worker.prototype.detectEncoding.metadata = {
|
|
|
153
153
|
Internal method to transform a file into a stream of objects.
|
|
154
154
|
*/
|
|
155
155
|
Worker.prototype.fileToObjectStream = async function (options) {
|
|
156
|
-
const { filename, columns, limit: limitOption } = options;
|
|
156
|
+
const { filename, columns, limit: limitOption,format:formatOverride } = options;
|
|
157
157
|
|
|
158
158
|
// handle stream item
|
|
159
159
|
if (options.stream) {
|
|
@@ -203,14 +203,15 @@ Worker.prototype.fileToObjectStream = async function (options) {
|
|
|
203
203
|
} else {
|
|
204
204
|
stream.setEncoding(encoding);
|
|
205
205
|
}
|
|
206
|
+
let format=formatOverride || postfix;
|
|
206
207
|
|
|
207
|
-
if (
|
|
208
|
+
if (format === 'csv') {
|
|
208
209
|
const csvTransforms = this.csvToObjectTransforms({ ...options });
|
|
209
210
|
transforms = transforms.concat(csvTransforms.transforms);
|
|
210
|
-
} else if (
|
|
211
|
+
} else if (format === 'txt') {
|
|
211
212
|
const csvTransforms = this.csvToObjectTransforms({ ...options, delimiter: '\t' });
|
|
212
213
|
transforms = transforms.concat(csvTransforms.transforms);
|
|
213
|
-
} else if (
|
|
214
|
+
} else if (format === 'jsonl') {
|
|
214
215
|
/* Type of JSON that has the names in an array in the first record,
|
|
215
216
|
and the values in JSON arrays thereafter
|
|
216
217
|
*/
|
package/file/R2.js
CHANGED
package/file/S3.js
CHANGED
|
@@ -12,7 +12,9 @@ const {
|
|
|
12
12
|
} = require('@aws-sdk/client-s3');
|
|
13
13
|
const { getTempFilename } = require('./tools');
|
|
14
14
|
|
|
15
|
-
function Worker() {
|
|
15
|
+
function Worker() {
|
|
16
|
+
this.prefix='s3';
|
|
17
|
+
}
|
|
16
18
|
|
|
17
19
|
function getParts(filename) {
|
|
18
20
|
if (!filename) throw new Error(`Invalid filename: ${filename}`);
|
|
@@ -247,7 +249,7 @@ Worker.prototype.listAll = async function ({ directory }) {
|
|
|
247
249
|
debug(`Sending List command with prefix ${Prefix} with ContinuationToken ${ContinuationToken}`);
|
|
248
250
|
// eslint-disable-next-line no-await-in-loop
|
|
249
251
|
const result = await s3Client.send(command);
|
|
250
|
-
const newFiles = (result.Contents?.map((d) =>
|
|
252
|
+
const newFiles = (result.Contents?.map((d) => `${this.prefix}://${Bucket}/${d.Key}`) || []);
|
|
251
253
|
debug(`Retrieved ${newFiles.length} new files, total ${files.length},sample ${newFiles.slice(0, 3).join(',')}`);
|
|
252
254
|
files.push(...newFiles);
|
|
253
255
|
ContinuationToken = result.NextContinuationToken;
|