UNPKG

@azure/cosmos

Version:
34 lines 1.18 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); exports.getCurrentTimestampInMs = getCurrentTimestampInMs; exports.startBackgroundTask = startBackgroundTask; /** * @hidden * Utility function to get currentTime in UTC milliseconds. * @returns */ function getCurrentTimestampInMs() { return Date.now(); } /** * @hidden * Utility function to start a background task that runs at specified intervals. * @param action - A function that returns a Promise, representing the task to be executed. * @param intervalMs - The interval in milliseconds at which the task should run. * @returns A NodeJS.Timeout object representing the timer for the background task. */ function startBackgroundTask(action, intervalMs) { const timer = setInterval(() => { (async () => { await action(); })(); }, intervalMs); // Unref the timer if available to prevent it from keeping the Node.js event loop alive if (timer.unref && typeof timer.unref === "function") { timer.unref(); } return timer; } //# sourceMappingURL=time.js.map