Skip to content

Instantly share code, notes, and snippets.

@smendoza787
Created March 21, 2020 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smendoza787/fdc26aa6e2de0f529c83fb66aee7a8c0 to your computer and use it in GitHub Desktop.
Save smendoza787/fdc26aa6e2de0f529c83fb66aee7a8c0 to your computer and use it in GitHub Desktop.
Huey the Queue
class HueyTheQueue {
constructor() {
this.q = []
}
enQ(...msgs) {
return this.q.push(...msgs)
}
deQ() {
if (this.q.length) {
return this.q.shift()
}
throw Error('Huey has no news for you.')
}
peek() {
return this.q[0]
}
length() {
return this.q.length
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment