Comparing version 1.1.5 to 1.2.0
{ | ||
"name": "zaq", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "Yet another fun little logging utility.", | ||
@@ -36,4 +36,6 @@ "main": "zaq.js", | ||
"devDependencies": { | ||
"babel-cli": "^6.18.0" | ||
"babel-cli": "^6.18.0", | ||
"uglify-js": "^3.0.24", | ||
"uglify-js-es6": "^2.8.9" | ||
} | ||
} |
@@ -35,4 +35,5 @@ var zaq = require('./zaq.js'); | ||
zaq.time('50ms elapsed.'); | ||
zaq.divider("Check sizes..."); | ||
zaq.flag('lol test'); | ||
zaq.divider("Check sizes...", { space: 2, lineSymbol: ':', centered: true }); | ||
zaq.weight(__dirname, 'yarn.lock'); | ||
zaq.weight(__dirname, 'madeup.js'); | ||
zaq.weight(__dirname, 'madeup.js'); |
76
zaq.js
@@ -8,51 +8,59 @@ const jawn = require('node-jawn'); | ||
const zaq = { | ||
version: '1.1.5', | ||
version: '1.2.0', | ||
verbose: true, | ||
log: console.log | ||
loggers: [ console.log ] | ||
}; | ||
zaq.log = (...input) => { | ||
zaq.loggers.forEach(logger => logger(...input)); | ||
} | ||
zaq.use = (logger) => { | ||
if (zaq.loggers.indexOf(logger) === -1) zaq.loggers.push(logger); | ||
} | ||
zaq.obj = (obj = null, color = 'cyan') => { | ||
let msg = chalk[color]('\n >> '); | ||
let msg = chalk[color]('\n >>>> '); | ||
obj = (_.isString(obj) ? obj : zaq.pretty(obj))+''; | ||
msg += obj.split('\n').join('\n' + chalk[color].dim(' :: ')); | ||
//msg += chalk[color].dim('\n ' + zaq.nLines(40, '\'')); | ||
msg += obj.split('\n').join('\n' + chalk[color].dim(' :::: ')); | ||
return msg; | ||
}; | ||
zaq.win = (text, obj) => { | ||
text = chalk.bold.green(' ✓ WIN: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'green') : '')); | ||
}; | ||
zaq.message = (style, prefix, text, obj) => { | ||
prefix = ' ' + prefix + (Array(10 - prefix.length).join(' ')); | ||
text = chalk.bold[style](prefix) + chalk.bold(text); | ||
text += obj ? zaq.obj(obj, style) : ''; | ||
return text; | ||
} | ||
zaq.err = (text, obj) => { | ||
text = chalk.bold.red(' x ERR: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'red') : '')); | ||
}; | ||
zaq.logMessage = (style, prefix, text, obj) => { | ||
let message = zaq.message(style, prefix, text, obj); | ||
return zaq.log(message); | ||
} | ||
zaq.warn = (text, obj) => { | ||
text = chalk.bold.yellow(' # WARN: ') + text; | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'yellow') : '')); | ||
}; | ||
zaq.info = (text, obj) => { | ||
text = chalk.bold.blue(' → INFO: ') + text; | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'blue') : '')); | ||
}; | ||
zaq.time = (text, obj) => { | ||
text = chalk.bold.grey(' ♦ TIME: ') + text; | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'grey') : '')); | ||
}; | ||
zaq.win = (text, obj) => zaq.logMessage('green', '✓ WIN:', text, obj); | ||
zaq.err = (text, obj) => zaq.logMessage('red', '✘ ERR:', text, obj); | ||
zaq.flag = (text, obj) => zaq.logMessage('cyan', '⌘ FLAG:', text, obj); | ||
zaq.warn = (text, obj) => zaq.logMessage('yellow', '⌗ WARN:', text, obj); | ||
zaq.info = (text, obj) => zaq.logMessage('blue', '→ INFO:', text, obj); | ||
zaq.time = (text, obj) => zaq.logMessage('grey', '◔ TIME:', text, obj); | ||
zaq.pretty = (content) => JSON.stringify(content, null,' '); | ||
zaq.space = (content, amount = 1) => { | ||
let pad = zaq.nLines(amount, '\n'); | ||
return zaq.log(pad + content + pad); | ||
} | ||
zaq.space = (content) => zaq.log('\n' + content + '\n'); | ||
zaq.nLines = (n, line = '-') => Array(n).join(chalk.dim(line)); | ||
zaq.nLines = (n, lines = '-') => Array(n).join(chalk.dim(lines)); | ||
zaq.mini = (str) => str.toString().trim().substr(0, 100); | ||
zaq.divider = (text, lines) => { | ||
let lineCount = Math.floor((process.stdout.columns - (text.length + 1)) * (1 / (lines ? lines.length : 1))); | ||
return zaq.space(`${text} ${zaq.nLines(lineCount, lines)}`); | ||
zaq.divider = (text = '', options = {}) => { | ||
let { lineSymbol, centered, space } = options; | ||
let { columns } = process.stdout; | ||
let textWidth = text.length + (centered ? 2 : 1); | ||
let lineCount = Math.floor((columns - textWidth) / (lineSymbol ? lineSymbol.length : 1)); | ||
lineCount = centered ? Math.ceil(lineCount / 2) : lineCount; | ||
let filler = zaq.nLines(lineCount, lineSymbol); | ||
let output = centered ? `${filler} ${text} ${filler}` : `${text} ${filler}`; | ||
return zaq.space(output, space); | ||
}; | ||
@@ -59,0 +67,0 @@ |
@@ -1,1 +0,1 @@ | ||
const jawn=require("node-jawn");const _=require("underscore");const path=require("path");const fs=require("fs");const chalk=require("chalk");const zaq={version:"1.1.5",verbose:true,log:console.log};zaq.obj=((obj=null,color="cyan")=>{let msg=chalk[color]("\n >> ");obj=(_.isString(obj)?obj:zaq.pretty(obj))+"";msg+=obj.split("\n").join("\n"+chalk[color].dim(" :: "));return msg});zaq.win=((text,obj)=>{text=chalk.bold.green(" ✓ WIN: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"green"):""))});zaq.err=((text,obj)=>{text=chalk.bold.red(" x ERR: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"red"):""))});zaq.warn=((text,obj)=>{text=chalk.bold.yellow(" # WARN: ")+text;return zaq.log(text+(obj?zaq.obj(obj,"yellow"):""))});zaq.info=((text,obj)=>{text=chalk.bold.blue(" → INFO: ")+text;return zaq.log(text+(obj?zaq.obj(obj,"blue"):""))});zaq.time=((text,obj)=>{text=chalk.bold.grey(" ♦ TIME: ")+text;return zaq.log(text+(obj?zaq.obj(obj,"grey"):""))});zaq.pretty=(content=>JSON.stringify(content,null," "));zaq.space=(content=>zaq.log("\n"+content+"\n"));zaq.nLines=((n,lines="-")=>Array(n).join(chalk.dim(lines)));zaq.mini=(str=>str.toString().trim().substr(0,100));zaq.divider=((text,lines)=>{let lineCount=Math.floor((process.stdout.columns-(text.length+1))*(1/(lines?lines.length:1)));return zaq.space(`${text} ${zaq.nLines(lineCount,lines)}`)});zaq.weight=((...pathParts)=>{let file=path.join(...pathParts);let basename=path.basename(file);let stats;try{stats=fs.statSync(file)}catch(e){return zaq.warn(`File ${chalk.yellow.italic(basename)} not found, cannot be weighed.`)}let filesize=(stats.size/1024).toFixed(2);zaq.info(`File ${chalk.blue.italic(basename)} is ${chalk.blue(filesize)} kb`)});module.exports=zaq; | ||
const jawn=require("node-jawn");const _=require("underscore");const path=require("path");const fs=require("fs");const chalk=require("chalk");const zaq={version:"1.2.0",verbose:true,loggers:[console.log]};zaq.log=((...input)=>{zaq.loggers.forEach(logger=>logger(...input))});zaq.use=(logger=>{if(zaq.loggers.indexOf(logger)===-1)zaq.loggers.push(logger)});zaq.obj=((obj=null,color="cyan")=>{let msg=chalk[color]("\n >>>> ");obj=(_.isString(obj)?obj:zaq.pretty(obj))+"";msg+=obj.split("\n").join("\n"+chalk[color].dim(" :::: "));return msg});zaq.message=((style,prefix,text,obj)=>{prefix=" "+prefix+Array(10-prefix.length).join(" ");text=chalk.bold[style](prefix)+chalk.bold(text);text+=obj?zaq.obj(obj,style):"";return text});zaq.logMessage=((style,prefix,text,obj)=>{let message=zaq.message(style,prefix,text,obj);return zaq.log(message)});zaq.win=((text,obj)=>zaq.logMessage("green","✓ WIN:",text,obj));zaq.err=((text,obj)=>zaq.logMessage("red","✘ ERR:",text,obj));zaq.flag=((text,obj)=>zaq.logMessage("cyan","⌘ FLAG:",text,obj));zaq.warn=((text,obj)=>zaq.logMessage("yellow","⌗ WARN:",text,obj));zaq.info=((text,obj)=>zaq.logMessage("blue","→ INFO:",text,obj));zaq.time=((text,obj)=>zaq.logMessage("grey","◔ TIME:",text,obj));zaq.pretty=(content=>JSON.stringify(content,null," "));zaq.space=((content,amount=1)=>{let pad=zaq.nLines(amount,"\n");return zaq.log(pad+content+pad)});zaq.nLines=((n,line="-")=>Array(n).join(chalk.dim(line)));zaq.mini=(str=>str.toString().trim().substr(0,100));zaq.divider=((text="",options={})=>{let{lineSymbol:lineSymbol,centered:centered,space:space}=options;let{columns:columns}=process.stdout;let textWidth=text.length+(centered?2:1);let lineCount=Math.floor((columns-textWidth)/(lineSymbol?lineSymbol.length:1));lineCount=centered?Math.ceil(lineCount/2):lineCount;let filler=zaq.nLines(lineCount,lineSymbol);let output=centered?`${filler} ${text} ${filler}`:`${text} ${filler}`;return zaq.space(output,space)});zaq.weight=((...pathParts)=>{let file=path.join(...pathParts);let basename=path.basename(file);let stats;try{stats=fs.statSync(file)}catch(e){return zaq.warn(`File ${chalk.yellow.italic(basename)} not found, cannot be weighed.`)}let filesize=(stats.size/1024).toFixed(2);zaq.info(`File ${chalk.blue.italic(basename)} is ${chalk.blue(filesize)} kb`)});module.exports=zaq; |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
915198
103
3