Skip to content

Commit

Permalink
improve stream tests and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelvilche committed Mar 3, 2023
1 parent 1646216 commit e3d47e7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 35 deletions.
14 changes: 1 addition & 13 deletions lib/getObjectStream.js
Expand Up @@ -5,16 +5,6 @@ const getObjectWrapper = require('./getObjectWrapper');

module.exports = class S3GetObjectStream {

/**
* Get the parser functions
*
* @readonly
* @memberof S3GetObjectStream
*/
get parsers() {
return [];
}

/**
* The buffer size of chunks
*
Expand All @@ -35,9 +25,7 @@ module.exports = class S3GetObjectStream {
*/
call(params) {

const getObjectStream = !Array.isArray(this.parsers) || !this.parsers.length
? getObjectWrapper.getObject(params)
: this.parsers.reduce((parsed, [parser, ...parserParams]) => parsed.pipe(parser(...parserParams)), getObjectWrapper.getObject(params));
const getObjectStream = getObjectWrapper.getObject(params);

return Readable.from(this.processChunks(getObjectStream));
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -35,9 +35,9 @@
"test": "tests"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.281.0",
"@aws-sdk/lib-storage": "^3.281.0",
"@aws-sdk/s3-presigned-post": "^3.281.0",
"@aws-sdk/s3-request-presigner": "^3.281.0"
"@aws-sdk/client-s3": "^3.282.0",
"@aws-sdk/lib-storage": "^3.282.0",
"@aws-sdk/s3-presigned-post": "^3.282.0",
"@aws-sdk/s3-request-presigner": "^3.282.0"
}
}
17 changes: 0 additions & 17 deletions tests/getObjectTestClass.js
@@ -1,26 +1,9 @@
'use strict';

const { Transform } = require('stream');

const S3GetObjectStream = require('../lib/getObjectStream');

module.exports = class MyGetObjectStream extends S3GetObjectStream {

get parsers() {
return [
[
() => {
const parser = new Transform({ objectMode: true });
// eslint-disable-next-line no-underscore-dangle
parser._transform = function(chunk, encoding, cb) {
cb(null, chunk);
};
return parser;
}
]
];
}

get bufferSize() {
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/s3-test.js
Expand Up @@ -526,7 +526,7 @@ context('GetObjectStream', () => {
assert.deepStrictEqual(streamData, streamRows);
});

it.skip('Should process stream chunks with defined parser, process buffer and buffer size', async () => {
it('Should process stream chunks with defined parser, process buffer and buffer size', async () => {

const streamRows = ['test-row-1', 'test-row-2'];
const testStream = Readable.from(streamRows);
Expand Down

0 comments on commit e3d47e7

Please sign in to comment.