fix: use nullish checks for node api input

This commit is contained in:
Кирилл Ветров 2026-06-24 16:35:07 +03:00
parent fb671952e9
commit e59f0907f4
4 changed files with 5 additions and 6 deletions

View File

@ -37,7 +37,7 @@ class Dish {
constructor(dishOrInput=null, type = null) {
this.value = new ArrayBuffer(0);
this.type = Dish.ARRAY_BUFFER;
const hasInput = Boolean(dishOrInput) || dishOrInput === 0;
const hasInput = dishOrInput !== undefined && dishOrInput !== null;
// Case: dishOrInput is dish object
if (hasInput &&

View File

@ -98,7 +98,7 @@ function transformArgs(opArgsList, newArgs) {
* @param input
*/
function ensureIsDish(input) {
if (!input && input !== 0) {
if (input === undefined || input === null) {
return new NodeDish();
}

View File

@ -97,7 +97,7 @@ TestRegister.addApiTests([
assert(result instanceof NodeDish);
}),
it("should preserve numeric zero input", () => {
it("should process numeric zero input", () => {
const result = chef.toHex(0);
assert.strictEqual(result.toString(), "30");
}),
@ -185,7 +185,7 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "ONXW2ZJANFXHA5LU");
}),
it("chef.bake: should preserve numeric zero input", async () => {
it("chef.bake: should process numeric zero input", async () => {
const result = await chef.bake(0, "to hex");
assert.strictEqual(result.toString(), "30");
}),

View File

@ -59,7 +59,7 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "7");
}),
it("ADD: preserves numeric zero input", () => {
it("ADD: processes numeric zero input", () => {
const result = chef.ADD(0, {
key: "4",
});
@ -1185,4 +1185,3 @@ ExifImageHeight: 57`);
]);