UNPKG

yolo-helpers

Version:

Helper functions to use models converted from YOLO in browser and Node.js

28 lines (27 loc) 968 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.polyfillUtil = polyfillUtil; // Polyfill the removed util.isNullOrUndefined (Node 23+ broke tfjs-node < ~4.23) function polyfillUtil() { let util = eval('require("util")'); // Only patch if the function is missing if (typeof util.isNullOrUndefined !== 'function') { util.isNullOrUndefined = (val) => val === null || val === undefined; } // Optional: also patch isUndefined / isDefined if you see similar errors later if (typeof util.isUndefined !== 'function') { util.isUndefined = (val) => val === undefined; } if (typeof util.isDefined !== 'function') { util.isDefined = (val) => val !== undefined; } if (typeof util.isArray !== 'function') { util.isArray = (val) => { return Array.isArray(val); }; } } // only run in node.js if (typeof window === 'undefined') { polyfillUtil(); }