Comparing version 1.0.3 to 1.1.0
{ | ||
"name": "zaq", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Yet another fun little logging utility.", | ||
@@ -5,0 +5,0 @@ "main": "zaq.js", |
@@ -1,2 +0,2 @@ | ||
var zaq = require('./zaq.min.js'); | ||
var zaq = require('./zaq.js'); | ||
@@ -3,0 +3,0 @@ var sampleJSON = { |
117
zaq.js
const jawn = require('node-jawn'); | ||
const _ = require('underscore'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const chalk = require('chalk'); | ||
let deprecated = (x) => { | ||
zaq.warn('Function ' + chalk.bold.yellow('[zaq.' + x + '()]') + ' is deprecated. Please consult your doctor.'); | ||
} | ||
let zaq = { | ||
const zaq = { | ||
version: '1.1.0', | ||
verbose: true, | ||
log: console.log, | ||
obj (obj, color = 'cyan') { | ||
let msg = chalk[color]('\n >> '); | ||
msg += (_.isString(obj) ? obj : zaq.pretty(obj)).split('\n').join('\n' + chalk[color].dim(' :: ')); | ||
//msg += chalk[color].dim('\n ' + zaq.nLines(40, '\'')); | ||
return msg; | ||
}, | ||
win (text, obj) { | ||
text = chalk.bold.green(' ✓ WIN: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'green') : '')); | ||
}, | ||
err (text, obj) { | ||
text = chalk.bold.red(' x ERR: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'red') : '')); | ||
}, | ||
warn (text, obj) { | ||
text = chalk.bold.yellow(' # WARN: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'yellow') : '')); | ||
}, | ||
info (text, obj) { | ||
text = chalk.bold.blue(' → INFO: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'blue') : '')); | ||
}, | ||
time (text, obj) { | ||
text = chalk.bold.grey(' ♦ TIME: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'grey') : '')); | ||
}, | ||
pretty: (content) => JSON.stringify(content, null,' '), | ||
space: (content) => zaq.log('\n' + content + '\n'), | ||
nLines (n, lines) { | ||
return Array(n).join(lines || '=') | ||
}, | ||
mini (str) { | ||
return (_.isString(str) ? str : str.toString()).trim().substr(0, 100); | ||
}, | ||
divider (text, lines) { | ||
let lineCount = Math.floor((process.stdout.columns - (text.length + 1)) * (1 / (lines ? lines.length : 1))); | ||
return zaq.log(text + ' '+ zaq.nLines(lineCount, lines)); | ||
}, | ||
json (x, y) { | ||
zaq.log(zaq.obj(y ? y : x)); | ||
deprecated('json'); | ||
}, | ||
before (obj) { | ||
zaq.log(zaq.obj(obj)); | ||
deprecated('before'); | ||
}, | ||
during (obj) { | ||
zaq.log(zaq.obj(obj)); | ||
deprecated('during'); | ||
}, | ||
after (obj) { | ||
zaq.log(zaq.obj(obj)); | ||
deprecated('after'); | ||
} | ||
log: console.log | ||
}; | ||
zaq.obj = (obj, color = 'cyan') => { | ||
let msg = chalk[color]('\n >> '); | ||
msg += (_.isString(obj) ? obj : zaq.pretty(obj)).split('\n').join('\n' + chalk[color].dim(' :: ')); | ||
//msg += chalk[color].dim('\n ' + zaq.nLines(40, '\'')); | ||
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: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'yellow') : '')); | ||
}; | ||
zaq.info = (text, obj) => { | ||
text = chalk.bold.blue(' → INFO: ') + chalk.bold(text); | ||
return zaq.log(text + (obj ? zaq.obj(obj, 'blue') : '')); | ||
}; | ||
zaq.time = (text, obj) => { | ||
text = chalk.bold.grey(' ♦ TIME: ') + chalk.bold(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(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.log(text + ' '+ zaq.nLines(lineCount, lines)); | ||
}; | ||
zaq.weight = (...pathParts) => { | ||
let file = path.join(...pathParts); | ||
let basename = path.basename(file); | ||
let filesize = (fs.statSync(file).size / 1024).toFixed(2); | ||
zaq.info(`File '${basename}' is ${filesize} kb`); | ||
}; | ||
module.exports = zaq; |
@@ -1,1 +0,1 @@ | ||
const jawn=require("node-jawn");const _=require("underscore");const chalk=require("chalk");let deprecated=x=>{zaq.warn("Function "+chalk.bold.yellow("[zaq."+x+"()]")+" is deprecated. Please consult your doctor.")};let zaq={verbose:true,log:console.log,obj(obj,color="cyan"){let msg=chalk[color]("\n >> ");msg+=(_.isString(obj)?obj:zaq.pretty(obj)).split("\n").join("\n"+chalk[color].dim(" :: "));return msg},win(text,obj){text=chalk.bold.green(" ✓ WIN: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"green"):""))},err(text,obj){text=chalk.bold.red(" x ERR: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"red"):""))},warn(text,obj){text=chalk.bold.yellow(" # WARN: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"yellow"):""))},info(text,obj){text=chalk.bold.blue(" → INFO: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"blue"):""))},time(text,obj){text=chalk.bold.grey(" ♦ TIME: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"grey"):""))},pretty:content=>JSON.stringify(content,null," "),space:content=>zaq.log("\n"+content+"\n"),nLines(n,lines){return Array(n).join(lines||"=")},mini(str){return(_.isString(str)?str:str.toString()).trim().substr(0,100)},divider(text,lines){let lineCount=Math.floor((process.stdout.columns-(text.length+1))*(1/(lines?lines.length:1)));return zaq.log(text+" "+zaq.nLines(lineCount,lines))},json(x,y){zaq.log(zaq.obj(y?y:x));deprecated("json")},before(obj){zaq.log(zaq.obj(obj));deprecated("before")},during(obj){zaq.log(zaq.obj(obj));deprecated("during")},after(obj){zaq.log(zaq.obj(obj));deprecated("after")}};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.1.0",verbose:true,log:console.log};zaq.obj=((obj,color="cyan")=>{let msg=chalk[color]("\n >> ");msg+=(_.isString(obj)?obj:zaq.pretty(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: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"yellow"):""))});zaq.info=((text,obj)=>{text=chalk.bold.blue(" → INFO: ")+chalk.bold(text);return zaq.log(text+(obj?zaq.obj(obj,"blue"):""))});zaq.time=((text,obj)=>{text=chalk.bold.grey(" ♦ TIME: ")+chalk.bold(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(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.log(text+" "+zaq.nLines(lineCount,lines))});zaq.weight=((...pathParts)=>{let file=path.join(...pathParts);let basename=path.basename(file);let filesize=(fs.statSync(file).size/1024).toFixed(2);zaq.info(`File '${basename}' is ${filesize} kb`)});module.exports=zaq; |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
105973
79
2