parse-duration
Advanced tools
Comparing version 0.4.4 to 0.5.0
11
index.js
'use strict' | ||
var duration = /(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([a-zµμ]*)/ig | ||
var durationRE = /(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([a-zµμ]*)/ig | ||
@@ -22,3 +22,4 @@ module.exports = parse | ||
parse.millisecond = | ||
parse.ms = 1 | ||
parse.ms = | ||
parse[''] = 1 | ||
@@ -62,5 +63,5 @@ parse.second = | ||
var result = null | ||
// ignore commas | ||
str = str.replace(/(\d),(\d)/g, '$1$2') | ||
str.replace(duration, function(_, n, units){ | ||
// ignore commas/placeholders | ||
str = (str+'').replace(/(\d)[,_](\d)/g, '$1$2') | ||
str.replace(durationRE, function(_, n, units){ | ||
units = parse[units] || parse[units.toLowerCase().replace(/s$/, '')] | ||
@@ -67,0 +68,0 @@ if (units) result = (result || 0) + parseFloat(n, 10) * units |
{ | ||
"name": "parse-duration", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"description": "convert a human readable duration string to a duration format", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
6400
121