# fake-promise-util

> Util for simple promise simulation with optional delay.

Latest version **0.0.1** (published 2019-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install fake-promise-util
pnpm add fake-promise-util
yarn add fake-promise-util
bun add fake-promise-util
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-09-03 |
| First published | 2019-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jaka Stavanja |
| Maintainers | jstavanja |
| Keywords | fake, promise, util, quick, prototype, delay, simulation |

## Links

- npm: https://www.npmjs.com/package/fake-promise-util
- Repository: https://github.com/jstavanja/fake-promise-util
- Homepage: https://github.com/jstavanja/fake-promise-util#readme
- Issues: https://github.com/jstavanja/fake-promise-util/issues
- npm.io page: https://npm.io/package/fake-promise-util

## 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
- [@ireneliaoliao/vite-plugin-mock](https://npm.io/package/@ireneliaoliao/vite-plugin-mock.md) — 0 weekly downloads
- [fakenamely](https://npm.io/package/fakenamely.md) — 0 weekly downloads
- [@onify/fake-amqplib](https://npm.io/package/@onify/fake-amqplib.md) — 0 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2019-09-03

## README

# fake-promise-util [![Build Status](https://travis-ci.com/jstavanja/fake-promise-util.svg?branch=master)](https://travis-ci.com/jstavanja/fake-promise-util)

> Util for simple promise simulation with optional delay.

## Install

```
$ npm install fake-promise-util
```


## Usage

To simulate a delayed success, use the success method.

```js
const fakePromiseUtil = require('fake-promise-util');

const returnValue = 'Some successful result 🐵';
const delayInMs = 1000;

console.log(await fakePromiseUtil.success(returnValue, delayInMs))

// (after 1 second) => 'Some successful result 🐵'
```

To simulate a delayed fail, use the fail method.

```js
const fakePromiseUtil = require('fake-promise-util');

const returnValue = 'Some error text 🙈';
const delayInMs = 1000;

try {
    await fakePromiseUtil.fail(returnValue, delayInMs)
} catch (err) {
    console.log(err.message);
}
    
// (after 1 second) => 'Some error text 🙈'
```

## API
---
### success(returnValue?, delay?)

#### returnValue?

Type: `any`

Default: `true`

Anything you wish to succesfully return from the promise.

#### delay?

Type: `number`

Default: `0`

An optional delay that you can use to simulate a real world promise scenario.

---

### fail(errorMessage?, delay?)

#### errorMessage?

Type: `string`

Default: `Yikes.`

A string you wish to use as the error messsage, when the error is thrown inside the promise.

#### delay?

Type: `number`
Default: `0`

An optional delay that you can use to simulate a real world promise scenario.

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