Skip to content

Repository files navigation

@depack/detect

npm version

@depack/detect Detects Dependencies In The Source File.

yarn add -E @depack/detect

Table Of Contents

API

The package is available by importing its default function:

importdetectfrom'@depack/detect'

detect(
source: string,
): Array<string>

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

For example, for the given source file

importtestfrom'test'importtest2,*astest3from'test2'import'test3'export{defaultasTest}from'test4'

It will produce the following output

/* yarn example/ */importdetectfrom'@depack/detect'importreadfrom'@wrote/read'(async()=>{constsource=awaitread('example/source.js')constres=detect(source)console.log(res)})()
['test','test2','test3','test4']

Copyright

Art Deco© Art Deco for Depack 2019Tech Nation VisaTech Nation Visa Sucks

About

Detects Dependencies In The Source File.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages