Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
A tiny JavaScript library that converts milliseconds to and from CSS time.
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? :)
1.4 kb unminified with comments, 0.5 kb minified, 0.3 kb minified + gzipped
If you're using npm:
npm install css-time --save
Or if you just want the git repo:
git clone git@github.com:philbooth/css-time.js.git
If you're into other package managers, it is also available from Bower, Component and Jam.
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
.
Two functions are exported, from
and to
.
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
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'
The code is all written in ES3 syntax, so works in any browser.
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
.
FAQs
A tiny library that converts milliseconds to and from CSS time.
The npm package css-time receives a total of 366 weekly downloads. As such, css-time popularity was classified as not popular.
We found that css-time demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.