Fix an empty object detection implementation
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Oct 2022 21:49:54 +0000 (23:49 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Oct 2022 21:49:54 +0000 (23:49 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
is-empty-object.js
package.json

index b27dc104d89ed3a1ec0abf892ff9483ab18431a7..909a7d7880d4b621ee13637d13ce6878e243a4c7 100644 (file)
@@ -13,7 +13,7 @@ Benchmark.suite(
     return Reflect.ownKeys(obj).length === 0 && obj.constructor === Object
   }),
   Benchmark.add('Keys iteration ', (obj = testObject) => {
-    if (obj.constructor !== Object) return false
+    if (obj?.constructor !== Object) return false
     // Iterates over the keys of an object, if
     // any exist, return false.
     // eslint-disable-next-line no-unreachable-loop
index 9e887138611687912319c36cdd24417dd528dbf4..52466601c42aa9dd31c288c624f6e2a7c63dc1c8 100644 (file)
@@ -2,6 +2,9 @@
   "name": "benchmarks-js",
   "version": "0.0.1",
   "description": "JS code pattern benchmarks",
+  "engines": {
+    "node": ">=14.x"
+  },
   "repository": {
     "type": "git",
     "url": "git://github.com/jerome-benoit/benchmarks-js.git"