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

detective-typescript

Package Overview
Dependencies
Maintainers
3
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 7.0.1 to 7.0.2

30

index.js

@@ -13,6 +13,5 @@ 'use strict';

*/
module.exports = function(src, options = {}) {
module.exports = (src, options = {}) => {
const walkerOptions = { ...options, parser: Parser };
const walkerOptions = Object.assign({}, options, {parser: Parser});
// Determine whether to skip "type-only" imports

@@ -28,15 +27,10 @@ // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#import-types

const walker = new Walker(walkerOptions);
const dependencies = [];
if (typeof src === 'undefined') {
throw new Error('src not given');
}
if (typeof src === 'undefined') throw new Error('src not given');
if (src === '') return dependencies;
if (src === '') {
return dependencies;
}
const walker = new Walker(walkerOptions);
walker.walk(src, function(node) {
walker.walk(src, (node) => {
switch (node.type) {

@@ -49,3 +43,3 @@ case 'ImportExpression':

case 'ImportDeclaration':
if (skipTypeImports && node.importKind == 'type') {
if (skipTypeImports && node.importKind === 'type') {
break;

@@ -91,3 +85,3 @@ }

default:
return;
// nothing
}

@@ -99,4 +93,4 @@ });

module.exports.tsx = function(src, options) {
return module.exports(src, Object.assign({}, options, { jsx: true }));
module.exports.tsx = (src, options) => {
return module.exports(src, { ...options, jsx: true });
};

@@ -107,3 +101,5 @@

return node.arguments[0].value;
} else if (node.arguments[0].type === 'TemplateLiteral') {
}
if (node.arguments[0].type === 'TemplateLiteral') {
return node.arguments[0].quasis[0].value.raw;

@@ -110,0 +106,0 @@ }

{
"name": "detective-typescript",
"version": "7.0.1",
"version": "7.0.2",
"author": "Patrik Henningsson <patrik.henningsson@gmail.com>",
"description": "Get the dependencies of a TypeScript module",
"main": "index.js",
"files": [
"index.js"
],
"scripts": {
"test": "eslint index.js test/test.js && mocha test/test.js",
"watch": "mocha -w test/test.js"
"lint": "eslint index.js test/test.js",
"mocha": "mocha",
"test": "npm run lint && npm run mocha",
"watch": "npm run mocha -- -w"
},

@@ -11,0 +16,0 @@ "repository": {

@@ -1,6 +0,8 @@

### detective-typescript [![Build Status](http://img.shields.io/travis/pahen/detective-typescript/master.svg?style=flat-square)](https://travis-ci.org/pahen/detective-typescript) [![npm](http://img.shields.io/npm/v/detective-typescript.svg)](https://npmjs.org/package/detective-typescript) [![npm](http://img.shields.io/npm/dm/detective-typescript.svg)](https://npmjs.org/package/detective-typescript)
### detective-typescript [![CI](https://github.com/pahen/detective-typescript/actions/workflows/ci.yml/badge.svg)](https://github.com/pahen/detective-typescript/actions/workflows/ci.yml) [![npm](http://img.shields.io/npm/v/detective-typescript.svg)](https://npmjs.org/package/detective-typescript) [![npm](http://img.shields.io/npm/dm/detective-typescript.svg)](https://npmjs.org/package/detective-typescript)
> Get the dependencies of TypeScript module
`npm install detective-typescript`
```sh
npm install detective-typescript
```

@@ -10,7 +12,7 @@ ### Usage

```js
var detective = require('detective-typescript');
var mySourceCode = fs.readFileSync('myfile.ts', 'utf8');
const detective = require('detective-typescript');
const mySourceCode = fs.readFileSync('myfile.ts', 'utf8');
// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);
const dependencies = detective(mySourceCode);
```

@@ -20,6 +22,6 @@

- `skipTypeImports` (default: false) Skips imports that only imports types
- `mixedImports`: (default: false) Include CJS imports in dependency list
- `skipAsyncImports`: (default: false) Whether or not to omit async imports (import('foo'))
- `jsx`: (default: false) Enable parsing of JSX
- `skipTypeImports` (default: `false`) Skips imports that only imports types
- `mixedImports`: (default: `false`) Include CJS imports in dependency list
- `skipAsyncImports`: (default: `false`) Whether or not to omit async imports (import('foo'))
- `jsx`: (default: `false`) Enable parsing of JSX

@@ -26,0 +28,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