3.15.108 • Published 11 months ago

@devtea2026/asperiores-repellat-explicabo-animi v3.15.108

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@devtea2026/asperiores-repellat-explicabo-animi

ci npm version

Fast, in memory work queue.

Benchmarks (1 million tasks):

  • setImmediate: 812ms
  • @devtea2026/asperiores-repellat-explicabo-animi: 854ms
  • async.queue: 1298ms
  • neoAsync.queue: 1249ms

Obtained on node 12.16.1, on a dedicated server.

If you need zero-overhead series function call, check out fastseries. For zero-overhead parallel function call, check out fastparallel.

js-standard-style

  • Installation
  • Usage
  • API
  • Licence & copyright

Install

npm i @devtea2026/asperiores-repellat-explicabo-animi --save

Usage (callback API)

'use strict'

const queue = require('@devtea2026/asperiores-repellat-explicabo-animi')(worker, 1)

queue.push(42, function (err, result) {
  if (err) { throw err }
  console.log('the result is', result)
})

function worker (arg, cb) {
  cb(null, arg * 2)
}

Usage (promise API)

const queue = require('@devtea2026/asperiores-repellat-explicabo-animi').promise(worker, 1)

async function worker (arg) {
  return arg * 2
}

async function run () {
  const result = await queue.push(42)
  console.log('the result is', result)
}

run()

Setting "this"

'use strict'

const that = { hello: 'world' }
const queue = require('@devtea2026/asperiores-repellat-explicabo-animi')(that, worker, 1)

queue.push(42, function (err, result) {
  if (err) { throw err }
  console.log(this)
  console.log('the result is', result)
})

function worker (arg, cb) {
  console.log(this)
  cb(null, arg * 2)
}

Using with TypeScript (callback API)

'use strict'

import * as @devtea2026/asperiores-repellat-explicabo-animi from "@devtea2026/asperiores-repellat-explicabo-animi";
import type { queue, done } from "@devtea2026/asperiores-repellat-explicabo-animi";

type Task = {
  id: number
}

const q: queue<Task> = @devtea2026/asperiores-repellat-explicabo-animi(worker, 1)

q.push({ id: 42})

function worker (arg: Task, cb: done) {
  console.log(arg.id)
  cb(null)
}

Using with TypeScript (promise API)

'use strict'

import * as @devtea2026/asperiores-repellat-explicabo-animi from "@devtea2026/asperiores-repellat-explicabo-animi";
import type { queueAsPromised } from "@devtea2026/asperiores-repellat-explicabo-animi";

type Task = {
  id: number
}

const q: queueAsPromised<Task> = @devtea2026/asperiores-repellat-explicabo-animi.promise(asyncWorker, 1)

q.push({ id: 42}).catch((err) => console.error(err))

async function asyncWorker (arg: Task): Promise<void> {
  // No need for a try-catch block, @devtea2026/asperiores-repellat-explicabo-animi handles errors automatically
  console.log(arg.id)
}

API

  • @devtea2026/asperiores-repellat-explicabo-animiueue()
  • queue#push()
  • queue#unshift()
  • queue#pause()
  • queue#resume()
  • queue#idle()
  • queue#length()
  • queue#getQueue()
  • queue#kill()
  • queue#killAndDrain()
  • queue#error()
  • queue#concurrency
  • queue#drain
  • queue#empty
  • queue#saturated
  • @devtea2026/asperiores-repellat-explicabo-animiueue.promise()

@devtea2026/asperiores-repellat-explicabo-animiueue(that, worker, concurrency)

Creates a new queue.

Arguments:

  • that, optional context of the worker function.
  • worker, worker function, it would be called with that as this, if that is specified.
  • concurrency, number of concurrent tasks that could be executed in parallel.

queue.push(task, done)

Add a task at the end of the queue. done(err, result) will be called when the task was processed.


queue.unshift(task, done)

Add a task at the beginning of the queue. done(err, result) will be called when the task was processed.


queue.pause()

Pause the processing of tasks. Currently worked tasks are not stopped.


queue.resume()

Resume the processing of tasks.


queue.idle()

Returns false if there are tasks being processed or waiting to be processed. true otherwise.


queue.length()

Returns the number of tasks waiting to be processed (in the queue).


queue.getQueue()

Returns all the tasks be processed (in the queue). Returns empty array when there are no tasks


queue.kill()

Removes all tasks waiting to be processed, and reset drain to an empty function.


queue.killAndDrain()

