timer-machine
Advanced tools
Comparing version 0.1.0 to 1.0.0
@@ -149,2 +149,18 @@ /** | ||
/** | ||
* Return a string representation of the timer. | ||
* @return {String} | ||
*/ | ||
Timer.prototype.toString = function () { | ||
return this.time() + 'ms' | ||
} | ||
/** | ||
* Return a numeric value of the timer in milliseconds. | ||
* @return {Number} | ||
*/ | ||
Timer.prototype.valueOf = function () { | ||
return this.time() | ||
} | ||
/** | ||
* Get the current time in milliseconds. | ||
@@ -151,0 +167,0 @@ * @return {Number} |
{ | ||
"name": "timer-machine", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "A lightweight, pause-able timer class", | ||
"main": "lib/timer.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "jshint lib test && mocha" | ||
}, | ||
@@ -26,2 +26,3 @@ "repository": { | ||
"devDependencies": { | ||
"jshint": "^2.5.2", | ||
"mocha": "^1.20.1", | ||
@@ -28,0 +29,0 @@ "should": "^4.0.4", |
@@ -0,1 +1,3 @@ | ||
/*jshint expr: true*/ | ||
var should = require('should') | ||
@@ -2,0 +4,0 @@ var Timer = require('../lib/timer') |
@@ -0,1 +1,3 @@ | ||
/*jshint freeze: false*/ | ||
var originalGetTime = Date.prototype.getTime | ||
@@ -2,0 +4,0 @@ |
@@ -0,1 +1,3 @@ | ||
/*jshint expr: true*/ | ||
var should = require('should') | ||
@@ -2,0 +4,0 @@ var Timer = require('../lib/timer') |
var should = require('should') | ||
var sinon = require('sinon') | ||
var Timer = require('../lib/timer') | ||
var getTimeMock = require('./mocks/date-get-time') | ||
var getTimeMock = require('./mocks/date-get-time') | ||
var timerTimeMock = require('./mocks/timer-time') | ||
@@ -190,2 +191,25 @@ | ||
describe('toString prototype method', function () { | ||
it('should return a string', function () { | ||
timer.toString().should.be.a.String | ||
}) | ||
it('should be a whole number followed by"ms"', function () { | ||
timer.toString().should.match(/\d+ms/) | ||
}) | ||
}) | ||
describe('valueOf prototype method', function () { | ||
it('should be an alias of time()', function () { | ||
var expected = {} | ||
sinon.stub(timer, 'time').returns(expected) | ||
timer.valueOf().should.equal(expected) | ||
timer.time.restore() | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
19285
402
0
274
4