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

@waiting/shared-core

Package Overview
Dependencies
Maintainers
0
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waiting/shared-core - npm Package Compare versions

Comparing version 23.22.0 to 23.23.0

2

dist/lib/callstack/types.d.ts

@@ -9,3 +9,5 @@ export interface CallerInfo extends CallerInfoBase {

columnNumber: number;
/** @deprecated since nodejs v22.9 */
enclosingLineNumber: number;
/** @deprecated since nodejs v22.9 */
enclosingColNumber: number;

@@ -12,0 +14,0 @@ }

2

dist/lib/callstack/util.d.ts

@@ -18,3 +18,3 @@ import type { CallerInfo } from './types.js';

/**
* Get stack string
* Get stack string, line/colum number transformed with source-map
* @see https://stackoverflow.com/a/13227808

@@ -21,0 +21,0 @@ */

@@ -5,2 +5,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */

import { normalize } from 'node:path';
import util from 'node:util';
import semver from 'semver';

@@ -24,3 +25,5 @@ const maxStackDepth = 128;

columnNumber: -1,
/** @deprecated since nodejs v22.9 */
enclosingLineNumber: -1,
/** @deprecated since nodejs v22.9 */
enclosingColNumber: -1,

@@ -61,3 +64,61 @@ };

retrievePosition = false) {
const info = getCallerStackSimpleInfo(callerDistance + 1);
if (!retrievePosition) {
return info;
}
const stack = getStack();
if (!stack.length) {
return info;
}
const depth = callerDistance + 1;
const arr = stack.split('\n');
const line2 = arr[depth + 1];
assert(line2, 'Retrieve stack of caller failed, line empty.');
const infoBase = retrieveInfoPathWithLineCol(line2);
const srcPath = infoBase.path && !infoBase.path.startsWith('file:///')
? 'file:///' + normalize(infoBase.path).replace(/\\/ug, '/')
: infoBase.path;
const caller = {
...info,
line: infoBase.line,
column: infoBase.column,
srcPath,
};
if (isNodeGteV20 && !isExecWithEnableSourceMaps()) {
const str = caller.path.toLowerCase();
if (str.endsWith('.ts') || str.endsWith('.mts')) {
if (caller.line === caller.lineNumber && caller.column === caller.columnNumber) {
console.warn(`Warning getCallerStack(): Nodejs >= 20.0.0, but not exec with --enable-source-maps. return line and column may incorrect. \n file: "${caller.path}"`);
}
}
}
return caller;
}
/**
* Get stack string, line/colum number not transformed with source-map
*/
function getCallerStackSimpleInfo(callerDistance = 0) {
const depth = callerDistance + 1;
// @link https://github.com/nodejs/node/releases/tag/v22.9.0
// @ts-ignore since node v22.9
if (typeof util.getCallSite === 'function') {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const callSites = util.getCallSite(depth + 1);
const site = callSites[depth];
assert(site, 'stack empty');
const info = {
...initInfo,
path: site.scriptName,
fileName: site.scriptName,
className: '',
funcName: '',
methodName: '',
lineNumber: site.lineNumber,
columnNumber: site.column,
enclosingLineNumber: -1,
enclosingColNumber: -1,
};
return info;
}
const stacks = getStackCallerSites(depth + 1);

@@ -103,34 +164,6 @@ const site = stacks[depth];

};
if (!retrievePosition) {
return info;
}
const stack = getStack();
if (!stack.length) {
return info;
}
const arr = stack.split('\n');
const line2 = arr[depth + 1];
assert(line2, 'Retrieve stack of caller failed, line empty.');
const infoBase = retrieveInfoPathWithLineCol(line2);
const srcPath = infoBase.path && !infoBase.path.startsWith('file:///')
? 'file:///' + normalize(infoBase.path).replace(/\\/ug, '/')
: infoBase.path;
const caller = {
...info,
line: infoBase.line,
column: infoBase.column,
srcPath,
};
if (isNodeGteV20 && !isExecWithEnableSourceMaps()) {
const str = caller.path.toLowerCase();
if (str.endsWith('.ts') || str.endsWith('.mts')) {
if (caller.line === caller.lineNumber && caller.column === caller.columnNumber) {
console.warn(`Warning getCallerStack(): Nodejs >= 20.0.0, but not exec with --enable-source-maps. return line and column may incorrect. \n file: "${caller.path}"`);
}
}
}
return caller;
return info;
}
/**
* Get stack string
* Get stack string, line/colum number transformed with source-map
* @see https://stackoverflow.com/a/13227808

@@ -137,0 +170,0 @@ */

