🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

timestring

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timestring - npm Package Compare versions

Comparing version

to
6.0.0

5

CHANGELOG.md
# Changelog
## 6.0.0
- Drop support for Node.js `< 8.0.0`
- Throw an error when unable to parse a timestring ([prolink007](https://github.com/prolink007))
## 5.0.1

@@ -4,0 +9,0 @@

18

index.js

@@ -1,3 +0,1 @@

'use strict'
/**

@@ -59,11 +57,13 @@ * Exports

if (groups !== null) {
groups.forEach(group => {
let value = group.match(/[0-9.]+/g)[0]
let unit = group.match(/[a-z]+/g)[0]
totalSeconds += getSeconds(value, unit, unitValues)
})
if (groups === null) {
throw new Error(`The string [${string}] could not be parsed by timestring`)
}
groups.forEach(group => {
let value = group.match(/[0-9.]+/g)[0]
let unit = group.match(/[a-z]+/g)[0]
totalSeconds += getSeconds(value, unit, unitValues)
})
if (returnUnit) {

@@ -70,0 +70,0 @@ return convert(totalSeconds, returnUnit, unitValues)

{
"name": "timestring",
"version": "5.0.1",
"version": "6.0.0",
"description": "Parse a human readable time string into a time based value",

@@ -29,14 +29,13 @@ "main": "index.js",

"engines": {
"node": ">=4"
"node": ">=8"
},
"devDependencies": {
"chai": "^4.0.1",
"codeclimate-test-reporter": "^0.5.0",
"coveralls": "^3.0.0",
"istanbul": "^0.4.1",
"mocha": "^5.0.0",
"chai": "^4.2.0",
"coveralls": "^3.0.3",
"istanbul": "^0.4.5",
"mocha": "^6.1.4",
"mocha-lcov-reporter": "1.3.0",
"standard": "^11.0.0",
"watch": "^1.0.1"
"standard": "^12.0.1",
"watch": "^1.0.2"
}
}

@@ -5,3 +5,2 @@ # timestring

[![Build Status](https://img.shields.io/travis/mike182uk/timestring.svg?style=flat-square)](http://travis-ci.org/mike182uk/timestring)
[![Code Climate](https://img.shields.io/codeclimate/github/mike182uk/timestring.svg?style=flat-square)](https://codeclimate.com/github/mike182uk/timestring)
[![Coveralls](https://img.shields.io/coveralls/mike182uk/timestring/master.svg?style=flat-square)](https://coveralls.io/r/mike182uk/timestring)

@@ -162,1 +161,12 @@ [![npm](https://img.shields.io/npm/dm/timestring.svg?style=flat-square)](https://www.npmjs.com/package/timestring)

It is important to note that the `daysPerYear` configuration option will be used to convert a month or year to seconds, so if you are using custom configuration options make sure that you adjust this value to suit if you expect to be parsing timestrings containing months or years.
## Notes
If the string that is passed into `timestring` can not be parsed then an error will be thrown:
```js
const timestring = require('timestring')
let str = 'aaabbbccc'
let time = timestring(str) // will throw an error
```