# simple-spy

> yet another spy library

Latest version **4.0.1** (published 2022-07-12) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2022-07-12 |
| First published | 2015-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 17 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Oskar Karlsson |
| Maintainers | tjoskar |
| Keywords | spy |

## Links

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

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@sampuli/data](https://npm.io/package/@sampuli/data.md) — 0 weekly downloads
- [screengraft](https://npm.io/package/screengraft.md) — 0 weekly downloads
- [directus-extension-seed-studio](https://npm.io/package/directus-extension-seed-studio.md) — 0 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2022-07-12
- 4.0.0 — 2022-07-12
- 3.0.1 — 2019-08-06
- 3.0.0 — 2019-06-26
- 2.2.1 — 2017-12-13
- 2.2.0 — 2017-12-13
- 2.1.0 — 2016-12-11
- 2.0.4 — 2016-10-29
- 2.0.3 — 2016-09-10
- 2.0.2 — 2016-09-10
- 2.0.1 — 2016-09-10
- 2.0.0 — 2016-09-10
- 1.0.3 — 2015-08-19
- 1.0.2 — 2015-08-18
- 1.0.1 — 2015-08-18
- … 1 more at https://npm.io/package/simple-spy/versions

## README

# simple-spy [![Coverage Status](https://coveralls.io/repos/github/tjoskar/simple-spy/badge.svg?branch=master)](https://coveralls.io/github/tjoskar/simple-spy?branch=master)

> yet another spy library


## Install

```
$ npm install --save simple-spy
```


## Usage

```js
import { spy } from 'simple-spy'

const fun = (...args) => console.log(...args)
const funSpy = spy(fun)

assert(funSpy.callCount === 0)
assert(funSpy.args.length === 0)

funSpy('Hello Dexter Morgan') // Output:  Hello Dexter Morgan

assert(funSpy.callCount === 1)
assert(funSpy.args.length === 1)
assert(funSpy.args[0][0] === 'Hello Dexter Morgan')

funSpy.reset()

funSpy(1, 2, 3) // Output:  1 2 3

assert(funSpy.callCount === 1)
assert(funSpy.args.length === 1)
assert(funSpy.args[0].length === 3)
assert(funSpy.args[0][0] === 1)
assert(funSpy.args[0][1] === 2)
assert(funSpy.args[0][2] === 3)
```


## API

### spy(fun)

#### fun

Type: `function`


## License

MIT © [Oskar Karlsson](http://oskarkarlsson.nu)

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