Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "zaq", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Yet another fun little logging utility.", | ||
"main": "zaq.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node test.js" | ||
}, | ||
@@ -30,5 +30,5 @@ "repository": { | ||
"chalk": "^1.1.3", | ||
"node-jawn": "^1.1.11", | ||
"node-jawn": "^1.1.13", | ||
"underscore": "^1.8.3" | ||
} | ||
} |
# zaq |
119
zaq.js
@@ -5,35 +5,94 @@ var jawn = require('node-jawn'); | ||
var zaq = { | ||
log: console.log, | ||
err: function (x) { | ||
return this.log(chalk.bold.red(' x ERROR: '), x); | ||
}, | ||
warn: function (x) { | ||
return this.log(chalk.bold.yellow(' ! WARNING: '), x); | ||
}, | ||
info: function (x) { | ||
return this.log(chalk.bold.blue(' → INFO: '), x); | ||
}, | ||
win: function (x) { | ||
return this.log(chalk.bold.green(' ✓ SUCCESS: '), x); | ||
}, | ||
json: function (x) { this.log(jawn.wrapDoubleBreaks(JSON.stringify(x, null, ' '))); }, | ||
lines: Array(70).join('='), | ||
before: function (obj, funcName) { | ||
this.log(this.lines + "\n" + this.lines + "\n"); | ||
if (funcName) this.log(' RUNNING', funcName); | ||
this.json(obj); | ||
}, | ||
during: function (obj) { | ||
this.log('\t. . .', obj, '\t. . .'); | ||
}, | ||
after: function (obj) { | ||
this.log(chalk.grey('\n- - - - - ->\n')); | ||
this.json(obj); | ||
}, | ||
mini: function (str) { | ||
return (_.isString(str) ? str : str.toString()).trim().substr(0, 100) | ||
var zaq = {}; | ||
zaq.log = console.log; | ||
zaq.err = function (x) { | ||
return zaq.log(chalk.bold.red(' x ERROR: '), x); | ||
}; | ||
zaq.warn = function (x) { | ||
return zaq.log(chalk.bold.yellow(' ! WARNING: '), x); | ||
}; | ||
zaq.info = function (x) { | ||
return zaq.log(chalk.bold.blue(' → INFO: '), x); | ||
}; | ||
zaq.win = function (x) { | ||
return zaq.log(chalk.bold.green(' ✓ SUCCESS: '), x); | ||
}; | ||
zaq.time = function (x) { | ||
return zaq.log(chalk.bold.cyan(' ⏳ TIME: '), x); | ||
} | ||
zaq.pretty = function (content) { | ||
return JSON.stringify(content, null, ' '); | ||
} | ||
zaq.space = function (content) { | ||
return zaq.log(jawn.wrapDoubleBreaks(content)); | ||
} | ||
zaq.json = function (x, y) { | ||
var label, content; | ||
if (y) { | ||
label = x; | ||
content = zaq.pretty(y); | ||
} else { | ||
content = zaq.pretty(x); | ||
} | ||
zaq.log((label ? label + ': \n' : '') + jawn.wrapDoubleBreaks(content)); | ||
}; | ||
// Lines & Dividers -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ | ||
zaq.divider = function (text, lines) { | ||
zaq.log(text + ' ' + zaq.nLines(process.stdout.columns - (text.length + 1), lines)); | ||
} | ||
zaq.nLines = function (n, lines) { | ||
if (!lines) lines = "="; | ||
return Array(n).join(lines); | ||
} | ||
zaq.lines = zaq.nLines(process.stdout.columns); | ||
// Inspection -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ | ||
zaq.before = function (obj, funcName) { | ||
zaq.log(zaq.lines + "\n" + zaq.lines + "\n"); | ||
if (funcName) zaq.log(' RUNNING', funcName); | ||
zaq.json(obj); | ||
}; | ||
zaq.during = function (obj) { | ||
zaq.log('\t. . .', obj, '\t. . .'); | ||
}; | ||
zaq.after = function (obj) { | ||
zaq.log(chalk.grey('\n- - - - - ->\n')); | ||
zaq.json(obj); | ||
}; | ||
zaq.mini = function (str) { | ||
return (_.isString(str) ? str : str.toString()).trim().substr(0, 100); | ||
}; | ||
// Timing -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ | ||
zaq.cloq = function (name) { | ||
var start = _.now(); | ||
zaq.time(chalk.cyan(name) + ' cloq ticking.'); | ||
return { | ||
start: start, | ||
lastLap: start, | ||
lap: function (evt) { | ||
var thisLap = _.now(); | ||
var lapTime = (thisLap - this.lastLap); | ||
this.lastLap = thisLap; | ||
zaq.time(chalk.bold(evt) + ' took ' + chalk.bold(lapTime / 1000) + ' seconds.'); | ||
}, | ||
done: function (evt) { | ||
if (evt) this.lap(evt); | ||
var total = (_.now() - this.start); | ||
zaq.time(chalk.cyan(name) + ' total time: ' + chalk.bold(total / 1000) + ' seconds.') | ||
} | ||
} | ||
} | ||
module.exports = zaq; |
@@ -1,1 +0,1 @@ | ||
var jawn=require("node-jawn");var _=require("underscore");var chalk=require("chalk");var zaq={log:console.log,err:function(x){return this.log(chalk.bold.red(" x ERROR: "),x)},warn:function(x){return this.log(chalk.bold.yellow(" ! WARNING: "),x)},info:function(x){return this.log(chalk.bold.blue(" → INFO: "),x)},win:function(x){return this.log(chalk.bold.green(" ✓ SUCCESS: "),x)},json:function(x){this.log(jawn.wrapDoubleBreaks(JSON.stringify(x,null," ")))},lines:Array(70).join("="),before:function(obj,funcName){this.log(this.lines+"\n"+this.lines+"\n");if(funcName)this.log(" RUNNING",funcName);this.json(obj)},during:function(obj){this.log(" . . .",obj," . . .")},after:function(obj){this.log(chalk.grey("\n- - - - - ->\n"));this.json(obj)},mini:function(str){return(_.isString(str)?str:str.toString()).trim().substr(0,100)}};module.exports=zaq; | ||
var jawn=require("node-jawn");var _=require("underscore");var chalk=require("chalk");var zaq={};zaq.log=console.log;zaq.err=function(x){return zaq.log(chalk.bold.red(" x ERROR: "),x)};zaq.warn=function(x){return zaq.log(chalk.bold.yellow(" ! WARNING: "),x)};zaq.info=function(x){return zaq.log(chalk.bold.blue(" → INFO: "),x)};zaq.win=function(x){return zaq.log(chalk.bold.green(" ✓ SUCCESS: "),x)};zaq.time=function(x){return zaq.log(chalk.bold.cyan(" ⏳ TIME: "),x)};zaq.pretty=function(content){return JSON.stringify(content,null," ")};zaq.space=function(content){return zaq.log(jawn.wrapDoubleBreaks(content))};zaq.json=function(x,y){var label,content;if(y){label=x;content=zaq.pretty(y)}else{content=zaq.pretty(x)}zaq.log((label?label+": \n":"")+jawn.wrapDoubleBreaks(content))};zaq.divider=function(text,lines){zaq.log(text+" "+zaq.nLines(process.stdout.columns-(text.length+1),lines))};zaq.nLines=function(n,lines){if(!lines)lines="=";return Array(n).join(lines)};zaq.lines=zaq.nLines(process.stdout.columns);zaq.before=function(obj,funcName){zaq.log(zaq.lines+"\n"+zaq.lines+"\n");if(funcName)zaq.log(" RUNNING",funcName);zaq.json(obj)};zaq.during=function(obj){zaq.log("\t. . .",obj,"\t. . .")};zaq.after=function(obj){zaq.log(chalk.grey("\n- - - - - ->\n"));zaq.json(obj)};zaq.mini=function(str){return(_.isString(str)?str:str.toString()).trim().substr(0,100)};zaq.cloq=function(name){var start=_.now();zaq.time(chalk.cyan(name)+" cloq ticking.");return{start:start,lastLap:start,lap:function(evt){var thisLap=_.now();var lapTime=thisLap-this.lastLap;this.lastLap=thisLap;zaq.time(chalk.bold(evt)+" took "+chalk.bold(lapTime/1e3)+" seconds.")},done:function(evt){if(evt)this.lap(evt);var total=_.now()-this.start;zaq.time(chalk.cyan(name)+" total time: "+chalk.bold(total/1e3)+" seconds.")}}};module.exports=zaq; |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
5980
6
113
2
Updatednode-jawn@^1.1.13