zouti
v0.5.0
Published
Useful tools & functions (loggin' & hashin').
Downloads
25
Readme
zouti
Useful tools & functions we use on every krkn projects.
Getting Started
Install the module with: npm install zouti
var zouti = require( "zouti" );
Documentation
zouti.log( message, context, type )
Print a formated console log like below, with date, context between brackets, then message.
5 Mar 22:58:06 - [node] foo
The type
parameter is a String
which can be :
"ERROR"
,"ERR"
,"RED"
: print the message in red"WARNING"
,"WARN"
,"YELLOW"
: print the message in yellow"SUCCESS"
,"GREEN"
: print the message in green"MAGENTA"
: print the message in magenta- every other values prints the message in cyan
zouti.warning( message, context ), zouti.warn( message, context )
Alias for zouti.log( message, context, "WARNING" )
zouti.error( message, context ), zouti.notOk( message, context )
Alias for zouti.log( message, context, "ERROR" )
zouti.success( message, context ), zouti.ok( message, context )
Alias for zouti.log( message, context, "SUCCESS" )
zouti.spacer( amount )
Print amount
(defaults to 1
) empty console lines, as visual spacer.
zouti.mute()
Muting zouti by disable all the console.log calls until zouti.unmute()
is called.
Note: if zouti is already muted, does nothing.
zouti.unmute()
Unmute zouti.
Note: if zouti is already unmuted, does nothing.
zouti.muted
Property returning a boolean
, indicating the mute status of zouti.
zouti.clearConsole()
Clear the console by sending the string \u001B[2J\u001B[0;0f
to it.
zouti.bench( name, log )
Called the first time, start a benchmark.
When it's called the second time with the same name
, stop the benchmark and print elapsed time (if the log
argument is set to true - which is by default), in milliseconds.
The second call returns an object with literal and numerical values (in milliseconds).
zouti.uuid()
Generate an UUID compliant to RFC 4122.
zouti.sleep( duration )
Make the program sleep for duration
seconds.
Note: this function must be used with care, eats a lot of CPU's power.
zouti.md5( string ), zouti.sha1( string ), zouti.sha256( string ), zouti.sha512( string ), zouti.whirlpool( string )
Returns the hashed version of the given string, using the specified algorythm.
These functions use the native crypto
module of node.js.
zouti.kindOf( value )
Returns the type of the given value, returning number
, string
, boolean
, function
, regexp
, array
, date
, error
, null
, undefined
or object
.
Based on grunt.util.kindOf
.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Lint your code using Grunt.
Release History
- 0.0.1: initial release (05/03/2014)
- 0.1.0: refactor
bench
method (08/06/2014) - 0.2.0: add
clearConsole
method (03/10/2014) - 0.3.0: add aliases for
log
method (11/02/2015) - 0.4.0: add
mute
andunmute
methods (12/01/2016) - 0.5.0: add
spacer
method (24/05/2016)
License
Copyright (c) 2014 leny & krkn
Licensed under the WTFPL license.