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 1.0.3 to 1.1.0

index.d.mts

41

index.d.ts
// ./index.d.ts
/**
* convert `str` to ms
*/
export type Units =
'nanosecond' | 'ns' |
'µs' | 'μs' | 'us' | 'microsecond' |
'millisecond' | 'ms' |
'second' | 'sec' | 's' |
'minute' | 'min' | 'm' |
'hour' | 'hr' | 'h' |
'day' | 'd' |
'week' | 'wk' | 'w' |
'month' | 'b' |
'year' | 'yr' | 'y'
declare namespace parse {
/**
* convert `str` to ms
*/
type Units =
'nanosecond' | 'ns' |
'µs' | 'μs' | 'us' | 'microsecond' |
'millisecond' | 'ms' |
'second' | 'sec' | 's' |
'minute' | 'min' | 'm' |
'hour' | 'hr' | 'h' |
'day' | 'd' |
'week' | 'wk' | 'w' |
'month' | 'b' |
'year' | 'yr' | 'y'
}
declare const parse: ((input: string, format?: Units) => number) & {
type Parse = {
(input: string, format?: parse.Units): number | undefined;
[key: string]: number;
};
} & {
default: Parse
}
export default parse;
declare const parse: Parse;
export = parse;

@@ -64,8 +64,9 @@ 'use strict'

str = (str+'').replace(/(\d)[,_](\d)/g, '$1$2')
var isNegative = str[0] === '-';
str.replace(durationRE, function(_, n, units){
units = unitRatio(units)
if (units) result = (result || 0) + parseFloat(n, 10) * units
if (units) result = (result || 0) + Math.abs(parseFloat(n, 10)) * units
})
return result && (result / (unitRatio(format) || 1))
return result && ((result / (unitRatio(format) || 1)) * (isNegative ? -1 : 1))
}

@@ -72,0 +73,0 @@

{
"name": "parse-duration",
"version": "1.0.3",
"version": "1.1.0",
"description": "convert a human readable duration string to a duration format",

@@ -14,5 +14,4 @@ "keywords": [

"exports": {
"require": "./index.js",
"import": "./index.mjs",
"types": "./index.d.ts"
"default": "./index.js"
},

@@ -32,3 +31,4 @@ "dependencies": {},

"index.mjs",
"index.d.ts"
"index.d.ts",
"index.d.mts"
],

@@ -35,0 +35,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

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