+7
| require('./timeago.js')(); | ||
| console.log( | ||
| _timefriendly('1 hour'), _timefriendly('1 hour')===1000*60*60, | ||
| _timefriendly('2 days'), _timefriendly('2 days')===1000*60*60*48, | ||
| _timefriendly('2 weeks'), _timefriendly('2 weeks')===1000*60*60*24*14 | ||
| ); |
+2
-2
@@ -13,3 +13,3 @@ { | ||
| }, | ||
| "main": "timeago.js", | ||
| "main": "time-ago.js", | ||
| "dependencies": { | ||
@@ -21,3 +21,3 @@ }, | ||
| }, | ||
| "version": "0.0.2" | ||
| "version": "0.0.3" | ||
| } |
+5
-2
@@ -20,3 +20,6 @@ timeago | ||
| Simple _today() function shows Day, Month, Date, Yr | ||
| ==> 'Monday, June 1, 1970' | ||
| _today() function shows Day, Month, Date, Yr | ||
| ==> 'Monday, June 1, 1970' | ||
| _timefriendly('1 hour') // convert to ms: seconds, minutes, hours, days, weeks, months, years | ||
| ==> 3600000 |
+14
-2
| module.exports = function(){ | ||
| var second = 1000, | ||
| minute = second*60, | ||
| hour = minute*60, | ||
| day = hour*24, | ||
| week = day*7, | ||
| month = day*30, | ||
| year = day*365; | ||
| global._timeago = function(nd){ | ||
| var second = 1000, minute = second*60, hour = minute*60, day = hour*24, week = day*7, month = day*30, | ||
| year = month*12, r = Math.round, pl = function(v, n){ return n + ' ' + v + (n>1 ? 's':'') + ' ago'}; | ||
| var r = Math.round, pl = function(v, n){ return n + ' ' + v + (n>1 ? 's':'') + ' ago'}; | ||
| var ts = new Date().getTime() - new Date(nd).getTime(); | ||
@@ -23,2 +30,7 @@ if(ts < second) return ts + ' ms ago'; | ||
| } | ||
| global._timefriendly = function(s){ | ||
| var t = s.match(/(\d).([a-z]*?)s?$/); | ||
| return t[1] * eval(t[2]); | ||
| } | ||
| } |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
2751
24.88%4
33.33%37
76.19%24
9.09%1
Infinity%