123456789101112131415161718192021222324252627282930 |
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.installTimerFunctions = exports.pick = void 0;
- const globalThis_js_1 = __importDefault(require("./globalThis.js"));
- function pick(obj, ...attr) {
- return attr.reduce((acc, k) => {
- if (obj.hasOwnProperty(k)) {
- acc[k] = obj[k];
- }
- return acc;
- }, {});
- }
- exports.pick = pick;
- // Keep a reference to the real timeout functions so they can be used when overridden
- const NATIVE_SET_TIMEOUT = setTimeout;
- const NATIVE_CLEAR_TIMEOUT = clearTimeout;
- function installTimerFunctions(obj, opts) {
- if (opts.useNativeTimers) {
- obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis_js_1.default);
- obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis_js_1.default);
- }
- else {
- obj.setTimeoutFn = setTimeout.bind(globalThis_js_1.default);
- obj.clearTimeoutFn = clearTimeout.bind(globalThis_js_1.default);
- }
- }
- exports.installTimerFunctions = installTimerFunctions;
|