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

@travetto/transformer

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/transformer - npm Package Compare versions

Comparing version 3.4.0 to 3.4.1

2

package.json
{
"name": "@travetto/transformer",
"version": "3.4.0",
"version": "3.4.1",
"description": "Functionality for AST transformations, with transformer registration, and general utils",

@@ -5,0 +5,0 @@ "keywords": [

@@ -299,2 +299,8 @@ import ts from 'typescript';

let unique: string | undefined;
let name = type.name && !type.name.startsWith('_') ? type.name : '';
if (!name && hasEscapedName(node)) {
name = `${node.name.escapedText}`;
}
name ||= 'Shape';
try {

@@ -306,3 +312,17 @@ // Tie to source location if possible

if (fileName === this.source.fileName) { // if in same file suffix with location
unique = `${ts.getLineAndCharacterOfPosition(tgt.getSourceFile(), tgt.getStart()).line}_${tgt.getEnd() - tgt.getStart()}`;
const route: string[] = [];
let child = node;
while (child && !ts.isSourceFile(child)) {
if (ts.isFunctionDeclaration(child) || ts.isMethodDeclaration(child) || ts.isClassDeclaration(child)) {
if (child.name) {
route.push(child.name.getText());
}
}
child = child.parent;
}
if (!route.length) { // Only filename
route.push(ts.getLineAndCharacterOfPosition(tgt.getSourceFile(), tgt.getStart()).line.toString());
}
route.unshift(fileName);
unique = SystemUtil.naiveHashString(route.join(':'), 12);
} else {

@@ -314,11 +334,6 @@ // Otherwise treat it as external and add nothing to it

const imp = this.#resolver.getFileImportName(this.source.fileName);
unique = `${SystemUtil.naiveHash(`${imp}${type.name ?? 'unknown'}`)}`;
unique = SystemUtil.naiveHashString(`${imp}${type.name ?? 'unknown'}`, 12);
}
// Otherwise read name with uuid
let name = type.name && !type.name.startsWith('_') ? type.name : '';
if (!name && hasEscapedName(node)) {
name = `${node.name.escapedText}`;
}
name ||= 'Shape';
return unique ? `${name}_${unique}` : name;
return unique ? `${name}__${unique}` : name;
}

@@ -325,0 +340,0 @@

@@ -31,2 +31,6 @@ import crypto from 'crypto';

}
static naiveHashString(text: string, length: number): string {
return this.naiveHash(text).toString().padStart(length, '0').substring(0, length);
}
}

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