Same than kill but the drain function will be called before reset to empty.


queue.error(handler)

Set a global error handler. handler(err, task) will be called each time a task is completed, err will be not null if the task has thrown an error.


queue.concurrency

Property that returns the number of concurrent tasks that could be executed in parallel. It can be altered at runtime.


queue.drain

Function that will be called when the last item from the queue has been processed by a worker. It can be altered at runtime.


queue.empty

Function that will be called when the last item from the queue has been assigned to a worker. It can be altered at runtime.


queue.saturated

Function that will be called when the queue hits the concurrency limit. It can be altered at runtime.


@devtea2026/asperiores-repellat-explicabo-animiueue.promise(that, worker(arg), concurrency)

Creates a new queue with Promise apis. It also offers all the methods and properties of the object returned by @devtea2026/asperiores-repellat-explicabo-animiueue with the modified push and unshift methods.

Node v10+ is required to use the promisified version.

Arguments:

  • that, optional context of the worker function.
  • worker, worker function, it would be called with that as this, if that is specified. It MUST return a Promise.
  • concurrency, number of concurrent tasks that could be executed in parallel.

queue.push(task) => Promise

Add a task at the end of the queue. The returned Promise will be fulfilled (rejected) when the task is completed successfully (unsuccessfully).

This promise could be ignored as it will not lead to a 'unhandledRejection'.

queue.unshift(task) => Promise

Add a task at the beginning of the queue. The returned Promise will be fulfilled (rejected) when the task is completed successfully (unsuccessfully).

This promise could be ignored as it will not lead to a 'unhandledRejection'.

queue.drained() => Promise

Wait for the queue to be drained. The returned Promise will be resolved when all tasks in the queue have been processed by a worker.

This promise could be ignored as it will not lead to a 'unhandledRejection'.

License

ISC

Symbol.toStringTagairbnbwatchingtrimEndefficientperformantRFC-6455syntaxerrorcensorswfjsonpostcss-plugincommanderexecECMAScript 2016byteOffsetregular expressionrmdirprunebrowserlisteast-asian-widthURLSearchParamsAsyncIteratorreact-hooksmatchrm -rfsymbolsfunctionalpathECMAScript 2020hasrdsflattenawesomesaucelinkemojiiecryptowebcompilerwafjavascriptdefaultworkerpretty-0datastructureconfigscheme-validationWebSocketsoperating-systembindratelimitES2020streammergecollectionvalidationlruurlES2022nopetaskhttpsetPrototypeOftoStringTagmkdirpreducerisimmutablehasOwnPropertypostcssexecutableconcatObject.valuesbufferreduxes2018arktypeString.prototype.trimbannerserializeES2016statelessgenericsinternal slotwalkES2023envshebangflagcallboundbootstrap lessonceWebSocket.envReactiveExtensionsbatchnodetypesafeECMAScript 2023full-widthcomputed-typesJSONURLsidephoneflatMapECMAScript 2018openerkeydirectorymomentObject.entriesrangeerroruuidvisualECMAScript 2022persistentdescriptorcolumnsdataviewmake dirlesscsscodesjsonpathcss nestingidleintrinsicirqESnextcolourprogressthrottleauthenticationprotobufbundlingsinatrawriteopenstsliblook-upsortedworkflowprototypetypessharedECMAScript 2017es8statecss lessparentconfigurablexhrtraverseobjecttakeinspectfoldergettercacheStreamselbrobustreplayHyBiagentfindLastpackage managerfpserrorcolorhardlinksmrus3ES2017trimLeftemitMicrosoftcallbackcorewindowsimmerstyled-componentsdatechineseutilitiesinvariantUint8ClampedArrayarraysBigInt64Arrayspeedes5io-tsbuffersawsexitqueueoptionloggersqskeyszeroES2019dayjsendpointvaluessigtermes-shim APInodejsstreamsfastdefinePropertyrmsymlinksTypedArrayregexeslintfastcopyarraynegative zerojasminecreateRegExp.prototype.flagspreprocessorformattingrm -frhookformcjksignalerror-handlingstylesheetasyncvalidatextermArrayBuffer.prototype.sliceeventDispatchersameValueZeroSymbolextensionchromiumexpresstaperegularentriesseswarningInt32Arrayrestreact-testing-libraryaccessorvariablesfigletrandomstartdescriptorstoArraymapreadablestreamclass-validatorproxyschemelibphonenumberuninstalljsdomvestUnderscorecharacteremrReflect.getPrototypeOfqshelpersdeterministicCSSfindupavaequalitysomeclassnamesyntaxkarmaObject.assignlanguageRxJSlimitedECMAScript 2019stringifierArray.prototype.containseverytrimtimelintamazonquoteArray.prototype.findLastreactassigncopyinstallrequest$.extendqueueMicrotaskjapanesecollection.es6symbolhttpspolyfillttylesseslint-plugindeepclonevaluespinnerES2018jsdiffencryptionminimalomittyped arrayextendworkspace:*idpipesequencehasOwnfluxstringifysigintapivpccliflagstypedarrayscloudformationsymlinktsArray.prototype.flatMapsignalsfunctionspasswordecmascriptes2015packages_.extendfseventsparentsliveincloudsearchwhichoutputcloneinputdependency managerless mixinsFloat64Arraylastappartmakeimportfast-deep-cloneless compilerexpressionterminalpositivebundlerdescriptionautoscalingjQuery[[Prototype]]pyyamlpatchfindinstallerform-validationES3byteLengthcloudfrontstylesObjectECMAScript 2021modulesiteratenegativeglobalviewconcatMapfast-cloneinferencedataeslintplugintypeofreadablexdg-openconsumelookRegExp#flagsmatchesECMAScript 2015argparsecmdstructuredClonemulti-packagedeleteruntimegdprconcurrencyserializerbreakaccessibilitydefineCSSStyleDeclaration
3.15.108

