clock-time
Advanced tools
Comparing version 2.3.1 to 3.0.0
46
index.js
@@ -0,28 +1,26 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
function padSeconds(seconds) { | ||
return ('0' + seconds).slice(-2); | ||
return ('0' + seconds).slice(-2); | ||
} | ||
function toClockParts(ms, options = {}) { | ||
const total = Math.ceil(ms / 1000); | ||
const minutes = Math.floor(total / 60); | ||
const seconds = total - minutes * 60; | ||
return { | ||
total, | ||
minutes, | ||
seconds: options.noPad ? seconds : padSeconds(seconds) | ||
}; | ||
function toClockParts(ms, disablePadding) { | ||
var total = Math.ceil(ms / 1000); | ||
var minutes = Math.floor(total / 60); | ||
var seconds = total - minutes * 60; | ||
return { | ||
total: total, | ||
minutes: minutes, | ||
seconds: disablePadding ? seconds : padSeconds(seconds) | ||
}; | ||
} | ||
const separator = ':'; | ||
function clockTime() { | ||
if (arguments.length > 1) { | ||
return arguments[0] + separator + padSeconds(arguments[1]); | ||
} | ||
const clockParts = toClockParts(arguments[0]); | ||
return clockParts.minutes + separator + clockParts.seconds; | ||
exports.toClockParts = toClockParts; | ||
var separator = ':'; | ||
function clockTime(ms, seconds) { | ||
if (seconds) { | ||
return ms + separator + padSeconds(seconds); | ||
} | ||
var clockParts = toClockParts(ms); | ||
return clockParts.minutes + separator + clockParts.seconds; | ||
} | ||
module.exports = clockTime; | ||
module.exports.toClockParts = toClockParts; | ||
module.exports.clockTime = clockTime; | ||
exports.clockTime = clockTime; | ||
exports["default"] = clockTime; |
{ | ||
"name": "clock-time", | ||
"version": "2.3.1", | ||
"version": "3.0.0", | ||
"description": "Formats milliseconds or minutes and seconds as clock time", | ||
@@ -18,10 +18,14 @@ "author": "Trevor Blades <tdblades@gmail.com>", | ||
"scripts": { | ||
"pretest": "eslint ./", | ||
"test": "jest" | ||
"pretest": "eslint src/*", | ||
"test": "jest", | ||
"prepare": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@trevorblades/eslint-config": "^6.22.2", | ||
"@trevorblades/eslint-config": "^7.0.0", | ||
"@types/jest": "^24.0.15", | ||
"eslint": "^6.0.1", | ||
"jest": "^24.8.0" | ||
"jest": "^24.8.0", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.5.3" | ||
} | ||
} |
@@ -34,3 +34,3 @@ # Clock Time | ||
`toClockParts` also accepts an object of options as a second argument. You can disable zero-padding on the returned `seconds` property by passing `{noPad: true}` to the function. | ||
If the second argument to `toClockParts` is `true`, zero-padding on the returned `seconds` property will be disabled and `seconds` will be a number. | ||
@@ -37,0 +37,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2695
26
6
3