You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
https://snyk.io/vuln/npm:ms:20170412 possible fix #90
var scales = {
"years": y,
"year": y,
"yrs": y,
"yr": y,
"y": y,
"days": d,
"day": d,
"d": d,
"hours": h,
"hour": h,
"hrs": h,
"hr": h,
"h": h,
"minutes": m,
"minute": m,
"mins": m,
"min": m,
"m": m,
"seconds": s,
"second": s,
"secs": s,
"sec": s,
"s": s,
"milliseconds": 1,
"millisecond": 1,
"msecs": 1,
"msec": 1,
"ms": 1
};
function parse(str) {
str = String(str);
var match = str.split(/\s*?(?=[a-z])/i);
var n = parseFloat(+match[0]);
if (isNaN(n)) {
return;
}
var scale = (match.slice(1).join("") || "ms").toLowerCase();
if (!(scale in scales)) {
return;
}
return n * scales[scale];
}
Activity
leo commentedon May 16, 2017
Fixed in #89
delagen commentedon May 16, 2017
time: 72.148ms
Split regex implementation time: 8.242ms
delagen commentedon May 16, 2017
Moreover this may be faster
delagen commentedon May 17, 2017
I can open Mr, i have 1 more optimization with remove slice, join
delagen commentedon May 17, 2017
Opened PR #91
leerob commentedon Mar 2, 2021
Closing as stale 🙏