Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/stream-transform/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Transformer.prototype._transform = function (chunk, _, cb) {
if (l === 1) {
// sync
const result = this.handler.call(this, chunk, this.options.params);
if (result && result.then) {
if (result && typeof result.then === "function") {
result.then(
(result) => {
this.__done(null, [result], cb);
Expand Down
10 changes: 5 additions & 5 deletions packages/stream-transform/test/handler.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ describe("handler.types", function () {
);
});

it("receive string and return object", function (next) {
it("receive string and return object with a then field", function (next) {
transform(
["20322-051544", "28392-898392", "83929-843999"],
(record) => {
record.should.not.be.an.Array;
const [value_1, value_2] = record.split("-");
record = {
FIELD_1: value_1,
FIELD_2: value_2,
then: value_2,
};
return record;
},
(err, data) => {
if (err) return next(err);
data.should.eql([
{ FIELD_1: "20322", FIELD_2: "051544" },
{ FIELD_1: "28392", FIELD_2: "898392" },
{ FIELD_1: "83929", FIELD_2: "843999" },
{ FIELD_1: "20322", then: "051544" },
{ FIELD_1: "28392", then: "898392" },
{ FIELD_1: "83929", then: "843999" },
]);
next();
},
Expand Down