millisecond
Advanced tools
Comparing version 0.1.0 to 0.1.1
42
index.js
@@ -0,1 +1,33 @@ | ||
'use strict'; | ||
var regex = new RegExp('^((?:\\d+)?\\.?\\d+) *('+ [ | ||
'milliseconds?', | ||
'msecs?', | ||
'ms', | ||
'seconds?', | ||
'secs?', | ||
's', | ||
'minutes?', | ||
'mins?', | ||
'm', | ||
'hours?', | ||
'hrs?', | ||
'h', | ||
'days?', | ||
'd', | ||
'weeks?', | ||
'wks?', | ||
'w', | ||
'years?', | ||
'yrs?', | ||
'y' | ||
].join('|') +')?$', 'i'); | ||
var second = 1000 | ||
, minute = second * 60 | ||
, hour = minute * 60 | ||
, day = hour * 24 | ||
, week = day * 7 | ||
, year = day * 365; | ||
/** | ||
@@ -9,13 +41,5 @@ * Parse a time string and return the number value of it. | ||
module.exports = function millisecond(ms) { | ||
'use strict'; | ||
if ('string' !== typeof ms || '0' === ms || +ms) return +ms; | ||
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|wks?|w|years?|yrs?|y)?$/i.exec(ms) | ||
, second = 1000 | ||
, minute = second * 60 | ||
, hour = minute * 60 | ||
, day = hour * 24 | ||
, week = day * 7 | ||
, year = day * 365 | ||
var match = regex.exec(ms) | ||
, amount; | ||
@@ -22,0 +46,0 @@ |
{ | ||
"name": "millisecond", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Convert time strings to milliseconds", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9042
153
0