'use strict';

/*!
 * @techmely/utils
 * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
 * MIT Licensed
 */


// src/convertHrTime.ts
function convertHrTime(hrtime) {
  const nanoseconds = hrtime;
  const number = Number(nanoseconds);
  const milliseconds = number / 1e6;
  const seconds = number / 1e9;
  return {
    seconds,
    milliseconds,
    nanoseconds
  };
}

// src/timeSpan.ts
function timeSpan() {
  const start = process.hrtime.bigint();
  const end = (type) => convertHrTime(process.hrtime.bigint() - start)[type];
  const result = () => end("milliseconds");
  result.toRounded = () => Math.round(end("milliseconds"));
  result.toSeconds = () => end("seconds");
  result.toNanoseconds = () => end("nanoseconds");
  return result;
}

exports.timeSpan = timeSpan;
