New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-auto-guard

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-auto-guard - npm Package Compare versions

Comparing version 1.0.0-alpha.29 to 1.0.0

tests/import.ts

35

lib/index.js

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

orderedSourceFiles.forEach(function (sourceFile) {
var e_4, _a, e_5, _b, e_6, _c, e_7, _d;
var e_4, _a, e_5, _b, e_6, _c, e_7, _d, e_8, _e;
var dependencies = new Map();

@@ -699,2 +699,22 @@ var addDependency = createAddDependency(dependencies);

outFile.addStatements(functions.join('\n'));
// Memoize imports within local source file
var importsMap_1 = new Map();
var _loop_1 = function (impDeclaration) {
impDeclaration.getNamedImports().forEach(function (impSpecifier) {
importsMap_1.set(impSpecifier.getText(), impDeclaration.getModuleSpecifierValue());
});
};
try {
for (var _f = __values(sourceFile.getImportDeclarations()), _g = _f.next(); !_g.done; _g = _f.next()) {
var impDeclaration = _g.value;
_loop_1(impDeclaration);
}
}
catch (e_8_1) { e_8 = { error: e_8_1 }; }
finally {
try {
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
}
finally { if (e_8) throw e_8.error; }
}
outFile.addImportDeclarations(Array.from(dependencies.entries()).reduce(function (structures, _a) {

@@ -706,2 +726,11 @@ var _b = __read(_a, 2), importFile = _b[0], imports = _b[1];

var moduleSpecifier = outFile.getRelativePathAsModuleSpecifierTo(importFile);
if (importFile.isInNodeModules()) {
// Packages within node_modules should not be referenced via relative path
for (var im in imports) {
var importDeclaration = importsMap_1.get(im);
if (importDeclaration) {
moduleSpecifier = importDeclaration;
}
}
}
var defaultImport = imports.default;

@@ -737,3 +766,3 @@ delete imports.default;

var exportStatement = "export { " + options.importGuards + " };";
var _e = sourceFile.getStatements().reduce(function (reduced, node) {
var _h = sourceFile.getStatements().reduce(function (reduced, node) {
var nodeText = node.getText().replace(/\s{2,}/g, ' ');

@@ -744,3 +773,3 @@ reduced.hasImport || (reduced.hasImport = nodeText.includes("import * as " + options.importGuards));

return reduced;
}, { hasImport: false, hasExport: false, statements: 0 }), hasImport = _e.hasImport, hasExport = _e.hasExport, statements = _e.statements;
}, { hasImport: false, hasExport: false, statements: 0 }), hasImport = _h.hasImport, hasExport = _h.hasExport, statements = _h.statements;
if (!hasImport) {

@@ -747,0 +776,0 @@ sourceFile.insertStatements(0, importStatement);

2

package.json
{
"name": "ts-auto-guard",
"version": "1.0.0-alpha.29",
"version": "1.0.0",
"description": "Generate type guard functions from TypeScript interfaces",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rhys-vdw/ts-auto-guard",

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