🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

moment-duration-format-frequency

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-duration-format-frequency

Formats moment duration as frequency to human readable string

1.1.0
latest
Source
npm
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

Moment Duration Format Frequency

Format plugin for the Moment Duration object.

This is a plugin to the Moment.js JavaScript date library to add frequency formatting to Moment Durations.

Installation

Node.js

npm install moment-duration-format-frequency

Usage

Module

To use this plugin as a module, use the require function:

require("moment-duration-format-frequency");

The plugin does not export anything, so there is no need to assign the require output to a variable.

The plugin depends on moment.js.

Basics

The duration format method can format moment durations as human readable frequencies:

moment.duration(1.5, 'weeks').formatAsFrequency('weeks');
// "every 1-2 weeks"

moment.duration(0.23, 'weeks').formatAsFrequency('weeks');
// "4-5 times per week"

moment.duration(3, 'weeks').formatAsFrequency('weeks');
// "every 3 weeks"

moment.duration(0.25, 'weeks').formatAsFrequency('weeks');
// "4 times per week"

moment.duration(3, 'years').formatAsFrequency('years');
// "every 3 years"

Customization

Individual strings can be customized:

moment.duration.fn.formatAsFrequency.defaults.everyString = 'alle';

moment.duration(3, 'years').formatAsFrequency('years');
// "alle 3 years"

Keywords

frequency

FAQs

Package last updated on 16 Oct 2015

Did you know?

Socket

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.

Install

Related posts