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

@dbux/common

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbux/common - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4-dev.1

src/console.js

4

package.json
{
"name": "@dbux/common",
"version": "0.6.3",
"version": "0.6.4-dev.1",
"description": "",

@@ -19,3 +19,3 @@ "module": "src/index.js",

"_moduleAliases": {},
"gitHead": "92dd244aa0d1c7b4dd230b2d538be1db0383b7c2"
"gitHead": "68ae661ec58644650c06aa807748d1551d4b2cc1"
}

@@ -1,55 +0,6 @@

/* eslint no-console: 0 */
import NanoEvents from 'nanoevents';
import { consoleOutputStreams } from '../console';
(function _compatabilityHackfix() {
// NOTE: console.debug is not supported in some environments and babel, for some reason, does not polyfill it
// eslint-disable-next-line no-console
console.debug = console.debug || console.log;
})();
// ###########################################################################
// outside log event handler
// ###########################################################################
let logRecords;
// let logRecorder;
function addLogRecord(type, ...args) {
(logRecords[type] = logRecords[type] || []).push(args);
}
export function playbackLogRecords() {
const entries = Object.entries(logRecords);
const n = entries.reduce((a, [, msgs]) => a + msgs.length, 0);
if (!n) {
// nothing to report
return;
}
for (const [type, msgs] of entries) {
console[type].call(console, `${msgs.length} x ${type}s:`);
msgs.forEach((args, i) => {
console[type].call(console, ` `, ...args);
});
}
}
/**
* Little hackfix for simplistic "log counting".
*/
export function enableLogRecording() {
logRecords = {};
// NOTE: for now, only count warn + error log messages
addOutputStreams(Object.fromEntries(
['warn', 'error']
.map(type => {
return [type, addLogRecord.bind(null, type)];
})
));
}
// ###########################################################################
// reporting + flood gating

@@ -177,10 +128,2 @@ // ###########################################################################

const consoleOutputStreams = {
log: console.log.bind(console),
warn: console.warn.bind(console),
debug: console.debug.bind(console),
error: console.error.bind(console),
trace: console.trace.bind(console),
};
let outputStreams = consoleOutputStreams;

@@ -206,3 +149,3 @@

