File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 11import { Console } from 'node:console' ;
2- import { isDate } from 'node:util/types' ;
32import { Utility , isIntegerNumber } from '@aws-lambda-powertools/commons' ;
43import type {
54 GenericLogger ,
@@ -1033,11 +1032,12 @@ class Metrics extends Utility implements MetricsInterface {
10331032 * @param timestamp - Date object or epoch time in milliseconds representing the timestamp to validate.
10341033 */
10351034 #validateEmfTimestamp( timestamp : number | Date ) : boolean {
1036- if ( ! isDate ( timestamp ) && ! isIntegerNumber ( timestamp ) ) {
1035+ const isDate = timestamp instanceof Date ;
1036+ if ( ! isDate && ! isIntegerNumber ( timestamp ) ) {
10371037 return false ;
10381038 }
10391039
1040- const timestampMs = isDate ( timestamp ) ? timestamp . getTime ( ) : timestamp ;
1040+ const timestampMs = isDate ? timestamp . getTime ( ) : timestamp ;
10411041 const currentTime = new Date ( ) . getTime ( ) ;
10421042
10431043 const minValidTimestamp = currentTime - EMF_MAX_TIMESTAMP_PAST_AGE ;
@@ -1056,7 +1056,7 @@ class Metrics extends Utility implements MetricsInterface {
10561056 if ( isIntegerNumber ( timestamp ) ) {
10571057 return timestamp ;
10581058 }
1059- if ( isDate ( timestamp ) ) {
1059+ if ( timestamp instanceof Date ) {
10601060 return timestamp . getTime ( ) ;
10611061 }
10621062 /**
You can’t perform that action at this time.
0 commit comments