# ssfq

> Simple Straight Forward Queue

Latest version **0.0.5** (published 2017-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install ssfq
pnpm add ssfq
yarn add ssfq
bun add ssfq
```

## 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.5 |
| Published | 2017-04-17 |
| First published | 2017-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Johan Olsson |
| Maintainers | johano |

## Links

- npm: https://www.npmjs.com/package/ssfq
- Repository: https://github.com/johan-olsson/Queue
- Homepage: https://github.com/johan-olsson/Queue#readme
- Issues: https://github.com/johan-olsson/Queue/issues
- npm.io page: https://npm.io/package/ssfq

## Recent versions

- 0.0.5 (latest) — 2017-04-17
- 0.0.4 — 2017-04-17
- 0.0.3 — 2017-04-12
- 0.0.2 — 2017-02-01
- 0.0.1 — 2017-01-31

## README

# Queue [![Build Status](https://travis-ci.org/johan-olsson/Queue.svg?branch=master)](https://travis-ci.org/johan-olsson/Queue)

# Getting Started

```javascript
const Queue = require('ssfq')
const myQueue = new Queue(workerCount)

myQueue.push((next) => {
  /* do something */
  next()
})


```

```javascript

class YourClass extends Queue {

  find(query) {
    this.push((next) => {
      this._somedb.find(query, (docs) => {
        this.result = docs
      })
    })

    return this
  }

  each(fn) {
    this.push((next) => {
      this.result.forEach(fn)
    })

    return this
  }
}


var db = YourClass()
db.find({
    foo: 'bar'
  })
  .each((doc) => {
    console.log(doc)
  })
```
# Methods

## push(task, [options])

push task to queue
```javascript

queue.push((next) => {
  /* do something */
  next()
}, {
  priority: 2
})
```

### options

* priority _number, highest priority get executed first._ **default:** `0`

## resume()
unpause queue and continue processing tasks
```javascript

queue.resume()
```

## pause()
pause queue (after processing current task)
```javascript

queue.pause()
```

# Events
* `task` a new task is beeing processed
* `locked` queue is busy processing tasks
* `unlocked` queue is idle
* `paused` queue was paused and won't process any task until resumed
* `resumed` queue will continue processing tasks

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