11 months ago

3.15.107

11 months ago

3.15.106

11 months ago

3.15.105

11 months ago

3.15.104

11 months ago

3.15.103

11 months ago

3.15.102

11 months ago

3.15.101

11 months ago

3.11.64

1 year ago

3.13.88

11 months ago

3.11.63

1 year ago

3.13.89

11 months ago

3.11.66

1 year ago

3.11.65

1 year ago

3.11.68

1 year ago

3.11.67

1 year ago

3.11.69

12 months ago

3.11.60

1 year ago

3.11.62

1 year ago

1.6.46

1 year ago

3.11.61

1 year ago

1.6.45

1 year ago

1.6.47

1 year ago

3.13.98

11 months ago

3.11.75

12 months ago

3.11.74

12 months ago

3.11.77

12 months ago

3.11.76

12 months ago

3.11.79

12 months ago

3.11.78

12 months ago

3.13.90

11 months ago

3.13.91

11 months ago

3.13.92

11 months ago

3.13.93

11 months ago

3.13.94

11 months ago

3.11.71

12 months ago

1.4.31

1 year ago

3.13.95

11 months ago

3.11.70

12 months ago

3.13.96

11 months ago

3.11.73

12 months ago

1.4.33

1 year ago

3.13.97

11 months ago

3.11.72

12 months ago

1.4.32

1 year ago

1.4.35

1 year ago

1.4.34

1 year ago

1.4.37

1 year ago

1.4.36

1 year ago

2.11.60

1 year ago

1.3.31

1 year ago

1.3.30

1 year ago

3.15.100

11 months ago

1.8.54

1 year ago

1.8.55

1 year ago

3.15.99

11 months ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

3.14.99

11 months ago

1.7.50

1 year ago

1.7.51

1 year ago

1.7.52

1 year ago

1.7.53

1 year ago

1.7.54

1 year ago

3.14.98

11 months ago

1.5.38

1 year ago

1.5.37

1 year ago

1.5.39

1 year ago

3.12.87

12 months ago

3.12.86

12 months ago

3.12.88

11 months ago

1.9.55

1 year ago

1.5.41

1 year ago

1.5.40

1 year ago

1.5.43

1 year ago

2.11.58

1 year ago

1.5.42

1 year ago

2.11.59

1 year ago

1.5.45

1 year ago

1.5.44

1 year ago

2.9.56

1 year ago

2.9.57

1 year ago

2.9.55

1 year ago

3.11.86

12 months ago

3.11.85

12 months ago

3.11.80

12 months ago

3.11.82

12 months ago

3.11.81

12 months ago

2.10.57

1 year ago

3.11.84

12 months ago

2.10.58

1 year ago

3.11.83

12 months ago

1.2.23

1 year ago

1.2.24

1 year ago

1.2.22

1 year ago

1.2.27

1 year ago

1.2.28

1 year ago

1.2.25

1 year ago

1.2.26

1 year ago

1.2.29

1 year ago

1.2.30

1 year ago

1.7.47

1 year ago

1.7.48

1 year ago

1.7.49

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago