JavaScript API
Pure Index provides a JavaScript API which is usable from Node.js. You only have to use this if the use of Pure Index goes beyond the monorepo.
findUnusedExports
This function lets you find unused package exports by checking imports in different repositories.
Formulae
Arguments
entry
- Type:
string
- Required:
true
Path to the package index file. Relative to the package location.
location
- Type:
string
- Required:
false
- Default:
''
pkgName
- Type:
string
- Required:
false
- Default:
undefined
Allows you to specify the name of the package to be searched (instead of package.json -> name
).
repositories
- Type:
Item[]
- Required:
true
List of repositories where to look for package imports.
You can find the description of each field in the configuration section. If you don’t provide values for optional parameters, they will be taken as defaults.
Returns
Promise with a Result
object.
- if no unused exports were found,
result.ok = true
- if unused exports were found,
result.ok = false
Example
collectUsages
This function allows you to collect all package usage in different repositories.
Formulae
Arguments
name
- Type:
string
- Required:
true
The name of the package to look for.
repositories
- Type:
Item[]
- Required:
true
List of repositories where to look for package imports.
You can find the description of each field in the configuration section. If you don’t provide values for optional parameters, they will be taken as defaults.
Returns
Promise with a Result
object.
- if imports were found,
result.ok = true
- if no imports were found,
result.ok = false