6.1.8 • Published 3 months ago

oj-queue v6.1.8

Weekly downloads
1
License
MIT
Repository
github
Last release
3 months ago

promise based queue

uses oj-eventaggregator and oj-promise-utils

Usage

import { Queue, QueueItem, QueueFn } from "oj-queue"

const fetchHandler: QueueFn<{ value: number }, string> = (url, resolve, reject) =>
    fetch(url)
        .then(x => x.json())
        .then(x => resolve({ value: x.data }))
        .catch(reject)

const q = new Queue({ concurrent: 2 })

q.on("error", item => console.error(item.error))

const item0 = new QueueItem(fetchHandler, "https://some.api.com?data=0")
const item1 = new QueueItem(fetchHandler, "https://some.api.com?data=1", -1) // add priority, low value = high priority, 0 is default

q.add(item0, item1)

item0.promise
    .then(x => console.log(x.value))
    .catch(err => console.error(err))
6.1.8

3 months ago

6.1.6

1 year ago

6.1.5

1 year ago

6.1.7

1 year ago

6.1.0

2 years ago

6.0.0

2 years ago

6.1.2

2 years ago

6.1.1

2 years ago

6.1.4

2 years ago

6.1.3

2 years ago

2.0.3

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

2.0.0

3 years ago

1.0.0

4 years ago