Skip to content

Instantly share code, notes, and snippets.

@danpaz
Created June 19, 2014 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danpaz/6774f221a9f73013f8c5 to your computer and use it in GitHub Desktop.
Save danpaz/6774f221a9f73013f8c5 to your computer and use it in GitHub Desktop.
// A code sonnet for Utilities
util = require( 'util' );
switch( process.argv[2] ) {
case 'stdout':
util.puts( 'Hello World' );
util.log( 'Console log with a timestamp!' );
break;
case 'formatting':
var exdate = new Date();
var isdate = util.isDate( exdate );
var formatted = util.format( '%d/%d/%d',
exdate.getDate().toString(),
exdate.getMonth().toString(),
exdate.getFullYear() );
util.puts( 'The date is a date?: ' + isdate + '. And is formatted: ' + formatted );
break;
case 'lookattheguts':
util.puts( util.inspect( util, { showHidden: true, depth: null, colors: true } ) );
break;
case 'sweetstyles':
util.puts( util.inspect( util.inspect.styles ) );
util.puts( util.inspect( util.inspect.colors ) );
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment