https://github.com/aduth/is-dependency
Quickly determine if the given package(s) are dependencies in the current directory
https://github.com/aduth/is-dependency
Last synced: 8 months ago
JSON representation
Quickly determine if the given package(s) are dependencies in the current directory
- Host: GitHub
- URL: https://github.com/aduth/is-dependency
- Owner: aduth
- License: mit
- Created: 2021-12-18T18:02:20.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-18T18:07:32.000Z (over 4 years ago)
- Last Synced: 2025-03-10T14:03:31.679Z (about 1 year ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `@aduth/is-dependency`
A utility to quickly determine if the given package(s) are dependencies within the current working directory.
This implementation optimizes speed over accuracy, synchronously returning true if the package is defined as a dependency in the current directory's `package.json`, regardless of whether it's actually installed.
## Installation
Install using npm:
```
npm install @aduth/is-dependency
```
## Usage
Pass a name or array of names of dependencies and receive a boolean value in return.
```js
import { isDependency } from '@aduth/is-dependency';
isDependency('@aduth/is-dependency');
// true
```
## API
### `isDependency`
Returns true if the given package name or array of names are all defined as dependency's in the current working directory's relative `package.json`.
Optionally, pass an object of options to control the behavior.
```ts
export type Options = {
/**
* Fields to check in `package.json`.
*/
fields: string[];
};
export function isDependency(
nameOrNames: string | string[],
options?: Partial | undefined
): boolean;
```
## License
Copyright 2021 Andrew Duthie
Released under the [MIT License](https://github.com/aduth/is-dependency/tree/master/LICENSE.md).