Skip to content

Commit

Permalink
fix: update timeArray validation to handle non-numeric strings (#49)
Browse files Browse the repository at this point in the history
* fix: update timeArray validation to handle non-numeric strings

* chore: rename function argument: seconds to timeString
  • Loading branch information
matzar authored Sep 5, 2023
1 parent 00e5cae commit 627ead7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";

module.exports = function (seconds) {
let timeArray = seconds.split(":");
module.exports = function (timeString) {
let timeArray = timeString.split(":");

if (timeArray.some(isNaN))
if (timeArray.some((val) => Number.isNaN(Number(val))))
throw new TypeError(
'time-to-seconds: wrong argument type - something else than a number string in format "number", "number:number" or "number:number:number" was passed. See documentation for more information on argument formatting: https://www.npmjs.com/package/time-to-seconds.'
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matzar/time-to-seconds",
"version": "2.1.2",
"version": "2.1.3",
"description": "Non-strict format, time to seconds converter ",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 627ead7

Please sign in to comment.