Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
duration-pretty
Advanced tools
A pure JavaScript library that parses duration time length to format display
The plugin is a pure JavaScript library that parses duration time length to format display.
npm install --save duration-pretty
The duration(timestamp, type)
get two parameters: timestamp && type.
timestamp: number
type: seconds | milliseconds
Format duration time using a template string to format()
.
var { duration } = require('duration-pretty')
duration(7380, 'seconds').format('H:mm') // "2:03"
duration(36610000333, 'milliseconds').format('Y:MM:DD:HH:mm:ss:SSS') // "1:01:28:17:26:40:333"
or using ES6 Module:
import { duration } from 'duration-pretty'
duration(7380, 'seconds').format('H:mm') // "2:03"
The template string is parsed for universal token characters, which are replaced with the duration's value for each unit type. The tokens are:
years: Y
months: M | MM
days: D | DD
hours: H | HH
minutes: m | mm
seconds: s | ss
milliseconds: SSS
Escape token characters within the template string using []
.
duration(3661, 'seconds').format('H [[H]], m [[m] countdown]') // "1 [H], 1 [m countdown]"
You can find all cases in files:/test/*.spec.js
, And testing Using below script.
npm run test
FAQs
A pure JavaScript library that parses duration time length to format display
The npm package duration-pretty receives a total of 3 weekly downloads. As such, duration-pretty popularity was classified as not popular.
We found that duration-pretty demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.