Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@types/humanize-duration
Advanced tools
TypeScript definitions for humanize-duration
@types/humanize-duration provides TypeScript type definitions for the humanize-duration library, which is used to convert durations, given in milliseconds, into human-readable strings.
Basic Usage
Converts a duration in milliseconds to a human-readable string.
const humanizeDuration = require('humanize-duration');
const humanized = humanizeDuration(3000); // '3 seconds'
Custom Units
Allows customization of the units used in the output string.
const humanizeDuration = require('humanize-duration');
const humanized = humanizeDuration(3000, { units: ['h', 'm', 's'] }); // '3 seconds'
Language Support
Supports multiple languages for the output string.
const humanizeDuration = require('humanize-duration');
const humanized = humanizeDuration(3000, { language: 'es' }); // '3 segundos'
Round
Rounds the output to the nearest integer.
const humanizeDuration = require('humanize-duration');
const humanized = humanizeDuration(3000, { round: true }); // '3 seconds'
Largest
Limits the number of units in the output string.
const humanizeDuration = require('humanize-duration');
const humanized = humanizeDuration(3000, { largest: 1 }); // '3 seconds'
Moment.js is a widely-used library for parsing, validating, manipulating, and formatting dates. It includes duration formatting capabilities similar to humanize-duration but offers a broader range of date and time manipulation features.
date-fns is a modern JavaScript date utility library that provides a variety of functions for working with dates, including formatting durations. It is modular and tree-shakeable, making it a lightweight alternative to Moment.js.
Luxon is a library for working with dates and times in JavaScript. It is a modern alternative to Moment.js and includes features for formatting durations, along with extensive support for time zones and internationalization.
npm install --save @types/humanize-duration
This package contains type definitions for humanize-duration (https://github.com/EvanHahn/HumanizeDuration.js).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/humanize-duration.
These definitions were written by Piotr Błażejewicz, and Evan Hahn.
FAQs
TypeScript definitions for humanize-duration
The npm package @types/humanize-duration receives a total of 130,832 weekly downloads. As such, @types/humanize-duration popularity was classified as popular.
We found that @types/humanize-duration demonstrated a healthy version release cadence and project activity because the last version was released less than 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.