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

exer

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exer - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

46

lib/debug.d.ts

@@ -19,2 +19,5 @@ /// <reference types="node" />

enabled: boolean;
useColors: boolean;
color: number;
diff: string | number;
log: (...args: any[]) => Debugger;

@@ -35,4 +38,15 @@ fatal: (...args: any[]) => Debugger;

hideDate: boolean;
useConsole: boolean;
alwaysDiff: boolean;
}
export { Debug as debug };
export declare enum DebugLevel {
ALL = 0,
TRACE = 0,
DEBUG = 1,
INFO = 2,
WARN = 3,
ERROR = 4,
FATAL = 5,
OFF = 6
}
/**

@@ -47,3 +61,3 @@ * Create a debugger with the given `namespace`.

export declare namespace Debug {
var formatArgs: (this: any, fun: any, timer: string, trace: string, args: any[]) => void;
var formatArgs: (this: Debugger, fun: any, timer: string, trace: string, args: any[]) => void;
var humanize: (ms: any) => string;

@@ -61,2 +75,4 @@ var times: Record<string, [number, number]>;

var useColors: () => boolean;
var useConsole: () => boolean;
var alwaysDiff: () => boolean;
var selectColor: (namespace: string) => any;

@@ -67,23 +83,29 @@ var enable: (namespaces?: string) => void;

var coerce: (val: any) => any;
var log: (...args: any[]) => boolean;
var fatal: (...args: any[]) => boolean;
var level: DebugLevel;
var isBellow: (ofLevel: DebugLevel) => boolean;
var setLevel: (toLevel: DebugLevel) => void;
var logIcon: string;
var fatalIcon: string;
var error: (...args: any[]) => boolean;
var errorIcon: string;
var info: (...args: any[]) => boolean;
var infoIcon: string;
var warn: (...args: any[]) => boolean;
var warnIcon: string;
var debug: (...args: any[]) => boolean;
var debugIcon: string;
var trace: (...args: any[]) => boolean;
var traceIcon: string;
var time: (...args: any[]) => boolean;
var timeIcon: string;
var end: (...args: any[]) => boolean;
var endIcon: string;
var timeEnd: (...args: any[]) => boolean;
var timeEndIcon: string;
var log: (...args: any[]) => void;
var fatal: (...args: any[]) => void;
var error: (...args: any[]) => void;
var info: (...args: any[]) => void;
var warn: (...args: any[]) => void;
var debug: (...args: any[]) => void;
var trace: (...args: any[]) => void;
var time: (...args: any[]) => void;
var end: (...args: any[]) => void;
var timeEnd: (...args: any[]) => void;
var now: () => [number, number];
var millis: (start: [number, number], offset?: number) => string;
}
export { Debug as debug };
export default Debug;

@@ -5,2 +5,13 @@ "use strict";

const util = require("util");
var DebugLevel;
(function (DebugLevel) {
DebugLevel[DebugLevel["ALL"] = 0] = "ALL";
DebugLevel[DebugLevel["TRACE"] = 0] = "TRACE";
DebugLevel[DebugLevel["DEBUG"] = 1] = "DEBUG";
DebugLevel[DebugLevel["INFO"] = 2] = "INFO";
DebugLevel[DebugLevel["WARN"] = 3] = "WARN";
DebugLevel[DebugLevel["ERROR"] = 4] = "ERROR";
DebugLevel[DebugLevel["FATAL"] = 5] = "FATAL";
DebugLevel[DebugLevel["OFF"] = 6] = "OFF";
})(DebugLevel = exports.DebugLevel || (exports.DebugLevel = {}));
/**

@@ -21,5 +32,3 @@ * Create a debugger with the given `namespace`.

return;
// const args: any[] = [...arguments];
const self = debug; // Set `diff` timestamp
// const curr = Number(new Date());
const self = debug;
const curr = Debug.now();

@@ -34,3 +43,3 @@ const ms = Debug.millis(debug.prev || curr);

if (this === Debug.trace) {
stack = new Error().stack.replace('Error', 'Trace');
stack = new Error().stack.replace('Error', 'Trace').split('\n').filter((t, i) => i !== 1).join('\n');
}

@@ -119,19 +128,17 @@ else if (this === Debug.time) {

const useColors = this.useColors;
let z = 'log';
if (fun && fun.name !== 'log') {
// TODO: Color code per level
// fun.color
z = (fun.label || fun.name);
if (z === 'timeEnd')
z = 'time';
if (z === 'detail')
z = 'debug';
}
let level = `${z} `;
// TODO: Color code per level (fun.color)
let z = fun && fun.name || '';
if (z === 'timeEnd')
z = 'time';
if (z === 'detail')
z = 'debug';
let level = z.toUpperCase();
if (this.useColors) {
z = Debug[`${z}Icon`];
level = z ? (z + ' ') : level;
level = z ? (z + ' ') : level;
}
if (level)
level += ' ';
const name = `[${this.namespace}]`;
const msg = trace ? trace.replace('Trace', args[0] !== '' ? 'Trace: ' + args[0] : 'Trace') : args[0];
const msg = trace ? trace.replace('Trace:', args[0] !== '' ? 'Trace: ' + args[0] : 'Trace:') : args[0];
if (useColors) {

@@ -145,4 +152,6 @@ const c = this.color;

else {
args[0] = getDate() + level + name + ' ' + timer + (args.length ? msg : '');
args[0] = getDate() + level + name + ' ' + timer + (args.length ? msg : '')
+ (Debug.alwaysDiff() ? ' +' + Debug.humanize(this.diff) : '');
}
// return util.format.call(util, ...args);
};

@@ -259,2 +268,15 @@ // Debug.debug = Debug;

/**
* Is console instead of stdout/err used as output.
*/
Debug.useConsole = function useConsole() {
return 'useConsole' in Debug.inspectOpts
? Boolean(Debug.inspectOpts.useConsole)
: true;
};
Debug.alwaysDiff = function alwaysDiff() {
return 'alwaysDiff' in Debug.inspectOpts
? Boolean(Debug.inspectOpts.alwaysDiff)
: false;
};
/**
* Selects a color for a debug namespace

@@ -351,2 +373,24 @@ * @param {String} namespace The namespace string for the for the debug instance to be colored

};
Debug.level = DebugLevel.DEBUG;
Debug.isBellow = function isBellow(ofLevel) {
return Debug.level > ofLevel;
};
Debug.setLevel = function setLevel(toLevel) {
if (toLevel == null || toLevel === undefined) {
Debug.level = DebugLevel.OFF;
}
else {
Debug.level = (DebugLevel[toLevel] || DebugLevel.INFO);
}
};
Debug.logIcon = '';
Debug.fatalIcon = '🛑';
Debug.errorIcon = '❗';
Debug.infoIcon = 'ℹ️';
Debug.warnIcon = '⚠️';
Debug.debugIcon = '🔹';
Debug.traceIcon = '🔸';
Debug.timeIcon = '⏱️';
Debug.endIcon = '⏱️';
Debug.timeEndIcon = '⏱️';
/**

@@ -356,41 +400,31 @@ * Invokes `util.format()` with the specified arguments and writes to stderr.

Debug.log = function log(...args) {
return process.stderr.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.log(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.fatal = function fatal(...args) {
return process.stderr.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.error(...args) : process.stderr.write(util.format.call(util, ...args) + '\n');
};
Debug.fatalIcon = '🛑';
Debug.error = function error(...args) {
return process.stderr.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.error(...args) : process.stderr.write(util.format.call(util, ...args) + '\n');
};
Debug.errorIcon = '❗';
Debug.info = function info(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.info(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.infoIcon = 'ℹ️';
Debug.warn = function warn(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.warn(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.warnIcon = '⚠️';
Debug.debug = function detail(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.debug(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.debugIcon = '🔹';
Debug.trace = function trace(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.info(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.traceIcon = '🔻';
// TODO: Implement time/end
Debug.time = function time(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.info(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.timeIcon = '⏱️';
Debug.end = function end(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.info(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.endIcon = '⏱️';
Debug.timeEnd = function timeEnd(...args) {
return process.stdout.write(util.format.call(util, ...args) + '\n');
Debug.useConsole() ? console.info(...args) : process.stdout.write(util.format.call(util, ...args) + '\n');
};
Debug.timeEndIcon = '⏱️';
Debug.now = function now() {

@@ -438,2 +472,3 @@ return process.hrtime();

}
exports.default = Debug;
//# sourceMappingURL=debug.js.map

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

import * as Utils from './utils';
export * from './debug';
export * from './process';
export * from './timer';
export * from './utils';
export { Utils };

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

Object.defineProperty(exports, "__esModule", { value: true });
const Utils = require("./utils");
exports.Utils = Utils;
__export(require("./debug"));
__export(require("./process"));
__export(require("./timer"));
__export(require("./utils"));
//# sourceMappingURL=index.js.map

@@ -9,2 +9,3 @@ /// <reference types="node" />

created: Date;
zerostamp: number;
state: string;

@@ -14,2 +15,3 @@ loadTime: number;

timestamp: Date;
micostamp: number;
serial: number;

@@ -16,0 +18,0 @@ uptime: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os");
const utils_1 = require("./utils");
const Utils = require("./utils");
const LOAD_TIME = Math.round(process.uptime() * 1000);
const CREATED = new Date(Date.now() - Math.round(LOAD_TIME));
const IDENTITY = utils_1.Utils.uuid();
const ZEROSTAMP = Utils.micros();
const IDENTITY = Utils.uuid();
// Fake gql

@@ -21,2 +22,3 @@ function gql(txt) { return txt[0]; }

created,
micostamp,
state,

@@ -67,3 +69,3 @@ loadTime,

static get(level) {
const start = utils_1.Utils.time();
const start = Utils.time();
this.refresh();

@@ -82,3 +84,3 @@ const mem = process.memoryUsage();

modules.forEach(m => scriptSize += m.size);
const span = utils_1.Utils.span(start);
const span = Utils.span(start);
return {

@@ -90,2 +92,3 @@ application: process.title,

created: CREATED,
zerostamp: ZEROSTAMP,
state: this.serial ? 'warm' : 'cold',

@@ -95,2 +98,3 @@ loadTime: LOAD_TIME,

timestamp: new Date(),
micostamp: Utils.micros(),
serial: this.serial++,

@@ -154,6 +158,6 @@ uptime: process.uptime(),

return this.modules[id];
let name = (mod === this.mainModule) ? id : utils_1.Utils.relative(file, this.mainFile);
let name = (mod === this.mainModule) ? id : Utils.relative(file, this.mainFile);
const parent = mod.parent && this.modules[mod.parent.id];
const level = parent && (parent.level + 1) || 0;
const size = utils_1.Utils.fsize(file) || 0;
const size = Utils.fsize(file) || 0;
const info = { id, name, size, package: undefined, file, level, parent };

@@ -160,0 +164,0 @@ this.modules[id] = info;

@@ -1,30 +0,7 @@

/// <reference types="node" />
import 'reflect-metadata';
export declare const Utils: {
mem(): string;
mb(size: number): string;
isGzip(buf: string | Buffer): boolean;
relative(path: string, root: string, rem?: string, wit?: string): string;
fsize(path: string): number;
readFile(path: string): string;
readJson(path: string): any;
writeFile(path: string, content: string | Buffer): import("fs").Stats;
appendFile(path: string, content: string | Buffer): import("fs").Stats;
time(): [number, number];
span(start: [number, number], offset?: number): string;
isUUID(str: string): boolean;
isBase64(str: string): boolean;
wildcardMatch(rule: string, value: string): boolean;
camelCase(str: string, firstCapital?: boolean): string;
snakeCase(str: string, upper?: boolean): string;
kebapCase(str: string, upper?: boolean): string;
titleCase(str: string): string;
indent(text: string, spaces?: string | number): string;
literal(obj: any): string;
parseMap(map: string, prefix?: string): Record<string, any>;
uuid(): string;
password(): string;
isClass(cls: any): cls is Function;
getArgs(func: (...args: any[]) => any): string[];
baseClass(cls: Function): Function;
};
export * from './file';
export * from './js';
export * from './misc';
export * from './rand';
export * from './text';
export * from './time';
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const js = require("./js");
const rand = require("./rand");
const text = require("./text");
const time = require("./time");
const file = require("./file");
const misc = require("./misc");
// tslint:disable-next-line:variable-name
exports.Utils = Object.assign({}, js, rand, text, time, file, misc);
__export(require("./file"));
__export(require("./js"));
__export(require("./misc"));
__export(require("./rand"));
__export(require("./text"));
__export(require("./time"));
//# sourceMappingURL=index.js.map

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

export declare function micros(): number;
export declare function time(): [number, number];
export declare function span(start: [number, number], offset?: number): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LOAD = process.hrtime();
const ZERO = Date.now();
function micros() {
const hd = process.hrtime(LOAD);
const now = (ZERO + hd[0] * 1000) * 1000 + Math.floor(hd[1] / 1000);
return now;
}
exports.micros = micros;
function time() {

@@ -4,0 +12,0 @@ return process.hrtime();

{
"name": "exer",
"version": "0.0.15",
"version": "0.0.16",
"description": "Utils in TypeScript, Debug, NanoTimer ...",

@@ -41,6 +41,8 @@ "author": "kbajalc@gmail.com",

"devDependencies": {
"@types/lodash": "^4.14.123",
"@types/node": "^10.12.30",
"@types/uuid": "^3.4.4",
"ts-node": "^8.0.3",
"tslint": "^5.15.0",
"lodash": "^4.17.11",
"ts-node": "^8.1.0",
"tslint": "^5.16.0",
"tslint-config-airbnb": "^5.11.1",

@@ -47,0 +49,0 @@ "tty": "^1.0.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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