Permalink
Browse files

Better node.js support - module.exports.Time -> module.exports

Before you needed to do

    time = require('time').Time;

but now you can do

    time = require('time');
  • Loading branch information...
1 parent 4100e6f commit 86a0cc4474ae0a75794490caf468a62580fee637 @zackdever committed Sep 10, 2012
Showing with 15 additions and 3 deletions.
  1. +12 −0 README.md
  2. +1 −1 test/time.test.js
  3. +2 −2 time.js
View
@@ -5,6 +5,18 @@ with the option to convert to the next immediate corresponding Date.
Built for [Promt](http://promtapp.com).
+*Node*
+
+ var time = require('time');
+ time('2');
+
+*Browser*
+
+ <script src="time.js"></script>
+ <script>
+ Time('2');
+ </script>
+
Parses strings such as "8:20" into a Date-less Time.
new Time('1') // 1:00
View
@@ -1,4 +1,4 @@
-time = require('../time').Time;
+time = require('../time');
var hours=[], minutes=[], periods=[];
View
@@ -1,6 +1,6 @@
(function() {
- var root = (typeof exports == 'undefined' ? window : exports);
- root.Time = Time;
+ if (typeof module !== 'undefined' && module.exports) module.exports = Time;
+ else window.Time = Time;
Time.re = /^(10|11|12|[1-9])(?::|\.)?([0-5][0-9])?$/;

0 comments on commit 86a0cc4

Please sign in to comment.