0.1.5 • Published 4 years ago

loopque v0.1.5

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

LoopQueue

API

LoopQueue(loops, capacity, hash)

  • loops: when greater than 0, limit the maximum loop times; defaults to 0
  • capacity: when greater than 0, limit the maximum queue length; defaults to 0
  • hash: function to generate id from item; defaults to item => item

length

Property to retrieve current length of the queue.

push(item)

  • item: any value or object except undefined

Add item to the end of queue.

values()

Return item iterator, same as Symbol.iterator

get(id)

  • id: by default, id is the same primitive value or object reference; when queue is constructed with a hash function, id is whatever that function returns

Retrieve item in the queue via the given hash id, just like Map.

remove(id): boolean

  • id: by default, id is the same primitive value or object reference; when queue is constructed with a hash function, id is whatever that function returns

Remove an item by the given hash id.

clear()

Clear the entire queue.

shift()

Remove the first item in the queue and return it.

next(remove: (item: any) => boolean | boolean)

  • remove: a predicate callback or boolean to determine whether to remove next item

Loop through the queue and return the next item. If loops is set, this method checks cyclic number and removes the item when reached.

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago