File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { Console } from 'node:console' ;
2
- import { isDate } from 'node:util/types' ;
3
2
import { Utility , isIntegerNumber } from '@aws-lambda-powertools/commons' ;
4
3
import type {
5
4
GenericLogger ,
@@ -1033,11 +1032,12 @@ class Metrics extends Utility implements MetricsInterface {
1033
1032
* @param timestamp - Date object or epoch time in milliseconds representing the timestamp to validate.
1034
1033
*/
1035
1034
#validateEmfTimestamp( timestamp : number | Date ) : boolean {
1036
- if ( ! isDate ( timestamp ) && ! isIntegerNumber ( timestamp ) ) {
1035
+ const isDate = timestamp instanceof Date ;
1036
+ if ( ! isDate && ! isIntegerNumber ( timestamp ) ) {
1037
1037
return false ;
1038
1038
}
1039
1039
1040
- const timestampMs = isDate ( timestamp ) ? timestamp . getTime ( ) : timestamp ;
1040
+ const timestampMs = isDate ? timestamp . getTime ( ) : timestamp ;
1041
1041
const currentTime = new Date ( ) . getTime ( ) ;
1042
1042
1043
1043
const minValidTimestamp = currentTime - EMF_MAX_TIMESTAMP_PAST_AGE ;
@@ -1056,7 +1056,7 @@ class Metrics extends Utility implements MetricsInterface {
1056
1056
if ( isIntegerNumber ( timestamp ) ) {
1057
1057
return timestamp ;
1058
1058
}
1059
- if ( isDate ( timestamp ) ) {
1059
+ if ( timestamp instanceof Date ) {
1060
1060
return timestamp . getTime ( ) ;
1061
1061
}
1062
1062
/**
You can’t perform that action at this time.
0 commit comments