npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

israeli-queue

v1.1.4

Published

in-memory israeli-queue influenced by: http://www.math.tau.ac.il/~uriy/Papers/IQ-with-Priorities.pdf

Downloads

20

Readme

IQ.js :: The Israeli Queue

a priority queue with the following order rule: After completion of a visit at a queue, the next queue to be served is the one where its first customer in line has been waiting in the system for the longest time. That is, the criterion for selecting the next queue to visit and serve is an age-based one. This type of service discipline was termed the Israeli Queue, illustrated vividly as follows: A new arriving customer may find in the system up to N groups, where each group is headed by a “leader.” This new arrival looks for a “friend” among all group leaders in the system. If he (“he” stands for “she” as well) finds such a leader, he joins him and his group and waits with all the group’s members to be served in a batch mode. That is, the whole group is served at one service period, while the service duration is not affected by the size of the batch. For example, this queue discipline represents a physical waiting line for buying tickets to a movie, theater, or rock-concert performance. A new arrival that finds a friend already standing in line joins him and his group. When the “leader” reaches the cashier, he buys tickets for the entire group. It is assumed that the buying process is (almost) not affected by the number of tickets purchased. http://www.math.tau.ac.il/~uriy/Papers/IQ-with-Priorities.pdf

Usage

To install: npm install israeli-queue

require

const IQ = require('israeli-queue');

let q1 = new IQ();
q1.dequeue(); // []
q1.enqueue({o:"a"}); // [{"o":"a"}]
q1.enqueue({o:"c"}); // [{"o":"a"},{"o":"c"}]
q1.enqueue({o:"b"}, {o:"a"}); // [{"o":"a"},{"o":"b"},{"o":"c"}]

q1.peek(); // { o: 'a' }
q1.length(); // 3

API

constructor()

The constructor will create an in-memory Israeli queue data structure

dequeue()

Removes and returns the element of the priority queue which is first in line. Simply returns undefined if the priority queue is empty.

enqueue(element, friend_element)

Inserts each given argument into the appropriate place in the priority queue. Returns the index of the inserted item.

length()

Integer property which reflects the number of elements in the priority queue.

peek()

Returns the element of the priority queue which is first in line without removing it. Simply returns null if the priority queue is empty.

toString()

Returns the .toString() of an Array containing the priority queue's elements in sorted order.

Author

Dror Arazi ([email protected])

License

MIT