New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc