New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zaq

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zaq - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

package.json
{
"name": "zaq",
"version": "1.3.0",
"version": "1.4.0",
"description": "Yet another fun little logging utility.",

@@ -5,0 +5,0 @@ "main": "zaq.js",

@@ -1,2 +0,2 @@

var zaq = require('./zaq.js')();
var zaq = require('./zaq.js');

@@ -40,1 +40,7 @@ var sampleJSON = {

zaq.weight(__dirname, 'madeup.js');
const alt = zaq.as('Alternate Namespace!');
alt.win('Fetching resources was successful.');
alt.time('50ms elapsed.');
alt.debug('Some debug info...');
alt.flag('lol test');

@@ -7,10 +7,10 @@ const fs = require('fs');

const zaq = function (namespace = '') {
this.version = '1.2.8';
this.loggers = [
{ handler: console.log }
];
const faqtory = (namespace = '') => {
const zaq = {
version: '1.4.0',
loggers: [ { handler: console.log } ]
};
this.log = (input, level = 'misc') => {
this.loggers.forEach(({ handler, options = {} }) => {
zaq.log = (input, level = 'misc') => {
zaq.loggers.forEach(({ handler, options = {} }) => {
let { timestamps, levels, stripColors } = options;

@@ -24,13 +24,13 @@ if (timestamps) input = (chalk.dim(moment().format('l LTS '))) + input;

this.use = (handler, options = {}) => {
return this.loggers.push({ handler, options });
zaq.use = (handler, options = {}) => {
return zaq.loggers.push({ handler, options });
}
this.unuse = (index) => {
return this.loggers.splice(index, 1);
zaq.unuse = (index) => {
return zaq.loggers.splice(index, 1);
}
this.obj = (obj = null, color = 'cyan') => {
zaq.obj = (obj = null, color = 'cyan') => {
let msg = chalk[color]('\n >>>> ');
obj = (typeof obj === 'string' ? obj : this.pretty(obj))+'';
obj = (typeof obj === 'string' ? obj : zaq.pretty(obj))+'';
msg += obj.split('\n').join('\n' + chalk[color].dim(' :::: '));

@@ -40,36 +40,71 @@ return msg;

this.message = ({ style, prefix }, { text, obj }) => {
const space = (namespace && namespace.length ? chalk.dim(namespace) + ' ' : '');
prefix = ' ' + space + prefix + (Array(10 - prefix.length).join(' '));
text = chalk.bold[style](prefix) + chalk.bold(text);
text += obj ? this.obj(obj, style) : '';
return space + text;
zaq.message = ({ style, prefix }, { text, obj }) => {
const space = namespace && namespace.length ? `[${namespace}] ` : ' ';
prefix = prefix + (Array(10 - prefix.length).join(' '));
text = chalk.bold[style].dim(space) + chalk.bold[style](prefix) + chalk.bold(text);
text += obj ? zaq.obj(obj, style) : '';
return text;
}
this.logMessage = ({ style, prefix, level }, { text, obj }) => {
let message = this.message({ style, prefix }, { text, obj });
return this.log(message, level);
zaq.logMessage = ({ style, prefix, level }, { text, obj }) => {
let message = zaq.message({ style, prefix }, { text, obj });
return zaq.log(message, level);
}
const logType = (spec = {}) => (text, obj) => this.logMessage(spec, { text, obj });
const logType = (spec = {}) => (text, obj) => zaq.logMessage(spec, { text, obj });
this.win = logType({ style: 'green', prefix: '✓ WIN:', level: 'info' });
this.err = logType({ style: 'red', prefix: '✘ ERR:', level: 'error' });
this.flag = logType({ style: 'cyan', prefix: '⌘ FLAG:', level: 'info' });
this.warn = logType({ style: 'yellow', prefix: '⌗ WARN:', level: 'warn' });
this.info = logType({ style: 'blue', prefix: '→ INFO:', level: 'info' });
this.time = logType({ style: 'grey', prefix: '◔ TIME:', level: 'info' });
this.debug = logType({ style: 'magenta', prefix: '◆ DEBUG:', level: 'debug' });
zaq.win = logType({
style: 'green',
prefix: '✓ WIN:',
level: 'info'
});
this.pretty = (content) => JSON.stringify(content, null,' ');
this.space = (content, amount = 1) => {
let pad = this.nLines(amount, '\n');
return this.log(pad + content + pad);
zaq.err = logType({
style: 'red',
prefix: '✘ ERR:',
level: 'error'
});
zaq.flag = logType({
style: 'cyan',
prefix: '⌘ FLAG:',
level: 'info'
});
zaq.warn = logType({
style: 'yellow',
prefix: '⌗ WARN:',
level: 'warn'
});
zaq.info = logType({
style: 'blue',
prefix: '→ INFO:',
level: 'info'
});
zaq.time = logType({
style: 'grey',
prefix: '◔ TIME:',
level: 'info'
});
zaq.debug = logType({
style: 'magenta',
prefix: '◆ DEBUG:',
level: 'debug'
});
zaq.pretty = (content) => JSON.stringify(content, null,' ');
zaq.space = (content, amount = 1) => {
let pad = zaq.nLines(amount, '\n');
return zaq.log(pad + content + pad);
}
this.nLines = (n, line = '-') => Array(n).join(chalk.dim(line));
zaq.nLines = (n, line = '-') => Array(n).join(chalk.dim(line));
this.mini = (str) => str.toString().trim().substr(0, 100);
zaq.mini = (str) => str.toString().trim().substr(0, 100);
this.divider = (text = '', options = {}) => {
zaq.divider = (text = '', options = {}) => {
let { lineSymbol, centered, space } = options;

@@ -80,8 +115,8 @@ let { columns } = process.stdout;

lineCount = centered ? Math.ceil(lineCount / 2) : lineCount;
let filler = this.nLines(lineCount, lineSymbol);
let filler = zaq.nLines(lineCount, lineSymbol);
let output = centered ? `${filler} ${text} ${filler}` : `${text} ${filler}`;
return this.space(output, space);
return zaq.space(output, space);
};
this.weight = (...pathParts) => {
zaq.weight = (...pathParts) => {
let file = path.join(...pathParts);

@@ -93,11 +128,14 @@ let basename = path.basename(file);

} catch (e) {
return this.warn(`File ${chalk.yellow.italic(basename)} not found, cannot be weighed.`);
return zaq.warn(`File ${chalk.yellow.italic(basename)} not found, cannot be weighed.`);
}
let filesize = (stats.size / 1024).toFixed(2);
this.info(`File ${chalk.blue.italic(basename)} is ${chalk.blue(filesize)} kb`);
zaq.info(`File ${chalk.blue.italic(basename)} is ${chalk.blue(filesize)} kb`);
};
return this;
};
return zaq;
}
module.exports = zaq;
const defaultInstance = faqtory();
defaultInstance.as = faqtory;
module.exports = defaultInstance;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc