Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kitql/helper

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kitql/helper - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

cjs/colors/index.js

57

cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stry0 = exports.stry = exports.sleep = exports.yellow = exports.white = exports.strikethrough = exports.red = exports.magneta = exports.italic = exports.green = exports.gray = exports.cyan = exports.bold = exports.blue = exports.black = exports.Log = void 0;
exports.yellowBright = exports.yellow = exports.whiteBright = exports.white = exports.underline = exports.strikethrough = exports.reset = exports.redBright = exports.red = exports.magentaBright = exports.magenta = exports.italic = exports.inverse = exports.hidden = exports.greenBright = exports.green = exports.gray = exports.dim = exports.cyanBright = exports.cyan = exports.bold = exports.blueBright = exports.blue = exports.blackBright = exports.black = exports.bgYellowBright = exports.bgYellow = exports.bgWhiteBright = exports.bgWhite = exports.bgRedBright = exports.bgRed = exports.bgMagentaBright = exports.bgMagenta = exports.bgGreenBright = exports.bgGreen = exports.bgCyanBright = exports.bgCyan = exports.bgBlueBright = exports.bgBlue = exports.bgBlackBright = exports.bgBlack = exports.stryEq = exports.stry0 = exports.stry = exports.sleep = exports.Log = void 0;
var Log_js_1 = require("./Log.js");
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return Log_js_1.Log; } });
Object.defineProperty(exports, "black", { enumerable: true, get: function () { return Log_js_1.black; } });
Object.defineProperty(exports, "blue", { enumerable: true, get: function () { return Log_js_1.blue; } });
Object.defineProperty(exports, "bold", { enumerable: true, get: function () { return Log_js_1.bold; } });
Object.defineProperty(exports, "cyan", { enumerable: true, get: function () { return Log_js_1.cyan; } });
Object.defineProperty(exports, "gray", { enumerable: true, get: function () { return Log_js_1.gray; } });
Object.defineProperty(exports, "green", { enumerable: true, get: function () { return Log_js_1.green; } });
Object.defineProperty(exports, "italic", { enumerable: true, get: function () { return Log_js_1.italic; } });
Object.defineProperty(exports, "magneta", { enumerable: true, get: function () { return Log_js_1.magneta; } });
Object.defineProperty(exports, "red", { enumerable: true, get: function () { return Log_js_1.red; } });
Object.defineProperty(exports, "strikethrough", { enumerable: true, get: function () { return Log_js_1.strikethrough; } });
Object.defineProperty(exports, "white", { enumerable: true, get: function () { return Log_js_1.white; } });
Object.defineProperty(exports, "yellow", { enumerable: true, get: function () { return Log_js_1.yellow; } });
var sleep_js_1 = require("./sleep.js");

@@ -23,1 +11,44 @@ Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return sleep_js_1.sleep; } });

Object.defineProperty(exports, "stry0", { enumerable: true, get: function () { return stry_js_1.stry0; } });
Object.defineProperty(exports, "stryEq", { enumerable: true, get: function () { return stry_js_1.stryEq; } });
var index_js_1 = require("./colors/index.js");
Object.defineProperty(exports, "bgBlack", { enumerable: true, get: function () { return index_js_1.bgBlack; } });
Object.defineProperty(exports, "bgBlackBright", { enumerable: true, get: function () { return index_js_1.bgBlackBright; } });
Object.defineProperty(exports, "bgBlue", { enumerable: true, get: function () { return index_js_1.bgBlue; } });
Object.defineProperty(exports, "bgBlueBright", { enumerable: true, get: function () { return index_js_1.bgBlueBright; } });
Object.defineProperty(exports, "bgCyan", { enumerable: true, get: function () { return index_js_1.bgCyan; } });
Object.defineProperty(exports, "bgCyanBright", { enumerable: true, get: function () { return index_js_1.bgCyanBright; } });
Object.defineProperty(exports, "bgGreen", { enumerable: true, get: function () { return index_js_1.bgGreen; } });
Object.defineProperty(exports, "bgGreenBright", { enumerable: true, get: function () { return index_js_1.bgGreenBright; } });
Object.defineProperty(exports, "bgMagenta", { enumerable: true, get: function () { return index_js_1.bgMagenta; } });
Object.defineProperty(exports, "bgMagentaBright", { enumerable: true, get: function () { return index_js_1.bgMagentaBright; } });
Object.defineProperty(exports, "bgRed", { enumerable: true, get: function () { return index_js_1.bgRed; } });
Object.defineProperty(exports, "bgRedBright", { enumerable: true, get: function () { return index_js_1.bgRedBright; } });
Object.defineProperty(exports, "bgWhite", { enumerable: true, get: function () { return index_js_1.bgWhite; } });
Object.defineProperty(exports, "bgWhiteBright", { enumerable: true, get: function () { return index_js_1.bgWhiteBright; } });
Object.defineProperty(exports, "bgYellow", { enumerable: true, get: function () { return index_js_1.bgYellow; } });
Object.defineProperty(exports, "bgYellowBright", { enumerable: true, get: function () { return index_js_1.bgYellowBright; } });
Object.defineProperty(exports, "black", { enumerable: true, get: function () { return index_js_1.black; } });
Object.defineProperty(exports, "blackBright", { enumerable: true, get: function () { return index_js_1.blackBright; } });
Object.defineProperty(exports, "blue", { enumerable: true, get: function () { return index_js_1.blue; } });
Object.defineProperty(exports, "blueBright", { enumerable: true, get: function () { return index_js_1.blueBright; } });
Object.defineProperty(exports, "bold", { enumerable: true, get: function () { return index_js_1.bold; } });
Object.defineProperty(exports, "cyan", { enumerable: true, get: function () { return index_js_1.cyan; } });
Object.defineProperty(exports, "cyanBright", { enumerable: true, get: function () { return index_js_1.cyanBright; } });
Object.defineProperty(exports, "dim", { enumerable: true, get: function () { return index_js_1.dim; } });
Object.defineProperty(exports, "gray", { enumerable: true, get: function () { return index_js_1.gray; } });
Object.defineProperty(exports, "green", { enumerable: true, get: function () { return index_js_1.green; } });
Object.defineProperty(exports, "greenBright", { enumerable: true, get: function () { return index_js_1.greenBright; } });
Object.defineProperty(exports, "hidden", { enumerable: true, get: function () { return index_js_1.hidden; } });
Object.defineProperty(exports, "inverse", { enumerable: true, get: function () { return index_js_1.inverse; } });
Object.defineProperty(exports, "italic", { enumerable: true, get: function () { return index_js_1.italic; } });
Object.defineProperty(exports, "magenta", { enumerable: true, get: function () { return index_js_1.magenta; } });
Object.defineProperty(exports, "magentaBright", { enumerable: true, get: function () { return index_js_1.magentaBright; } });
Object.defineProperty(exports, "red", { enumerable: true, get: function () { return index_js_1.red; } });
Object.defineProperty(exports, "redBright", { enumerable: true, get: function () { return index_js_1.redBright; } });
Object.defineProperty(exports, "reset", { enumerable: true, get: function () { return index_js_1.reset; } });
Object.defineProperty(exports, "strikethrough", { enumerable: true, get: function () { return index_js_1.strikethrough; } });
Object.defineProperty(exports, "underline", { enumerable: true, get: function () { return index_js_1.underline; } });
Object.defineProperty(exports, "white", { enumerable: true, get: function () { return index_js_1.white; } });
Object.defineProperty(exports, "whiteBright", { enumerable: true, get: function () { return index_js_1.whiteBright; } });
Object.defineProperty(exports, "yellow", { enumerable: true, get: function () { return index_js_1.yellow; } });
Object.defineProperty(exports, "yellowBright", { enumerable: true, get: function () { return index_js_1.yellowBright; } });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Log = exports.strikethrough = exports.italic = exports.bold = exports.gray = exports.white = exports.cyan = exports.magneta = exports.blue = exports.yellow = exports.green = exports.red = exports.black = void 0;
const config = {
reset: {
node: `\x1b[0m`,
browser: '',
},
// Base
black: {
node: `\x1b[30m`,
browser: 'color: black',
},
red: {
node: `\x1b[31m`,
browser: 'color: red',
},
green: {
node: `\x1b[32m`,
browser: 'color: green',
},
yellow: {
node: `\x1b[33m`,
browser: 'color: yellow',
},
blue: {
node: `\x1b[34m`,
browser: 'color: blue',
},
magneta: {
node: `\x1b[35m`,
browser: 'color: #ff00ff',
},
cyan: {
node: `\x1b[36m`,
browser: 'color: cyan',
},
white: {
node: `\x1b[37m`,
browser: 'color: white',
},
gray: {
node: `\x1b[90m`,
browser: 'color: gray',
},
// Modif
bold: {
node: `\x1b[1m`,
browser: 'font-weight: bold',
},
italic: {
node: `\x1b[3m`,
browser: 'font-style: italic',
},
strikethrough: {
node: `\x1b[9m`,
browser: 'text-decoration: line-through',
},
};
function black(str) {
return `${config.black.node}${str}${config.reset.node}`;
}
exports.black = black;
function red(str) {
return `${config.red.node}${str}${config.reset.node}`;
}
exports.red = red;
function green(str) {
return `${config.green.node}${str}${config.reset.node}`;
}
exports.green = green;
function yellow(str) {
return `${config.yellow.node}${str}${config.reset.node}`;
}
exports.yellow = yellow;
function blue(str) {
return `${config.blue.node}${str}${config.reset.node}`;
}
exports.blue = blue;
function magneta(str) {
return `${config.magneta.node}${str}${config.reset.node}`;
}
exports.magneta = magneta;
function cyan(str) {
return `${config.cyan.node}${str}${config.reset.node}`;
}
exports.cyan = cyan;
function white(str) {
return `${config.white.node}${str}${config.reset.node}`;
}
exports.white = white;
function gray(str) {
return `${config.gray.node}${str}${config.reset.node}`;
}
exports.gray = gray;
function bold(str) {
return `${config.bold.node}${str}${config.reset.node}`;
}
exports.bold = bold;
function italic(str) {
return `${config.italic.node}${str}${config.reset.node}`;
}
exports.italic = italic;
function strikethrough(str) {
return `${config.strikethrough.node}${str}${config.reset.node}`;
}
exports.strikethrough = strikethrough;
exports.Log = void 0;
const index_js_1 = require("./colors/index.js");
class Log {

@@ -115,27 +12,24 @@ get isBrowser() {

this.toolName = toolName;
this.levelsToShow = (_a = options === null || options === void 0 ? void 0 : options.levelsToShow) !== null && _a !== void 0 ? _a : 2;
this.levelsToShow = (_a = options === null || options === void 0 ? void 0 : options.levelsToShow) !== null && _a !== void 0 ? _a : 3;
this.withDate = (_b = options === null || options === void 0 ? void 0 : options.withDate) !== null && _b !== void 0 ? _b : null;
this.prefixEmoji = (_c = options === null || options === void 0 ? void 0 : options.prefixEmoji) !== null && _c !== void 0 ? _c : '';
}
setLevel(logLevel) {
this.levelsToShow = logLevel;
}
buildStr(msg, withError, withSuccess, indent, browser) {
const table = [];
if (this.toolName) {
table.push(String(magneta(`[${this.toolName}]`)));
table.push(String((0, index_js_1.magenta)(`[${this.toolName}]`)));
}
// DateTime or Time or nothing
if (this.withDate === 'dateTime') {
table.push(String(magneta(`[${new Date().toISOString()}]`)));
table.push(String((0, index_js_1.magenta)(`[${new Date().toISOString()}]`)));
}
else if (this.withDate === 'time') {
table.push(String(magneta(`[${new Date().toISOString().split('T')[1]}]`)));
table.push(String((0, index_js_1.magenta)(`[${new Date().toISOString().split('T')[1]}]`)));
}
// Status icon or prefixEmoji
if (withError) {
table.push(`❌`);
table.push((0, index_js_1.bold)((0, index_js_1.redBright)('✘')));
}
else if (withSuccess) {
table.push(`✅`);
table.push((0, index_js_1.bold)((0, index_js_1.greenBright)('✔')));
}

@@ -153,19 +47,3 @@ else {

if (browser) {
let replacedStr = str;
// switch to browser console
const posToReplace = [];
for (const key in config) {
// check indexes
const indexes = this.getAllIndexOf(str, config[key].node);
for (const index of indexes) {
posToReplace.push({ index, key });
}
// replace with %c in another str to make sure we don't change the order of indexes
replacedStr = replacedStr.replaceAll(config[key].node, '%c');
}
const colors = [];
for (const c of posToReplace.sort((a, b) => a.index - b.index)) {
colors.push(config[c.key].browser);
}
return [replacedStr, ...colors];
return (0, index_js_1.colorBrowserProcess)(str);
}

@@ -175,14 +53,2 @@ // wrap it because we always unwrap after ;)

}
getAllIndexOf(str, subStr) {
let lastIndex = 0;
const indexes = [];
while (lastIndex !== -1) {
lastIndex = str.indexOf(subStr, lastIndex);
if (lastIndex !== -1) {
indexes.push(lastIndex);
lastIndex += subStr.length;
}
}
return indexes;
}
info(msg, conf) {

@@ -211,2 +77,3 @@ var _a, _b, _c;

const built = this.buildStr(msg, true, false, '', browser);
// Keep error to have the stacktrace in the browser
console.error(...built);

@@ -213,0 +80,0 @@ return built;

@@ -7,3 +7,3 @@ "use strict";

*/
const safe_stable_stringify_1 = require("safe-stable-stringify");
const tmp_js_1 = require("./safe-stable-stringify/tmp.js");
/**

@@ -24,3 +24,3 @@ * nice utility to stringify objects without spaces

}
return (0, safe_stable_stringify_1.stringify)(obj, replacer, space);
return (0, tmp_js_1.stringify)(obj, replacer, space);
}

@@ -27,0 +27,0 @@ exports.stry = stry;

@@ -1,3 +0,4 @@

export { Log, black, blue, bold, cyan, gray, green, italic, magneta, red, strikethrough, white, yellow, } from './Log.js';
export { Log } from './Log.js';
export { sleep } from './sleep.js';
export { stry, stry0 } from './stry.js';
export { stry, stry0, stryEq } from './stry.js';
export { bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, red, redBright, reset, strikethrough, underline, white, whiteBright, yellow, yellowBright, } from './colors/index.js';

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

const config = {
reset: {
node: `\x1b[0m`,
browser: '',
},
// Base
black: {
node: `\x1b[30m`,
browser: 'color: black',
},
red: {
node: `\x1b[31m`,
browser: 'color: red',
},
green: {
node: `\x1b[32m`,
browser: 'color: green',
},
yellow: {
node: `\x1b[33m`,
browser: 'color: yellow',
},
blue: {
node: `\x1b[34m`,
browser: 'color: blue',
},
magneta: {
node: `\x1b[35m`,
browser: 'color: #ff00ff',
},
cyan: {
node: `\x1b[36m`,
browser: 'color: cyan',
},
white: {
node: `\x1b[37m`,
browser: 'color: white',
},
gray: {
node: `\x1b[90m`,
browser: 'color: gray',
},
// Modif
bold: {
node: `\x1b[1m`,
browser: 'font-weight: bold',
},
italic: {
node: `\x1b[3m`,
browser: 'font-style: italic',
},
strikethrough: {
node: `\x1b[9m`,
browser: 'text-decoration: line-through',
},
};
export function black(str) {
return `${config.black.node}${str}${config.reset.node}`;
}
export function red(str) {
return `${config.red.node}${str}${config.reset.node}`;
}
export function green(str) {
return `${config.green.node}${str}${config.reset.node}`;
}
export function yellow(str) {
return `${config.yellow.node}${str}${config.reset.node}`;
}
export function blue(str) {
return `${config.blue.node}${str}${config.reset.node}`;
}
export function magneta(str) {
return `${config.magneta.node}${str}${config.reset.node}`;
}
export function cyan(str) {
return `${config.cyan.node}${str}${config.reset.node}`;
}
export function white(str) {
return `${config.white.node}${str}${config.reset.node}`;
}
export function gray(str) {
return `${config.gray.node}${str}${config.reset.node}`;
}
export function bold(str) {
return `${config.bold.node}${str}${config.reset.node}`;
}
export function italic(str) {
return `${config.italic.node}${str}${config.reset.node}`;
}
export function strikethrough(str) {
return `${config.strikethrough.node}${str}${config.reset.node}`;
}
import { bold, colorBrowserProcess, greenBright, magenta, redBright } from './colors/index.js';
export class Log {

@@ -100,27 +9,24 @@ get isBrowser() {

this.toolName = toolName;
this.levelsToShow = (_a = options === null || options === void 0 ? void 0 : options.levelsToShow) !== null && _a !== void 0 ? _a : 2;
this.levelsToShow = (_a = options === null || options === void 0 ? void 0 : options.levelsToShow) !== null && _a !== void 0 ? _a : 3;
this.withDate = (_b = options === null || options === void 0 ? void 0 : options.withDate) !== null && _b !== void 0 ? _b : null;
this.prefixEmoji = (_c = options === null || options === void 0 ? void 0 : options.prefixEmoji) !== null && _c !== void 0 ? _c : '';
}
setLevel(logLevel) {
this.levelsToShow = logLevel;
}
buildStr(msg, withError, withSuccess, indent, browser) {
const table = [];
if (this.toolName) {
table.push(String(magneta(`[${this.toolName}]`)));
table.push(String(magenta(`[${this.toolName}]`)));
}
// DateTime or Time or nothing
if (this.withDate === 'dateTime') {
table.push(String(magneta(`[${new Date().toISOString()}]`)));
table.push(String(magenta(`[${new Date().toISOString()}]`)));
}
else if (this.withDate === 'time') {
table.push(String(magneta(`[${new Date().toISOString().split('T')[1]}]`)));
table.push(String(magenta(`[${new Date().toISOString().split('T')[1]}]`)));
}
// Status icon or prefixEmoji
if (withError) {
table.push(`❌`);
table.push(bold(redBright('✘')));
}
else if (withSuccess) {
table.push(`✅`);
table.push(bold(greenBright('✔')));
}

@@ -138,19 +44,3 @@ else {

if (browser) {
let replacedStr = str;
// switch to browser console
const posToReplace = [];
for (const key in config) {
// check indexes
const indexes = this.getAllIndexOf(str, config[key].node);
for (const index of indexes) {
posToReplace.push({ index, key });
}
// replace with %c in another str to make sure we don't change the order of indexes
replacedStr = replacedStr.replaceAll(config[key].node, '%c');
}
const colors = [];
for (const c of posToReplace.sort((a, b) => a.index - b.index)) {
colors.push(config[c.key].browser);
}
return [replacedStr, ...colors];
return colorBrowserProcess(str);
}

@@ -160,14 +50,2 @@ // wrap it because we always unwrap after ;)

}
getAllIndexOf(str, subStr) {
let lastIndex = 0;
const indexes = [];
while (lastIndex !== -1) {
lastIndex = str.indexOf(subStr, lastIndex);
if (lastIndex !== -1) {
indexes.push(lastIndex);
lastIndex += subStr.length;
}
}
return indexes;
}
info(msg, conf) {

@@ -196,2 +74,3 @@ var _a, _b, _c;

const built = this.buildStr(msg, true, false, '', browser);
// Keep error to have the stacktrace in the browser
console.error(...built);

@@ -198,0 +77,0 @@ return built;

/**
* Using https://github.com/BridgeAR/safe-stable-stringify because it's simply more robust and more performant!
*/
import { stringify } from 'safe-stable-stringify';
import { stringify } from './safe-stable-stringify/tmp.js';
/**

@@ -6,0 +6,0 @@ * nice utility to stringify objects without spaces

{
"name": "@kitql/helper",
"version": "0.7.0",
"version": "0.7.1",
"dependencies": {

@@ -5,0 +5,0 @@ "safe-stable-stringify": "^2.4.3"

@@ -1,4 +0,5 @@

export { Log, black, blue, bold, cyan, gray, green, italic, magneta, red, strikethrough, white, yellow, } from './Log.js';
export { Log } from './Log.js';
export { sleep } from './sleep.js';
export { stry, stry0 } from './stry.js';
export type { Prettify } from './Prettify.d.ts';
export { stry, stry0, stryEq } from './stry.js';
export { bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, red, redBright, reset, strikethrough, underline, white, whiteBright, yellow, yellowBright, } from './colors/index.js';
export type { Prettify } from './Prettify.js';

@@ -1,13 +0,1 @@

export declare function black(str: string): string;
export declare function red(str: string): string;
export declare function green(str: string): string;
export declare function yellow(str: string): string;
export declare function blue(str: string): string;
export declare function magneta(str: string): string;
export declare function cyan(str: string): string;
export declare function white(str: string): string;
export declare function gray(str: string): string;
export declare function bold(str: string): string;
export declare function italic(str: string): string;
export declare function strikethrough(str: string): string;
export declare class Log {

@@ -24,5 +12,3 @@ private toolName;

});
setLevel(logLevel: number): void;
private buildStr;
private getAllIndexOf;
info(msg: string, conf?: {

@@ -29,0 +15,0 @@ level?: number;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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