An node logger for colorful with line info supported.
npm install node-lancer自古枪兵幸运E.
!lancer
npm install --save* Example
``nodejs
var util = require('node-lancer');
var logger = require('node-lancer/logger');
var debug = logger('myPkg');
var colors = require('node-lancer/color');
var timestamp = require('node-lancer/timestamp');
var type = require('node-lancer/type');
`
* md5
var md5str = util.md5('out put md5 string');
* escapeHTML
var escapedHTML = util.escapeHTML('
');* unescapeHTML
var unescapedHTML =util.unescapeHTML(escapedHTML);* random
`nodejs
var randomNum = util.random(10);
var randomNum = util.random(-1, 20);
`
* tripBOMvar noBOMBuffer = util.tripBOM(buffer);* forEach, map, every, some, filter
same as the Array.prototype.{METHOD};
`nodejs
var list = util.{forEach|map|every|some|filter}(callback, /context/);
`* toArray, arrayOf
var arr = util.{toArray|arrayOf}(arguments); /same as Array.of/* extend, merge, clone
> util.merge is same as util.extend, util.clone is link util.extend(true, {}, target);
> Same as jQuery.extend;
* specialValueToNormalValue
> trip special values to normal.
> 'NaN' => NaN
> 'Infinity'=> Infinity
> 'Null'=> null
> 'null'=> null
> 'false'=> false
> 'true'=> true
* camelCase
var camelVar = util.camelCase('this-should-be-camel-cased');* namespace
`nodejs
var data = {};
var namespace = 'a.b.c';
// get val;
var val = util.namespace(data, namespace);
// overwrite old value.
util.namespace(data, namespace, 'set value')
// extend new scope data.
util.namespace(data, 'a.b', {d:'don\'t overwrite data',e:'and add this'}, true);
`
* inspect, formatCopied from the node/util
* timestamp
> 'YYYY': y,
> 'M': M,
> 'MM': pad(M),
> 'D': d,
> 'DD': pad(d),
> 'h': H%12,
> 'hh': pad(H%12),
> 'H': H,
> 'HH': pad(H),
> 'm': m,
> 'mm': pad(m),
> 's': s,
> 'ss':pad(s),
> 'S': SSS/100 | 0,
> 'SS': SSS/10 | 0,
> 'SSS': SSS,
> 'P': date > new Date(y,m,d,12,0,0,0) ? 'AM':'PM'
Example
`nodejs
var time = util.timestamp();
// output 2016-03-05 13:57:54
`
* linevar lineInfo = util.line(/number/);`