# gate-executor

> A work queue that can be gated, stopping to wait for sub-queues to complete.

Latest version **3.3.1** (published 2026-01-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install gate-executor
pnpm add gate-executor
yarn add gate-executor
bun add gate-executor
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.3.1 |
| Published | 2026-01-19 |
| First published | 2014-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 41.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Richard Rodger |
| Maintainers | rjrodger, mihaidma |
| Keywords | seneca, gate, executor |

## Links

- npm: https://www.npmjs.com/package/gate-executor
- Repository: https://github.com/senecajs/gate-executor
- Issues: https://github.com/senecajs/gate-executor/issues
- npm.io page: https://npm.io/package/gate-executor

## Recent versions

- 3.3.1 (latest) — 2026-01-19
- 3.2.1 — 2025-12-11
- 3.1.1 — 2021-10-15
- 3.0.0 — 2020-08-24
- 2.1.0 — 2019-10-02
- 2.0.1 — 2019-06-27
- 2.0.0 — 2019-06-27
- 1.1.1 — 2016-10-18
- 1.1.0 — 2016-09-27
- 1.0.0 — 2016-08-10
- 0.4.0 — 2016-03-03
- 0.3.2 — 2016-01-24
- 0.3.1 — 2016-01-24
- 0.3.0 — 2016-01-23
- 0.2.3 — 2015-07-09
- … 4 more at https://npm.io/package/gate-executor/versions

## README

# gate-executor

[![npm version][npm-badge]][npm-url]
[![Build Status][travis-badge]][travis-url]
[![Coverage Status][coveralls-badge]][coveralls-url]
[![Dependency Status][david-badge]][david-url]
[![Gitter chat][gitter-badge]][gitter-url]

#### A work queue that can be gated, stopping to wait for sub-queues to complete.

[Annotated Source](http://senecajs.github.io/gate-executor/gate-executor.html)

A work execution queue that provides gating. Work items submitted to
the queue are called in order, and execute concurrently. However, if
the queue is *gated*, then a sub-queue is created, and work items
added to the sub-queue must complete first.

Gating operates to any depth, allowing you to form a tree-structured
queue that must complete breadth-first.

The queue also handles timeouts, so that failing work items do not
block processing. Timeouts use a shared `setInterval`, so are nice and
efficient.

Used by the [Seneca](http://senecajs.org/) microservice framework to
implement plugin initialisation.

# Usage


```js
var GateExecutor = require('gate-executor')

var ge = GateExecutor()

ge.add({
  fn: function first (done) {
    console.log('first')
    done()
  }
})

// create a gate
var subge = ge.gate()

ge.add({
  fn: function second (done) {
    console.log('second')
    done()
  }
})

// this needs to complete before 'second' can run
subge.add({
  fn: function second (done) {
    console.log('third')
    done()
  }
})

ge.start(function () {
  console.log('done')
  done()
})

// prints:
//   first
//   third
//   second
//   done
```

For detailed information, and API descriptions, see the
[Annotated Source](http://senecajs.github.io/gate-executor/doc/gate-executor.html)

# Support

If you're using this module, feel free to contact me on twitter if you
have any questions! :) [@rjrodger](http://twitter.com/rjrodger)

# Testing

```js
npm test
```

[npm-badge]: https://badge.fury.io/js/gate-executor.svg
[npm-url]: https://badge.fury.io/js/gate-executor
[travis-badge]: https://api.travis-ci.org/senecajs/gate-executor.svg
[travis-url]: https://travis-ci.org/senecajs/gate-executor
[coveralls-badge]:https://coveralls.io/repos/senecajs/gate-executor/badge.svg?branch=master&service=github
[coveralls-url]: https://coveralls.io/github/senecajs/gate-executor?branch=master
[david-badge]: https://david-dm.org/senecajs/gate-executor.svg
[david-url]: https://david-dm.org/senecajs/gate-executor
[gitter-badge]: https://badges.gitter.im/senecajs/seneca.svg
[gitter-url]: https://gitter.im/senecajs/seneca

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