{
"name": "@waiting/shared-core",
"author": "waiting",
"version": "23.22.0",
"version": "23.23.0",
"description": "node core function re export with Promise or Observable",

@@ -83,3 +83,3 @@ "keywords": [

},
"gitHead": "704e9cc57d1468cd7e094cbf8aa963d88f3ad0bc"
"gitHead": "a729be1370b4b92fb935db2c55a2173058a6f4b4"
}
export interface CallerInfo extends CallerInfoBase {
srcPath: string
// from StackFram
// from StackFrame
fileName: string

@@ -11,3 +11,5 @@ className: string

columnNumber: number
/** @deprecated since nodejs v22.9 */
enclosingLineNumber: number
/** @deprecated since nodejs v22.9 */
enclosingColNumber: number

@@ -14,0 +16,0 @@ }

@@ -5,2 +5,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */

import { normalize } from 'node:path'
import util from 'node:util'

@@ -32,3 +33,5 @@ import semver from 'semver'

columnNumber: -1,
/** @deprecated since nodejs v22.9 */
enclosingLineNumber: -1,
/** @deprecated since nodejs v22.9 */
enclosingColNumber: -1,

@@ -78,3 +81,79 @@ }

const info = getCallerStackSimpleInfo(callerDistance + 1)
if (! retrievePosition) {
return info
}
const stack = getStack()
if (! stack.length) {
return info
}
const depth = callerDistance + 1
const arr = stack.split('\n')
const line2 = arr[depth + 1]
assert(line2, 'Retrieve stack of caller failed, line empty.')
const infoBase = retrieveInfoPathWithLineCol(line2)
const srcPath = infoBase.path && ! infoBase.path.startsWith('file:///')
? 'file:///' + normalize(infoBase.path).replace(/\\/ug, '/')
: infoBase.path
const caller: CallerInfo = {
...info,
line: infoBase.line,
column: infoBase.column,
srcPath,
}
if (isNodeGteV20 && ! isExecWithEnableSourceMaps()) {
const str = caller.path.toLowerCase()
if (str.endsWith('.ts') || str.endsWith('.mts')) {
if (caller.line === caller.lineNumber && caller.column === caller.columnNumber) {
console.warn(`Warning getCallerStack(): Nodejs >= 20.0.0, but not exec with --enable-source-maps. return line and column may incorrect. \n file: "${caller.path}"`)
}
}
}
return caller
}
/**
* @link https://github.com/nodejs/node/releases/tag/v22.9.0
*/
interface CallerInfoOrigin {
functionName: string
scriptName: string
lineNumber: number
column: number
}
/**
* Get stack string, line/colum number not transformed with source-map
*/
function getCallerStackSimpleInfo(callerDistance = 0): CallerInfo {
const depth = callerDistance + 1
// @link https://github.com/nodejs/node/releases/tag/v22.9.0
// @ts-ignore since node v22.9
if (typeof util.getCallSite === 'function') {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const callSites: CallerInfoOrigin[] = util.getCallSite(depth + 1)
const site = callSites[depth]
assert(site, 'stack empty')
const info: CallerInfo = {
...initInfo,
path: site.scriptName,
fileName: site.scriptName,
className: '',
funcName: '',
methodName: '',
lineNumber: site.lineNumber,
columnNumber: site.column,
enclosingLineNumber: -1,
enclosingColNumber: -1,
}
return info
}
const stacks = getStackCallerSites(depth + 1)

@@ -128,38 +207,8 @@ const site = stacks[depth]

if (! retrievePosition) {
return info
}
return info
}
const stack = getStack()
if (! stack.length) {
return info
}
const arr = stack.split('\n')
const line2 = arr[depth + 1]
assert(line2, 'Retrieve stack of caller failed, line empty.')
const infoBase = retrieveInfoPathWithLineCol(line2)
const srcPath = infoBase.path && ! infoBase.path.startsWith('file:///')
? 'file:///' + normalize(infoBase.path).replace(/\\/ug, '/')
: infoBase.path
const caller: CallerInfo = {
...info,
line: infoBase.line,
column: infoBase.column,
srcPath,
}
if (isNodeGteV20 && ! isExecWithEnableSourceMaps()) {
const str = caller.path.toLowerCase()
if (str.endsWith('.ts') || str.endsWith('.mts')) {
if (caller.line === caller.lineNumber && caller.column === caller.columnNumber) {
console.warn(`Warning getCallerStack(): Nodejs >= 20.0.0, but not exec with --enable-source-maps. return line and column may incorrect. \n file: "${caller.path}"`)
}
}
}
return caller
}
/**
* Get stack string
* Get stack string, line/colum number transformed with source-map
* @see https://stackoverflow.com/a/13227808

@@ -166,0 +215,0 @@ */

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