npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

css-time

v0.1.12

Published

A tiny library that converts milliseconds to and from CSS time.

Downloads

3,060

Readme

css-time.js

Build status

A tiny JavaScript library that converts milliseconds to and from CSS time.

Why would I want that?

Converting to and from CSS time is really not difficult. But this library saves you the bother of making sure you get it right and is well-supported by unit tests. It's one less thing to worry about, right? :)

How tiny is it?

1.4 kb unminified with comments, 0.5 kb minified, 0.3 kb minified + gzipped

How do I install it?

If you're using npm:

npm install css-time --save

Or if you just want the git repo:

git clone [email protected]:philbooth/css-time.js.git

If you're into other package managers, it is also available from Bower, Component and Jam.

How do I use it?

Loading the library

If you are running in Node.js, Browserify or another CommonJS-style environment, you can require check-types like so:

var check = require('css-time');

It also the supports the AMD-style format preferred by Require.js.

If you are including css-time.js with an HTML <script> tag, or neither of the above environments are detected, it will export the interface globally as cssTime.

Calling the exported functions

Two functions are exported, from and to.

from (string)

Returns the number of milliseconds represented by a CSS time string. If the argument can't be parsed as a CSS time, an error is thrown.

cssTime.from('500ms'); // returns 500
cssTime.from('-1.5s'); // returns -1500

to (number)

Returns a CSS time string representing the number of milliseconds passed in the argument. If the argument is not a number, an error is thrown.

cssTime.to(500); // returns '500ms'
cssTime.to(-0.5); // returns '-0.5ms'

Where can I use it?

The code is all written in ES3 syntax, so works in any browser.

How do I set up the build environment?

Dependencies

The build environment relies on Node.js, NPM, JSHint, Mocha, Chai and UglifyJS. Assuming that you already have Node.js and NPM set up, you just need to run npm install to install all of the dependencies as listed in package.json.

The unit tests are in test/css-time.js. You can run them with the command npm test. To run the tests in a browser, open test/css-time.html.

What license is it released under?

MIT