Skip to content

ChangJoo-Park/dtms

Repository files navigation

dtms - CSS d[uration|elay] to milliseconds

dtms is <time> of CSS parse in to milliseconds for JavaScript.

Install

yarn add dtms # npm install dtms

Usage

import { dtms } from 'dtms'
dtms('0.2s') // returns 200 (milliseconds)
dtms('2s') // returns 2000 (milliseconds)
dtms('0s') // returns 0 (milliseconds)
dtms('-1s') // returns -1000 may not working with transition

// Not Allowed
dtms('') // Not alllowed empty string.
dtms('2m') // Only support ms and s from CSS specification

Why only support milliseconds?

CSS <time> should be 'ms' and 's'.

https://developer.mozilla.org/en-US/docs/Web/CSS/time

About

Duration string to integer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published