Add minutes time functions, for a complete range
This commit is contained in:
parent
012578f012
commit
7415daed0c
|
@ -24,7 +24,30 @@ module.exports.uninstall = function() {
|
||||||
|
|
||||||
module.exports.install = function() {
|
module.exports.install = function() {
|
||||||
/**
|
/**
|
||||||
* Multiplies a number by 1000 to get time in milliseconds
|
* Multiplies a number by 60000 to convert minutes
|
||||||
|
* to milliseconds
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* (2).minutes(); //=> 120000
|
||||||
|
* @return {Number} time in milliseconds
|
||||||
|
*/
|
||||||
|
Number.prototype.minutes = function() {
|
||||||
|
return this * 60000;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for Number.prototype.minutes
|
||||||
|
*
|
||||||
|
* @see Number.prototype.minute
|
||||||
|
* @example
|
||||||
|
* (1).minute(); //=>60000
|
||||||
|
* @return {Number} time in milliseconds
|
||||||
|
*/
|
||||||
|
Number.prototype.minute = Number.prototype.minutes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiplies a number by 1000 to convert seconds
|
||||||
|
* to milliseconds
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* (2).seconds(); //=> 2000
|
* (2).seconds(); //=> 2000
|
||||||
|
@ -66,7 +89,9 @@ module.exports.install = function() {
|
||||||
Number.prototype.ms = Number.prototype.milliseconds;
|
Number.prototype.ms = Number.prototype.milliseconds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Divides a number by 1000 to get time in microseconds
|
* Converts microseconds to milliseconds.
|
||||||
|
* Note that timing of events in terms of microseconds
|
||||||
|
* is not very accurate in JS.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* (2000).microseconds(); //=> 2
|
* (2000).microseconds(); //=> 2
|
||||||
|
|
|
@ -77,6 +77,18 @@ describe("monkey-patches", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#minutes", function() {
|
||||||
|
it("allows for expressing time in minutes", function() {
|
||||||
|
expect((5).minutes()).to.be.eql(300000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#minute", function() {
|
||||||
|
it("allows for expressing time per minute", function() {
|
||||||
|
expect((1).minute()).to.be.eql(60000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#fromScale", function() {
|
describe("#fromScale", function() {
|
||||||
it("converts a value from one scale to 0-1 scale", function() {
|
it("converts a value from one scale to 0-1 scale", function() {
|
||||||
expect((5).fromScale(0, 10)).to.be.eql(0.5);
|
expect((5).fromScale(0, 10)).to.be.eql(0.5);
|
||||||
|
|
Loading…
Reference in New Issue