From: Chris Duncan Date: Fri, 6 Dec 2024 20:48:02 +0000 (-0800) Subject: Compare only real values with equals and notEqual. Use ok with strict equality compar... X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=970d49d1aba857e16f4b0266f237388bf3e1dfb0;p=libnemo.git Compare only real values with equals and notEqual. Use ok with strict equality comparison instead. --- diff --git a/GLOBALS.mjs b/GLOBALS.mjs index dd8b76f..dea5a8c 100644 --- a/GLOBALS.mjs +++ b/GLOBALS.mjs @@ -114,12 +114,18 @@ export const assert = { return a != null }, equals: (a, b) => { + if (a == null || b == null) { + throw new Error(`assert.equals() will not compare null or undefined`) + } if (a !== b) { throw new Error(`${a} not equal to ${b}`) } return a === b }, notEqual: (a, b) => { + if (a == null || b == null) { + throw new Error(`assert.notEqual() will not compare null or undefined`) + } if (a === b) { throw new Error(`${a} equals ${b}`) }