Socket
Socket
Sign inDemoInstall

parse-duration

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-duration - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

13

index.js
'use strict'
var duration = /(-?\d*\.?\d+(?:e[-+]?\d+)?)\s*([a-zµμ]*)/ig
var duration = /(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([a-zµμ]*)/ig

@@ -41,4 +41,5 @@ module.exports = parse

parse.month =
parse.b =
parse.month = parse.d * (365.25 / 12)
parse.d * (365.25 / 12)

@@ -57,12 +58,10 @@ parse.year =

function parse(str){
var result = 0
var result = null
// ignore commas
str = str.replace(/(\d),(\d)/g, '$1$2')
str.replace(duration, function(_, n, units){
units = parse[units]
|| parse[units.toLowerCase().replace(/s$/, '')]
|| 1
result += parseFloat(n, 10) * units
units = parse[units] || parse[units.toLowerCase().replace(/s$/, '')]
if (units) result = (result || 0) + parseFloat(n, 10) * units
})
return result
}
{
"name": "parse-duration",
"version": "0.2.0",
"version": "0.2.1",
"description": "convert a human readable duration string to ms",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc