Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dpck/detect

Detects Dependencies In The Source File.
https://github.com/dpck/detect

Last synced: about 1 month ago
JSON representation

Detects Dependencies In The Source File.

Awesome Lists containing this project

README

        

# @depack/detect

[![npm version](https://badge.fury.io/js/%40depack%2Fdetect.svg)](https://npmjs.org/package/@depack/detect)

`@depack/detect` Detects Dependencies In The Source File.

```sh
yarn add -E @depack/detect
```

## Table Of Contents

- [Table Of Contents](#table-of-contents)
- [API](#api)
- [`detect(source: string): Array`](#detectsource-string-arraystring)
- [Copyright](#copyright)

## API

The package is available by importing its default function:

```js
import detect from '@depack/detect'
```

## `detect(`
  `source: string,`
`): Array`

Returns the paths or names of packages that are imported in the source code.

_For example, for the given source file_
```js
import test from 'test'
import test2, * as test3 from 'test2'
import 'test3'
export { default as Test } from 'test4'
```

_It will produce the following output_

```js
/* yarn example/ */
import detect from '@depack/detect'
import read from '@wrote/read'

(async () => {
const source = await read('example/source.js')
const res = detect(source)
console.log(res)
})()
```
```js
[ 'test', 'test2', 'test3', 'test4' ]
```

## Copyright




Art Deco


© Art Deco for Depack 2019


Tech Nation Visa


Tech Nation Visa Sucks