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

@dogmalang/queue

v0.2.0

Published

A queue implementation.

Downloads

1

Readme

@dogmalang/queue

NPM version Total downloads

A queue implementation.

Developed in Dogma, compiled to JavaScript.

Engineered in Valencia, Spain, EU by Justo Labs.

Use

The package must be imported as follows:

////////////////
// JavaScript //
////////////////
import Queue from "@dogmalang/queue";

#########
# Dogma #
#########
use "@dogmalang/queue" as Queue

Constructor

////////////////
// JavaScript //
////////////////
constructor()
constructor(items:array, opts?:{max:number})
constructor(opts:{max:number})

#########
# Dogma #
#########
type Queue()
type Queue(items:list, opts?:{max:num})
type Queue(opts:{max:num})
  • items, initial items.
  • opts, the options: max, maximum number of items.

Examples:

////////////////
// JavaScript //
////////////////
q = new Queue()
q = new Queue([1, 2, 3, 4])
q = new Queue({max: 123})

#########
# Dogma #
#########
q = Queue()
q = Queue([1, 2, 3, 4])
q = Queue({max=123})

enqueue() and append()

Add a new item at the end of the queue:

////////////////
// JavaScript //
////////////////
append(item) : Queue
enqueue(item) : Queue

#########
# Dogma #
#########
@alias("append")
fn Queue.enqueue(item) -> self

The method returns the queue for chaining other appends. If the queue has max and this reached, an error is raised.

Example:

q.enqueue("one").enqueue("two").enqueue("three")

unshift()

Add an item at the beginning of the queue:

////////////////
// JavaScript //
////////////////
unshift(item) : Queue

#########
# Dogma #
#########
fn Queue.unshift(item) -> self

shift() and dequeue()

Remove the first/front item and returning it:

////////////////
// JavaScript //
////////////////
shift() : any
dequeue() : any

#########
# Dogma #
#########
@alias("shift")
fn Queue.dequeue() : any

If the queue is empty, an error is raised.

Example:

i = q.shift()

len

Return the current length:

////////////////
// JavaScript //
////////////////
len : number

#########
# Dogma #
#########
fn Queue.len : num

Example:

size = q.len

max

Return the maximum size if set:

////////////////
// JavaScript //
////////////////
max : number

#########
# Dogma #
#########
@prop
fn Queue.max() : num

Example:

max = q.max

isEmpty()

Check whether the queue is empty:

////////////////
// JavaScript //
////////////////
isEmpty() : boolean

#########
# Dogma #
#########
fn Queue.isEmpty() : bool

Example:

q.isEmpty()

isFull()

Check whether the queue is full:

////////////////
// JavaScript //
////////////////
isFull() : boolean

#########
# Dogma #
#########
fn Queue.isFull() : bool

first

Return the first/front item without removing it:

////////////////
// JavaScript //
////////////////
first : any

#########
# Dogma #
#########
@prop
fn Queue.first() : any

Example:

q.append("one").append("two").first

last

Return the last/back item without removing it:

////////////////
// JavaScript //
////////////////
last : any

#########
# Dogma #
#########
@prop
fn Queue.last() : any

Example:

q.append("one").append("two").last

get()

Return the item in a given position:

////////////////
// JavaScript //
////////////////
get(pos:number) : any

#########
# Dogma #
#########
fn Queue.get(pos:num) : any

list()

Return a list with the items:

////////////////
// JavaScript //
////////////////
list() : any[]

#########
# Dogma #
#########
fn Queue.list() : list

Example:

q.list()