Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

millisecond

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

millisecond - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

LICENSE

18

index.js

@@ -13,3 +13,3 @@ /**

var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(ms)
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|wks?|w|years?|yrs?|y)?$/i.exec(ms)
, second = 1000

@@ -19,2 +19,4 @@ , minute = second * 60

, day = hour * 24
, week = day * 7
, year = day * 365
, amount;

@@ -27,2 +29,16 @@

switch (match[2].toLowerCase()) {
case 'years':
case 'year':
case 'yrs':
case 'yr':
case 'y':
return amount * year;
case 'weeks':
case 'week':
case 'wks':
case 'wk':
case 'w':
return amount * week;
case 'days':

@@ -29,0 +45,0 @@ case 'day':

17

package.json
{
"name": "millisecond",
"version": "0.0.1",
"version": "0.1.0",
"description": "Convert time strings to milliseconds",
"main": "index.js",
"scripts": {
"test": "mocha --reporter spec --ui bdd test.js",
"watch": "mocha --watch --reporter spec --ui bdd test.js",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd test.js"
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"test": "mocha test.js",
"watch": "mocha --watch test.js",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"
},

@@ -33,8 +34,8 @@ "repository": {

"devDependencies": {
"assume": "0.0.x",
"assume": "1.1.x",
"istanbul": "0.3.x",
"mocha": "2.0.x",
"pre-commit": "0.0.x"
"mocha": "2.1.x",
"pre-commit": "1.0.x"
},
"homepage": "https://github.com/unshiftio/millisecond"
}
# millisecond
[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/millisecond)[![Build Status][build]](https://travis-ci.org/unshiftio/millisecond)[![Dependencies][david]](https://david-dm.org/unshiftio/millisecond)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/millisecond?branch=master)[![IRC channel][irc]](http://webchat.freenode.net/?channels=unshift)
[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/millisecond)[![Build Status][build]](https://travis-ci.org/unshiftio/millisecond)[![Dependencies][david]](https://david-dm.org/unshiftio/millisecond)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/millisecond?branch=master)[![IRC channel][irc]](https://webchat.freenode.net/?channels=unshift)
[made-by]: https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square
[version]: http://img.shields.io/npm/v/millisecond.svg?style=flat-square
[build]: http://img.shields.io/travis/unshiftio/millisecond/master.svg?style=flat-square
[version]: https://img.shields.io/npm/v/millisecond.svg?style=flat-square
[build]: https://img.shields.io/travis/unshiftio/millisecond/master.svg?style=flat-square
[david]: https://img.shields.io/david/unshiftio/millisecond.svg?style=flat-square
[cover]: http://img.shields.io/coveralls/unshiftio/millisecond/master.svg?style=flat-square
[irc]: http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square
[cover]: https://img.shields.io/coveralls/unshiftio/millisecond/master.svg?style=flat-square
[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square

@@ -68,2 +68,7 @@ Parse strings that indicate a time to their millisecond equivalents.

- `x d`
- `x weeks`
- `x week`
- `x wks`
- `x wk`
- `x w`
- `x years`

@@ -70,0 +75,0 @@ - `x year`

@@ -18,2 +18,14 @@ describe('millisecond', function () {

it('should convert ms to ms', function () {
assume(ms('100ms')).to.equal(100);
});
it('should convert s to ms', function () {
assume(ms('1s')).to.equal(1000);
assume(ms('1sec')).to.equal(1000);
assume(ms('1secs')).to.equal(1000);
assume(ms('1second')).to.equal(1000);
assume(ms('1seconds')).to.equal(1000);
});
it('should convert from m to ms', function () {

@@ -41,12 +53,16 @@ assume(ms('1m')).to.equal(60000);

it('should convert s to ms', function () {
assume(ms('1s')).to.equal(1000);
assume(ms('1sec')).to.equal(1000);
assume(ms('1secs')).to.equal(1000);
assume(ms('1second')).to.equal(1000);
assume(ms('1seconds')).to.equal(1000);
it('should convert w to ms', function () {
assume(ms('1w')).to.equal(604800000);
assume(ms('1wk')).to.equal(604800000);
assume(ms('1wks')).to.equal(604800000);
assume(ms('1week')).to.equal(604800000);
assume(ms('1weeks')).to.equal(604800000);
});
it('should convert ms to ms', function () {
assume(ms('100ms')).to.equal(100);
it('should convert y to ms', function () {
assume(ms('1y')).to.equal(31536000000);
assume(ms('1yr')).to.equal(31536000000);
assume(ms('1yrs')).to.equal(31536000000);
assume(ms('1year')).to.equal(31536000000);
assume(ms('1years')).to.equal(31536000000);
});

@@ -53,0 +69,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc