# eventuate-once

> Act once upon the next occurrence of an eventuate

Latest version **1.1.0** (published 2015-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install eventuate-once
pnpm add eventuate-once
yarn add eventuate-once
bun add eventuate-once
```

## 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.1.0 |
| Published | 2015-08-10 |
| First published | 2015-07-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jason Pincin |
| Maintainers | jasonpincin |
| Keywords | eventuate, event, emitter, handler, once, callback, Promise, EventEmitter |

## Links

- npm: https://www.npmjs.com/package/eventuate-once
- Repository: https://github.com/jasonpincin/eventuate-once
- Issues: https://github.com/jasonpincin/eventuate-once/issues
- npm.io page: https://npm.io/package/eventuate-once

## Dependencies (1)

- [promise-polyfill](https://npm.io/package/promise-polyfill.md) ~2.1.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2015-08-10
- 1.0.1 — 2015-07-29
- 1.0.0 — 2015-07-28

## README

# eventuate-once

[![NPM version](https://badge.fury.io/js/eventuate-once.png)](http://badge.fury.io/js/eventuate-once)
[![Build Status](https://travis-ci.org/jasonpincin/eventuate-once.svg?branch=master)](https://travis-ci.org/jasonpincin/eventuate-once)
[![Coverage Status](https://coveralls.io/repos/jasonpincin/eventuate-once/badge.png?branch=master)](https://coveralls.io/r/jasonpincin/eventuate-once?branch=master)

Act once upon the next occurrence of an eventuate. Optionally act upon only the next matching occurrence. 

## example

```javascript
var eventuate = require('eventuate'),
    once      = require('eventuate-once')

var request = eventuate()

// once cb
once(request, function (req) {
    console.log(req)
})
request.produce({ url: '/index.html' })

// once promise
once(request).then(console.log)
request.produce({ url: '/README.md' })

// will result in no actions because consumers are gone
// (use "requireConsumers" to make this an error condition)
request.produce({ url: '/LICENSE' })
```

## api

```javascript
var once = require('eventuate-once')
```

### once(eventuate [, cb])

Execute the optional `cb` (if provided) one time on the next data payload from the `eventuate`. This is like `eventuate(cb)` except that it only happens once. In addition, returns a `Promise` that resolves to the `eventuate` data payload.

### once.match(eventuate, filter [, cb])

Execute the optional `cb` (if provided) one time on the next data payload from the `eventuate`, for which a truthy value is returned from the `filter` function. In addition, returns a `Promise` that resolves to the matched `eventuate` data payload.

The `filter` argument should be a function with signature `function (data)`. It will be passed all events produced by the `eventuate`, and it should return a falsey value or truthy value. Upon returning a truthy value, no more events will be provided, and the callbacks/promise will be resolved. 

## testing

`npm test [--dot | --spec] [--grep=pattern]`

Specifying `--dot` or `--spec` will change the output from the default TAP style. 
Specifying `--grep` will only run the test files that match the given pattern.

## coverage

`npm run coverage [--html]`

This will output a textual coverage report. Including `--html` will also open 
an HTML coverage report in the default browser.

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