timestring
Advanced tools
Comparing version 5.0.1 to 6.0.0
# 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 | ||
[](http://travis-ci.org/mike182uk/timestring) | ||
[](https://codeclimate.com/github/mike182uk/timestring) | ||
[](https://coveralls.io/r/mike182uk/timestring) | ||
@@ -162,1 +161,12 @@ [](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 | ||
``` |
11314
7
171