export function loglog(ns, ...args) {
function loglog(ns, ...args) {
outputStreams.log(wrapNs(ns), ...args);

@@ -212,3 +155,3 @@ }

// const prettyDebug = makePrettyLog(console.debug, 'gray');
export function logDebug(ns, ...args) {
function logDebug(ns, ...args) {
// color decoration

@@ -221,3 +164,3 @@ // prettyDebug(wrapNs(ns), ...args);

export function logWarn(ns, ...args) {
function logWarn(ns, ...args) {
ns = wrapNs(ns);

@@ -234,3 +177,3 @@ outputStreams.warn(ns, ...args);

export function logTrace(ns, ...args) {
function logTrace(ns, ...args) {
ns = wrapNs(ns);

@@ -256,2 +199,44 @@ outputStreams.trace(ns, ...args);

outputStreams = mergeOutputStreams(newOutputStreams);
}
}
// // ###########################################################################
// // log playback experiments (unused)
// // ###########################################################################
// let logRecords;
// // let logRecorder;
// export function playbackLogRecords() {
// const entries = Object.entries(logRecords);
// const n = entries.reduce((a, [, msgs]) => a + msgs.length, 0);
// if (!n) {
// // nothing to report
// return;
// }
// for (const [type, msgs] of entries) {
// console[type].call(console, `${msgs.length} x ${type}s:`);
// msgs.forEach((args, i) => {
// console[type].call(console, ` `, ...args);
// });
// }
// }
// function addLogRecord(type, ...args) {
// (logRecords[type] = logRecords[type] || []).push(args);
// }
// /**
// * Little hackfix for simplistic "log counting".
// */
// export function enableLogRecording() {
// logRecords = {};
// // NOTE: for now, only count warn + error log messages
// addOutputStreams(Object.fromEntries(
// ['warn', 'error']
// .map(type => {
// return [type, addLogRecord.bind(null, type)];
// })
// ));
// }

@@ -101,5 +101,6 @@ /**

function printTimer(what, timer, buffer) {
if (buffer.length > 1e8) {
timer.print(debug, `${what} (not small buffer): ${Math.round(buffer.length / 1000).toLocaleString('en-us')} kb`);
}
// if (buffer.length > 1e8) {
const msg = buffer.length > 1e8 ? ' (buffer NOT SMALL)' : '';
timer.print(debug, `${what}${msg}: ${Math.round(buffer.length / 1000).toLocaleString('en-us')} kb`);
// }
}

@@ -181,5 +182,6 @@

export default {
const msgpackParser = {
Encoder,
Decoder
};
export default msgpackParser;
import Enum from '../../util/Enum';
/**
* Allows discerning
* Allows discerning between different call, apply, bind.
*/

@@ -6,0 +6,0 @@ let specialCallType = {

/** @typedef {import('../Loc').default} Loc */
/**
* WARNING: This is a bit of a mess.
* -> `dbux-babel-plugin` has two versions of this (StaticContextCollection vs. `staticData` `buildDbuxInit` in `staticdata.js`)
* -> `dbux-runtime` has another version (staticProgramContextCollection)
* -> `dbux-code` adds `applicationId`
* NOTE: this is NOT a `StaticContext`.
* This thing just tracks extra program information and is added in `staticProgramContextCollection.addProgram`.
* You can correlate them with other data using `byProgram` and `byFile` indexes,
* e.g.: `dp.indexes.staticContexts.byFile`
*
*
* @type {number}
*/
export default class StaticProgramContext {
/**
* WARNING: this is only added by dbux-data (not available during runtime).
*
* @type {number}
*/
applicationId;
/**
* `Date.now()`.
*
* @type {number}
*/
createdAt;

@@ -15,0 +27,0 @@ /**

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

export class TracePurposeInfo {
type;
// more context-sensitive data here
}
export default class Trace {

@@ -51,2 +57,7 @@ /**

/**
* @type {TracePurposeInfo[]}
*/
purposes;
/**
* NOTE: this is the dynamic type only.

@@ -53,0 +64,0 @@ * Use DataProvider.util.getTraceType to get actual TraceType.

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

import isFunction from 'lodash/isFunction';

@@ -6,7 +7,15 @@ export default class EventHandlerList {

constructor(...unsubscribeCallbacks) {
this.subscribe(...unsubscribeCallbacks);
this.subscribe(unsubscribeCallbacks);
}
subscribe(...unsubscribeCallbacks) {
this._unsubscribeCallbacks.push(...unsubscribeCallbacks);
unsubscribeCallbacks = unsubscribeCallbacks.flat(1000);
this._unsubscribeCallbacks.push(...unsubscribeCallbacks.map(
cb => {
if (!isFunction(cb)) {
throw new Error(`EventHandlerList.subcribe expects functions. Found: ${cb}`);
}
return cb;
}
));
}

@@ -13,0 +22,0 @@

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

export default async function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
const P = Promise;
export default async function sleep(ms) { return new P(r => setTimeout(r, ms)); }

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

import truncate from 'lodash/truncate';
export function makeStringSimpleRenderable(s) {

@@ -9,1 +11,12 @@ return s.replace(/\s+/g, ' ');

}
const ShortenMaxLength = 100;
const ShortenCfg = { length: ShortenMaxLength };
/**
* @param {string} s
*/
export function makeShortString(s, cfg = ShortenCfg) {
return truncate(s.replace(/\s+/g, ' '), cfg);
}

@@ -50,7 +50,14 @@ /**

export function _require(name) {
if (_r !== undefined) {
return _r;
}
// eslint-disable-next-line no-eval
const r = _r || (_r = eval(`
(typeof __non_webpack_require__ !== 'undefined' && __non_webpack_require__ || require)
`));
return r(name);
_r = eval(`
((typeof __non_webpack_require__ !== 'undefined' && __non_webpack_require__) ||
(typeof require !== 'undefined' && require))
`) || null;
if (!_r) {
return null;
}
return _r(name);
}

@@ -57,0 +64,0 @@

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