UNPKG
itty-time
Version:
latest (2.0.2)
next (1.0.6-next.0)
2.0.2
2.0.1
2.0.0
1.0.6
1.0.6-next.0
1.0.5
1.0.5-next.1
1.0.5-next.0
1.0.4
1.0.3
1.0.2
1.0.0-next.5
1.0.0-next.4
1.0.0-next.3
1.0.0-next.2
1.0.0-next.1
1.0.0-next.0
0.2.2
0.2.1
0.2.0
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
Smaller and faster than ms.
github.com/kwhitley/itty-time
kwhitley/itty-time
itty-time
/
ms.cjs
2 lines
(1 loc)
•
220 B
JavaScript
View Raw
1
2
"use strict"
;
const
e=
36e5
,t=
24
*e,s={
year
:
315576e5
,
month
:
30
*t,
week
:
7
*t,
day
:t,
hour
:e,
minute
:
6e4
,
second
:
1e3
,
m
:
1
};
exports
.
ms
=
e
=>
{
if
(!
isNaN
(+e))
return
+e;
const
[,t,r]=e.
match
(
/^([^ ]+) +(\w\w*?)s?$/
)||[,e];
return
+t*(s[r]||
1
)};