-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old browsers support, add UMD builds
- Loading branch information
Showing
8 changed files
with
82 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
._* | ||
node_modules | ||
lib-cov | ||
coverage.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.toMs=e()}}(function(){var define,module,exports;module={exports:(exports={})}; | ||
/* globals define, window */ | ||
/* jshint -W053 */ | ||
|
||
'use strict'; | ||
|
||
module.exports = extended(new Number(0)); | ||
|
||
function extended(number) { | ||
number.second = addMs.bind(number, 1e3, 1); | ||
number.seconds = addMs.bind(number, 1e3); | ||
number.minute = addMs.bind(number, 6e4, 1); | ||
number.minutes = addMs.bind(number, 6e4); | ||
number.hour = addMs.bind(number, 36e5, 1); | ||
number.hours = addMs.bind(number, 36e5); | ||
number.day = addMs.bind(number, 864e5, 1); | ||
number.days = addMs.bind(number, 864e5); | ||
number.week = addMs.bind(number, 6048e5, 1); | ||
number.weeks = addMs.bind(number, 6048e5); | ||
number.year = addMs.bind(number, 31536e6, 1); | ||
number.years = addMs.bind(number, 31536e6); | ||
return number; | ||
} | ||
|
||
function addMs(mlp, val) { | ||
val = mlp * (+val || 0); | ||
return extended(new Number(this + val)); | ||
} | ||
|
||
return module.exports;}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,27 @@ | ||
/* globals define, window */ | ||
/* jshint -W053 */ | ||
|
||
'use strict'; | ||
|
||
(function (factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define(factory); // AMD support | ||
} else if (typeof exports !== 'undefined') { | ||
module.exports = factory(); // CommonJS support | ||
} else { | ||
window.toMs = factory(); // Non-modular execution | ||
} | ||
})(function () { | ||
module.exports = extended(new Number(0)); | ||
|
||
function _extended(number) { | ||
number.second = _bind(_addMs, number, 1e3, 1); | ||
number.seconds = _bind(_addMs, number, 1e3); | ||
number.minute = _bind(_addMs, number, 6e4, 1); | ||
number.minutes = _bind(_addMs, number, 6e4); | ||
number.hour = _bind(_addMs, number, 36e5, 1); | ||
number.hours = _bind(_addMs, number, 36e5); | ||
number.day = _bind(_addMs, number, 864e5, 1); | ||
number.days = _bind(_addMs, number, 864e5); | ||
number.week = _bind(_addMs, number, 6048e5, 1); | ||
number.weeks = _bind(_addMs, number, 6048e5); | ||
number.year = _bind(_addMs, number, 31536e6, 1); | ||
number.years = _bind(_addMs, number, 31536e6); | ||
return number; | ||
} | ||
function extended(number) { | ||
number.second = addMs.bind(number, 1e3, 1); | ||
number.seconds = addMs.bind(number, 1e3); | ||
number.minute = addMs.bind(number, 6e4, 1); | ||
number.minutes = addMs.bind(number, 6e4); | ||
number.hour = addMs.bind(number, 36e5, 1); | ||
number.hours = addMs.bind(number, 36e5); | ||
number.day = addMs.bind(number, 864e5, 1); | ||
number.days = addMs.bind(number, 864e5); | ||
number.week = addMs.bind(number, 6048e5, 1); | ||
number.weeks = addMs.bind(number, 6048e5); | ||
number.year = addMs.bind(number, 31536e6, 1); | ||
number.years = addMs.bind(number, 31536e6); | ||
return number; | ||
} | ||
|
||
function _addMs(multiplier, value) { | ||
var _value = multiplier * (+value); | ||
var number = new Number(this + _value || 0); | ||
return _extended(number); | ||
} | ||
|
||
function _bind(fn, ctx) { | ||
var _args = Array.prototype.slice.call(arguments, 2); | ||
return function() { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
return fn.apply(ctx, _args.concat(args)); | ||
}; | ||
} | ||
|
||
return function () { | ||
var number = new Number(0); | ||
return _extended(number); | ||
}; | ||
|
||
}()); | ||
function addMs(mlp, val) { | ||
val = mlp * (+val || 0); | ||
return extended(new Number(this + val)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<html> | ||
<head> | ||
<title>to-ms - tests</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<link rel="stylesheet" href="https://cdn.rawgit.com/visionmedia/mocha/1.20.1/mocha.css" /> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script src="https://cdn.rawgit.com/visionmedia/mocha/1.20.1/mocha.js"></script> | ||
<script src="https://cdn.rawgit.com/shouldjs/should.js/master/should.min.js"></script> | ||
<script>mocha.setup('bdd')</script> | ||
<script src="to-ms.js"></script> | ||
<script src="test.js"></script> | ||
<script> | ||
mocha.run(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../dest/to-ms.js |