fix: use nullish checks for node api input
This commit is contained in:
parent
fb671952e9
commit
e59f0907f4
@ -37,7 +37,7 @@ class Dish {
|
|||||||
constructor(dishOrInput=null, type = null) {
|
constructor(dishOrInput=null, type = null) {
|
||||||
this.value = new ArrayBuffer(0);
|
this.value = new ArrayBuffer(0);
|
||||||
this.type = Dish.ARRAY_BUFFER;
|
this.type = Dish.ARRAY_BUFFER;
|
||||||
const hasInput = Boolean(dishOrInput) || dishOrInput === 0;
|
const hasInput = dishOrInput !== undefined && dishOrInput !== null;
|
||||||
|
|
||||||
// Case: dishOrInput is dish object
|
// Case: dishOrInput is dish object
|
||||||
if (hasInput &&
|
if (hasInput &&
|
||||||
|
|||||||
@ -98,7 +98,7 @@ function transformArgs(opArgsList, newArgs) {
|
|||||||
* @param input
|
* @param input
|
||||||
*/
|
*/
|
||||||
function ensureIsDish(input) {
|
function ensureIsDish(input) {
|
||||||
if (!input && input !== 0) {
|
if (input === undefined || input === null) {
|
||||||
return new NodeDish();
|
return new NodeDish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ TestRegister.addApiTests([
|
|||||||
assert(result instanceof NodeDish);
|
assert(result instanceof NodeDish);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("should preserve numeric zero input", () => {
|
it("should process numeric zero input", () => {
|
||||||
const result = chef.toHex(0);
|
const result = chef.toHex(0);
|
||||||
assert.strictEqual(result.toString(), "30");
|
assert.strictEqual(result.toString(), "30");
|
||||||
}),
|
}),
|
||||||
@ -185,7 +185,7 @@ TestRegister.addApiTests([
|
|||||||
assert.strictEqual(result.toString(), "ONXW2ZJANFXHA5LU");
|
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");
|
const result = await chef.bake(0, "to hex");
|
||||||
assert.strictEqual(result.toString(), "30");
|
assert.strictEqual(result.toString(), "30");
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -59,7 +59,7 @@ TestRegister.addApiTests([
|
|||||||
assert.strictEqual(result.toString(), "7");
|
assert.strictEqual(result.toString(), "7");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
it("ADD: preserves numeric zero input", () => {
|
it("ADD: processes numeric zero input", () => {
|
||||||
const result = chef.ADD(0, {
|
const result = chef.ADD(0, {
|
||||||
key: "4",
|
key: "4",
|
||||||
});
|
});
|
||||||
@ -1185,4 +1185,3 @@ ExifImageHeight: 57`);
|
|||||||
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user