From db886919d61d7558d5e143dbc2ef0e9520ac3ffa Mon Sep 17 00:00:00 2001 From: Navpreet Singh Date: Fri, 9 Oct 2026 23:23:41 +0100 Subject: [PATCH] fix(stream-transform): preserve objects with a non-callable then field --- packages/stream-transform/lib/index.js | 2 +- packages/stream-transform/test/handler.types.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/stream-transform/lib/index.js b/packages/stream-transform/lib/index.js index 07e31c129..266271cab 100644 --- a/packages/stream-transform/lib/index.js +++ b/packages/stream-transform/lib/index.js @@ -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); diff --git a/packages/stream-transform/test/handler.types.js b/packages/stream-transform/test/handler.types.js index 8f3d696b3..a80bf1ef7 100644 --- a/packages/stream-transform/test/handler.types.js +++ b/packages/stream-transform/test/handler.types.js @@ -40,7 +40,7 @@ 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) => { @@ -48,16 +48,16 @@ describe("handler.types", function () { 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(); },