Created
April 24, 2015 16:09
-
-
Save idmontie/0ea277d2abf724fb5725 to your computer and use it in GitHub Desktop.
TODO By for JavaScript
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
// Inspired by https://github.com/andyw8/do_by | |
// Usage: | |
// TODO( 'Finish this feature', 'Decemeber 25, 2015' ); | |
// TODO( 'Finish this feature', '12/15/2015' ); | |
this.TODO = function () { | |
var message = arguments[0]; | |
var date = arguments[1] || false; | |
// TODO only set the hours to zero if no time is provided in the TODO | |
if ( new Date( Date.parse( date ) ) < ( new Date() ).setHours( 0, 0, 0, 0 ) ) { | |
throw new Error( message + ' is past due! Should have been completed by ' + date ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be able to easily make this an NPM and Meteor package.