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

easy-ms

v1.0.1

Published

Easy and human friendly millisecond implementation that you will love it

Downloads

15

Readme

easy-ms

Build Status npm version Dependency status Downloads Donate

Easy and human friendly millisecond implementation that you will definitely love it

Installation

$ npm install --save easy-ms

Usage

It's easy and versatile. Below show examples of how to return 90,000 milliseconds.

var ms = require('easy-ms');

//the simple
ms(90000) // ms(ms)
ms(90, 0) // ms(s, ms)
ms(1, 30, 0) // ms(m, s, ms)
ms(0, 1, 30, 0) // ms(h, m, s, ms)
ms(0, 0, 1, 30, 0) // ms(d, h, m, s, ms)
ms(0, 0, 0, 1, 30, 0) // ms(y, d, h, m, s, ms)
ms(0, 0, 0.025, 0, 0, 0) // ms(y, d, h, m, s, ms)

//with string as well
ms('1m 30s') //1 minute 30 second
ms('1minute 30s') //1 minute 30 second
ms('1 min 30 sec') //1 minute 30 second
ms('1.5 min') //1 minute 30 second

//with object if you like it this way
ms({minute: 1, second: 30})
ms({min: 1, seconds: 30})
ms({m: 1, s: 30})
ms({m: 0.5, minute: 0.5, second: 15, s: 15}) //I don't know why you want to do it this way, but it is absolutely fine

//chain-able
ms('1m')
    .second(30)
ms(30, 0)
    .m(1)
ms({ms: 1000})
    .second(29)
    .m('1')

//chain-add
ms('1m')
    .s(5)               //chain 5 seconds
    .add('10 seconds')  //you still remember of using strings?
    .add({s: 5})        //or objects
    .add(5, 0)          //or just numbers?
    .second(5)          //it all works

//chain minus
ms('2m')
    .s(5)                 
    .minus('20 seconds')  //maybe you like to minus of some time
    .sub({s: 10})         //or sub?
    .subtract(10, 0)      //or subtract?
    .second(5)            //it's up to you.

We wish we could accept anything to be passed into easy-ms.

But below is a list of what does not work. They will return NaN

ms('1m').second('abc')
ms('1b').hour(5)
ms({m: 'foo'})

Inspiration

Inspired by ms and to-ms.

But do more than both combined.

Caveat

The value returned by the function ms(...) is monkey patched Number. It might created some unwanted behaviors.

var ms = require('easy-ms');
var val = ms(1000); //1000 millisecond

//It is not strictly equal
val == 1000; //return true
val === 1000; //return false

//To circumvent this, use Number(...)
Number(val) === 1000; //return true;
(val + 0) === 1000;	 //return true, but not recommended

//It might print more than you expected in console.log
console.log(a);
/*
return 
{ [Number: 1000]
  year: [Function: bound addTime],
  yrs: [Function: bound addTime],
  yr: [Function: bound addTime],
  ...
*/
console.log(Number(100));
//return 1000

//It works fine in strings
str = 'wait for ' + val; // 'wait for 1000'
str = `wait for ${val}`; // 'wait for 1000'

License

MIT