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 🙏

© 2026 – Pkg Stats / Ryan Hefner

millit

v0.0.7

Published

This utility allow convert strings to milliseconds.

Downloads

3

Readme

Millit

This utility allow convert strings to milliseconds. You can use even compost times.

Examples

millit('10 days') // 864000000
millit('10d') // 864000000
millit('5h') // 18000000
millit('12 hrs') // 43200000
millit('2.5hours') // 9000000
millit('1min 10s') // 70000
millit('10d 5seconds') // 864005000
millit('1year 45days') // 35445600000
millit("45days 1year") // 35445600000 - sames as before, order doesn't matter
millit('100h 12m') // 360720000
millit('1 days') // 86400000
millit('20') // 20
millit('-200h') // -720000000

Installation

Install it with you favorite package manager:

npm install millit
OR
yarn add millit

Usage:

If you are using plain javascript:

const millit = require("millit")

millit("10d")

if you are using typescript:

import millit from "millit"

millit("10d")

Features

The fact that the order doesn't matter empowers you to dynammically sum up different dates whitout be afraid of date inconsistencies. Example:

let myDateStr = "10d"
let sum10m = true

if(sum10m) {
  myDateStr += "10m"
  console.log(millit(myDateStr)) //864600000
} else {
  myDateStr += "1y"
  console.log(millit(myDateStr)) // 32421600000
}

hint: Try to change sum10m to false

disclaimer: When dynammically summing milliseconds along with other time units as above, always include the "ms" prefix. For example, "10d 10ms 20m" works as expected, while omitting the "ms" prefix in expressions like "10d 10 20m" will result in a silent error (NaN).

How it compares with MS

const tenDays = ms("10d")
const tenSecs = ms("10s")
const withMs = tenDays + tenSecs

const withMillit = millit("10d 10s")
console.log(withMs === withMillit) // true

console.log(ms(withMs)) // 10d
console.log(millit(withMillit)) // 10d

hint: This package is written intended to be fully compatible with the results that ms would give.

Performance

This package is just a convenience for small projects. It is not intended to be a substitute for "ms" as this package uses simple for loops to search through strings. It's not as powerful as "ms" which uses regex search, known to be faster for larger inputs.

Contribution

Contributions are welcome! If you want to contribute with this project, follow the steps:

  1. Fork this repository
  2. Create a branch: git checkout -b my-contribution
  3. Do your changes and commit it: git commit -m "fix: fix XYZ"
  4. Send your changes to the remote repository: git push origin my-contribution
  5. Open a pull request in the original repository

Thanks in advance!