diff --git a/src/core/Dish.mjs b/src/core/Dish.mjs index dc8672e6..6c9d6841 100755 --- a/src/core/Dish.mjs +++ b/src/core/Dish.mjs @@ -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 && diff --git a/src/node/api.mjs b/src/node/api.mjs index 092dd1fd..95cc2621 100644 --- a/src/node/api.mjs +++ b/src/node/api.mjs @@ -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(); } diff --git a/tests/node/tests/nodeApi.mjs b/tests/node/tests/nodeApi.mjs index d52bd458..54b5c395 100644 --- a/tests/node/tests/nodeApi.mjs +++ b/tests/node/tests/nodeApi.mjs @@ -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"); }), diff --git a/tests/node/tests/operations.mjs b/tests/node/tests/operations.mjs index 5300b3ef..03432ef7 100644 --- a/tests/node/tests/operations.mjs +++ b/tests/node/tests/operations.mjs @@ -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`); ]); -