# promise-conveniences

> Add some helpers to native Promises

Latest version **1.3.0** (published 2019-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-conveniences
pnpm add promise-conveniences
yarn add promise-conveniences
bun add promise-conveniences
```

## 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.3.0 |
| Published | 2019-12-17 |
| First published | 2018-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | James M. Barton |
| Maintainers | tivomaker |

## Links

- npm: https://www.npmjs.com/package/promise-conveniences
- Repository: https://github.com/TiVoMaker/looper
- Homepage: https://github.com/TiVoMaker/looper#readme
- Issues: https://github.com/TiVoMaker/looper/issues
- npm.io page: https://npm.io/package/promise-conveniences

## Recent versions

- 1.3.0 (latest) — 2019-12-17
- 1.2.1 — 2018-12-27
- 1.2.0 — 2018-12-14
- 1.1.0 — 2018-10-09
- 1.0.0 — 2018-05-30

## README

# Promise Conveniences

I've found myself making  a few Promise helpers over and over, and I was getting tired of it. I made this to reduce the drudgery of it.

Just require it:

	require('promise-conveniences');

A looping construct:

	console.log(Promise.looper(
		function worker (value) {
			return Promise.resolve(value + 1);
		},
		function checker (nextResult) {
			return nextResult < 10;
		},
		1
	));   // 10
	
If you provide an initial value, it's a **while** loop, or without one it's a **do...until** loop.

If the initial value is a Promise, it will wait for the Promise to
resolve before starting the loop.

You may return a Promise from the checker, in which case it will wait
for the Promise to resolve, and will continue if it resolves with a truthy value, passing the
the last worker result to the next invocation.

To wait a specific amount of time:

	const then = Date.now();
	Promise.waiter(2500)
	.then(() => {
		const now = Date.now();
		console.log(`Waited ${now - then} milliseconds`);   // 2504
	});

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