Socket
Socket
Sign inDemoInstall

detective-typescript

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective-typescript - npm Package Compare versions

Comparing version 11.0.2 to 11.1.0

14

index.js

@@ -32,2 +32,10 @@ 'use strict';

// Pre-parse the source to get the AST to pass to `onFile`,
// then reuse that AST below in our walker walk.
const ast = typeof src === 'string' ? walker.parse(src) : src;
if (options.onFile) {
options.onFile({ options, src, ast, walker });
}
walker.walk(src, node => {

@@ -104,2 +112,6 @@ switch (node.type) {

if (options.onAfterFile) {
options.onAfterFile({ options, src, ast, walker, dependencies });
}
return dependencies;

@@ -113,3 +125,3 @@ };

function extractDependencyFromRequire(node) {
if (node.arguments[0].type === 'Literal' || node.arguments[0].type === 'StringLiteral') {
if (['Literal', 'StringLiteral'].includes(node.arguments[0].type)) {
return node.arguments[0].value;

@@ -116,0 +128,0 @@ }

2

package.json
{
"name": "detective-typescript",
"version": "11.0.2",
"version": "11.1.0",
"author": "Patrik Henningsson <patrik.henningsson@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Get the dependencies of a TypeScript module",

@@ -31,2 +31,4 @@ # detective-typescript

- `jsx`: (default: `false`) Enable parsing of JSX
- `onFile`: A callback that will be called before the file is processed. Intended for use with [`dependency-tree`](https://github.com/dependents/node-dependency-tree). Passed an object argument with properties `options` (echoing any options passed in, e.g., by [`precinct`](https://github.com/dependents/node-precinct)), `src` (source code for file as string), `ast` (parsed AST object for the file source), and `walker` (a `Walker` instance from [`node-source-walk`](https://github.com/dependents/node-source-walk) configured for TypeScript to which you can pass the `ast` or `src`).
- `onAfterFile`: Similar to `onFile`, but the callback is also passed an object property `dependencies`, a string array with the extracted dependencies.

@@ -33,0 +35,0 @@ ## License

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