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/dist/cjs/sync.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const transform = function () {
}
// Validate arguments
let expected_handler_length = 1;
if (options.params) {
if (options.params !== undefined && options.params !== null) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/stream-transform/dist/esm/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5263,7 +5263,7 @@ const transform = function () {
}
// Validate arguments
let expected_handler_length = 1;
if (options.params) {
if (options.params !== undefined && options.params !== null) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/stream-transform/dist/iife/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5266,7 +5266,7 @@ var stream_transform_sync = (function (exports) {
}
// Validate arguments
let expected_handler_length = 1;
if (options.params) {
if (options.params !== undefined && options.params !== null) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/stream-transform/dist/umd/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5269,7 +5269,7 @@
}
// Validate arguments
let expected_handler_length = 1;
if (options.params) {
if (options.params !== undefined && options.params !== null) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/stream-transform/lib/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const transform = function () {
}
// Validate arguments
let expected_handler_length = 1;
if (options.params) {
if (options.params !== undefined && options.params !== null) {
expected_handler_length++;
}
if (handler.length > expected_handler_length) {
Expand Down
29 changes: 29 additions & 0 deletions packages/stream-transform/test/option.params.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import "should";
import { transform as transformSync } from "../lib/sync.js";
import { generate } from "csv-generate";
import { transform } from "../lib/index.js";

describe("option.params", function () {
describe("sync API", function () {
for (const params of [0, false, ""]) {
it(`honors falsy params ${JSON.stringify(params)}`, function () {
const data = transformSync(
["record"],
{ params },
function (record, value) {
return [record, value];
},
);
data.should.eql([["record", params]]);
});
}

for (const params of [undefined, null]) {
it(`rejects callback handlers with params ${params}`, function () {
(function () {
transformSync(["record"], { params }, function (record, callback) {
callback(null, record);
});
}).should.throw(
"Invalid Handler: only synchronous handlers are supported",
);
});
}
});

it("sync", function (next) {
const generator = generate({ length: 100, objectMode: true, seed: 1 });
const transformer = generator.pipe(
Expand Down