Comparing version 1.0.25 to 1.0.26
@@ -0,1 +1,2 @@ | ||
import moment from "moment"; | ||
import { Semaphore } from "./Semaphore"; | ||
@@ -6,2 +7,8 @@ export declare const isNotEmpty: (obj: any) => boolean; | ||
export declare const getUptimeServer: () => string; | ||
export declare const getInitDateTimeServer: () => { | ||
localDateTime: moment.Moment; | ||
serverDateTime: moment.Moment; | ||
utc0DateTime: moment.Moment; | ||
}; | ||
export declare const getVersionFromPackageJson: () => any; | ||
export declare const log: (tag: string, value: any) => void; | ||
@@ -8,0 +15,0 @@ export declare const replacer: () => (key: any, value: any) => any; |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Semaphore = exports.buildNestedObject = exports.expandObjectRecursive = exports.timeToPercentage = exports.round = exports.trunc = exports.delay = exports.replacer = exports.log = exports.getUptimeServer = exports.getPackageJsonData = exports.isEmpty = exports.isNotEmpty = void 0; | ||
exports.Semaphore = exports.buildNestedObject = exports.expandObjectRecursive = exports.timeToPercentage = exports.round = exports.trunc = exports.delay = exports.replacer = exports.log = exports.getVersionFromPackageJson = exports.getInitDateTimeServer = exports.getUptimeServer = exports.getPackageJsonData = exports.isEmpty = exports.isNotEmpty = void 0; | ||
const fs = __importStar(require("fs")); | ||
@@ -84,2 +84,23 @@ const moment_1 = __importDefault(require("moment")); | ||
exports.getUptimeServer = getUptimeServer; | ||
const getInitDateTimeServer = () => { | ||
const timeInSeconds = process.uptime(); | ||
return { | ||
localDateTime: (0, moment_1.default)().subtract(timeInSeconds, "seconds").utc(true), | ||
serverDateTime: (0, moment_1.default)().subtract(timeInSeconds, "seconds").utc(true), | ||
utc0DateTime: (0, moment_1.default)().subtract(timeInSeconds, "seconds").utc(false) | ||
}; | ||
}; | ||
exports.getInitDateTimeServer = getInitDateTimeServer; | ||
const getVersionFromPackageJson = () => { | ||
try { | ||
const packageJsonPath = "./package.json"; | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); | ||
return packageJson.version; | ||
} | ||
catch (error) { | ||
console.error("Error reading package.json:", error); | ||
return null; | ||
} | ||
}; | ||
exports.getVersionFromPackageJson = getVersionFromPackageJson; | ||
const log = (tag, value) => { | ||
@@ -86,0 +107,0 @@ if (process.env.MODE_DEBUG === "true") { |
{ | ||
"name": "c2-util", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "Biblioteca de funções utilitárias", | ||
@@ -5,0 +5,0 @@ "repository": "https://cabralsilva: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@github.com/cabralsilva/c2-util.git", |
10687
260