# require-spy

> Check if a given node module have been required

Latest version **1.0.0** (published 2017-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install require-spy
pnpm add require-spy
yarn add require-spy
bun add require-spy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-03-07 |
| First published | 2017-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Thomas Watson Steen |
| Maintainers | watson |
| Keywords | require, module, test |

## Links

- npm: https://www.npmjs.com/package/require-spy
- Repository: https://github.com/watson/require-spy
- Homepage: https://github.com/watson/require-spy#readme
- Issues: https://github.com/watson/require-spy/issues
- npm.io page: https://npm.io/package/require-spy

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-03-07

## README

# require-spy

Check if a given node module have been required.

[![Build status](https://travis-ci.org/watson/require-spy.svg?branch=master)](https://travis-ci.org/watson/require-spy)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```
npm install require-spy
```

## Usage

```js
var spy = require('require-spy')
var http = require('http')

// all modules required after spy.start is called are logged
spy.start()

var fs = require('fs')

console.log(spy.check('http')) // false
console.log(spy.check('fs')) // true
```

## API

### `spy.start()`

Start the spy.

Alternatively you can require the `require-spy/start` script either
inline or via the command line:

```
node -r require-spy/start app.js
```

This will auto-start the spy.

### `spy.check(name)`

Returns `true` if the given `name` have already been required. Otherwise
`false.

## License

MIT

---
_Source: https://npm.io/package/require-spy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
