Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-duration

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-duration

Converts CSS-style durations to milliseconds.

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
84
increased by42.37%
Maintainers
2
Weekly downloads
 
Created
Source

css-duration

Converts CSS-style durations to milliseconds.

var duration = require("css-duration")

duration('1000ms')
// > 1000

duration('1.5s')
// > 1500

duration('30m')
// > 1800000

duration('8h')
// > 28800000

duration('2d')
// > 172800000

Installation

npm install --save css-duration

Usage

duration(time)

Normalizes "unit-based time" (similar to CSS values) into a Number of milliseconds.

Parameters
  • time (String): A CSS-style value of a duration of time (i.e. 10s, 5h, 0.5d)
Units
  • ms: Milliseconds
  • s: Seconds
  • h: Hours
  • d: Days
  • w: Weeks

Note: Anything past seconds is not a valid CSS unit. Use another package for validating.

Example
duration('0.25d')
// => 21600000

duration('-1w')
// => -604800000

License

MIT © Brandon Semilla

Keywords

FAQs

Package last updated on 05 Feb 2017

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