From fd3aba005537151a4e33dbca46b69fb68da4784b Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 14 Nov 2022 04:29:04 +0300 Subject: [PATCH] added hi-res timestamp to Date.js Signed-off-by: Alex A. Naanou --- Date.js | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Date.js b/Date.js index b24eb55..a36a6cb 100644 --- a/Date.js +++ b/Date.js @@ -15,6 +15,15 @@ var object = require('ig-object') var DateMixin = module.DateMixin = object.Mixin('DateMixin', 'soft', { + hires: function(){ + return typeof(process) != 'undefined' ? + performance.timeOrigin + performance.now() + : performance.timing.navigationStart + performance.now() }, + hiresTimeStamp: function(){ + var t = this.hires() + var date = new this(t) + return date.getTimeStamp(true) + (''+(t-date.getTime())).slice(1) }, + timeStamp: function(...args){ return (new this()).getTimeStamp(...args) }, fromTimeStamp: function(ts){ diff --git a/package.json b/package.json index 31f6f2a..93837c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "6.20.4", + "version": "6.21.0", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": {