diff --git a/index.js b/index.js index c29aad0..b7b8aa2 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,7 @@ var defaultOpts = { */ var unitMap = { + ms: ['ms', 'milli', 'millisecond', 'milliseconds'], s: ['s', 'sec', 'secs', 'second', 'seconds'], m: ['m', 'min', 'mins', 'minute', 'minutes'], h: ['h', 'hr', 'hrs', 'hour', 'hours'], @@ -79,6 +80,7 @@ function parseTimestring(string, returnUnit, opts) { function getUnitValues(opts) { var unitValues = { + ms: 0.001, s: 1, m: 60, h: 3600, diff --git a/test.js b/test.js index 160971d..03ff6f4 100644 --- a/test.js +++ b/test.js @@ -5,6 +5,7 @@ var timestring = require('./index'); describe('timestring', function() { it('can parse a timestring', function() { + expect(timestring('500ms')).to.equal(0.5); expect(timestring('1s')).to.equal(1); expect(timestring('1m')).to.equal(60); expect(timestring('1h')).to.equal(3600); @@ -15,6 +16,7 @@ describe('timestring', function() { }); it('can return a value in a specified unit', function() { + expect(timestring('1m', 'ms')).to.equal(60000); expect(timestring('5m', 's')).to.equal(300); expect(timestring('5m', 'm')).to.equal(5); });