UNPKG

node-version-call

Version:

Call a function in a specific version of node

57 lines 2.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, /** * Call a function synchronously in a specific Node version. * Installs the version if not already present. * * @param version - Version spec ('v18.0.0', '>=18', '20') * @param workerPath - Path to the file to execute * @param options - Execution options * @param args - Arguments to pass to the worker * @returns The result from the worker. Throws on error. */ "default", { enumerable: true, get: function() { return callSync; } }); var _bindSyncts = /*#__PURE__*/ _interop_require_default(require("./bindSync.js")); function _array_like_to_array(arr, len) { if (len == null || len > arr.length) len = arr.length; for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; return arr2; } function _array_without_holes(arr) { if (Array.isArray(arr)) return _array_like_to_array(arr); } function _interop_require_default(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _iterable_to_array(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _non_iterable_spread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _to_consumable_array(arr) { return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); } function _unsupported_iterable_to_array(o, minLen) { if (!o) return; if (typeof o === "string") return _array_like_to_array(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); } function callSync(version, workerPath, options) { for(var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){ args[_key - 3] = arguments[_key]; } return (0, _bindSyncts.default)(version, workerPath, options).apply(this, _to_consumable_array(args)); } /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }