{"id":22061680,"url":"https://github.com/floofies/queuestack","last_synced_at":"2025-03-23T17:27:51.692Z","repository":{"id":135350538,"uuid":"164351811","full_name":"Floofies/QueueStack","owner":"Floofies","description":"Queue \u0026 Stack classes for JavaScript. Taken from Differentia.js","archived":false,"fork":false,"pushed_at":"2024-04-03T21:34:25.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T13:25:12.899Z","etag":null,"topics":["class","graph-theory-algorithms","library","queue","stack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Floofies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-06T22:40:38.000Z","updated_at":"2024-04-03T21:34:54.000Z","dependencies_parsed_at":"2024-04-03T22:43:48.664Z","dependency_job_id":null,"html_url":"https://github.com/Floofies/QueueStack","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"bb60081bc4092e55762726c984fd3d14aac2e24a"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2FQueueStack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2FQueueStack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2FQueueStack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floofies%2FQueueStack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Floofies","download_url":"https://codeload.github.com/Floofies/QueueStack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245139169,"owners_count":20567117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["class","graph-theory-algorithms","library","queue","stack"],"created_at":"2024-11-30T18:13:58.398Z","updated_at":"2025-03-23T17:27:51.660Z","avatar_url":"https://github.com/Floofies.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QueueStack\nQueue \u0026 Stack classes.\n\n[![NPM](https://nodei.co/npm/queuestacklib.png)](https://nodei.co/npm/queuestacklib/)\n\n- [`Queue`](#queue)\n\t- [Instance Properties](#instance-properties)\n\t\t- [`size`](#queuesize)\n\t\t- [`limit`](#queuelimit)\n\t- [Prototype Methods](#prototype-methods)\n\t\t- [`@@iterator`](#queueprototypeiterator)\n\t\t- [`clear`](#queueprototypeclear)\n\t\t- [`item`](#queueprototypeitem)\n\t\t- [`add`](#queueprototypeadd)\n\t\t- [`remove`](#queueprototyperemove)\n\t\t- [`head`](#queueprototypehead)\n\t\t- [`end`](#queueprototypeend)\n- [`Stack`](#stack)\n\t- [Instance Properties](#instance-properties-1)\n\t\t- [`size`](#stacksize)\n\t\t- [`limit`](#stacklimit)\n\t- [Prototype Methods](#prototype-methods-1)\n\t\t- [`@@iterator`](#stackprototypeiterator)\n\t\t- [`clear`](#stackprototypeclear)\n\t\t- [`item`](#stackprototypeitem)\n\t\t- [`add`](#stackprototypeadd)\n\t\t- [`remove`](#stackprototyperemove)\n\t\t- [`head`](#stackprototypehead)\n\t\t- [`end`](#stackprototypeend)\n\nYou can import the constructors like so:\n\n```JavaScript\nconst queuestacklib = require(\"queuestacklib\");\nconst Queue = queuestacklib.Queue;\nconst Stack = queuestacklib.Stack;\n\n// Using ES6 Destructuring Assignment\nconst {Queue, Stack} = require(\"queuestacklib\");\n```\n\n# `Queue`\n\n*Constructor*\n\n```JavaScript\nnew Queue( [ iterable = null [, limit = Number.MAX_SAFE_INTEGER ]] );\n```\n\nA bounded Queue which inherits from a Doubly Linked List.\n\n## Constructor Parameters\n- **`iterable`** (*Optional*) Iterable\n\n  The values of the optional Iterable will be used to populate the new Queue.\n\n- **`limit`** (*Optional*) Number\n\n  A Number which specifies the maximum number of values allowed within the Queue.\n\n## Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Append \"6\" to the end of the Queue.\nqueue.add(6);\n\n// Removes \"1\" from the beginning of the Queue.\nvar one = queue.remove();\n\n// Logs 2, 3, 4, 5, 6\nfor (const num of queue) {\n\tconsole.log(num);\n}\n```\n\n---\n\n## Instance Properties\n\n### `Queue.size`\n\n*Number*\n```JavaScript\nQueue.size\n```\nA number representing the quantity of values within the Queue.\n\n### `Queue.limit`\n\n*Number*\n```JavaScript\nQueue.limit\n```\nA Number which specifies the maximum number of values allowed within the Queue.\n\n---\n\n## Prototype Methods\n\n### `Queue.prototype.@@iterator`\n\n*Iterator*\n```JavaScript\nQueue[Symbol.iterator]();\n```\nAn iterator which yields each value in the Queue.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Logs 1, 2, 3, 4, and 5.\nfor (const value of queue) console.log(value);\n```\n\n---\n\n### `Queue.prototype.clear`\n\n*Function*\n```JavaScript\nQueue.clear();\n```\nRemoves all elements from the Queue.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Queue becomes empty.\nQueue.clear();\n```\n\n---\n\n### `Queue.prototype.item`\n\n*Function*\n```JavaScript\nQueue.item( index );\n```\nReturns the vakue at the specified 0-indexed offset from the beginning of the Queue, or `null` if it was not found.\n\n#### Parameters\n- **`index`** Number\n\n  An offset from the beginning of the Queue, starting at zero, to look for a value at.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Returns the value at index 4, the last element in Queue, which contains \"5\".\nvar five = queue.item(4);\n```\n\n---\n\n### `Queue.prototype.add`\n\n*Function*\n```JavaScript\nQueue.add( element );\n```\nInserts a value at the end of the Queue.\n\n#### Parameters\n- **`element`** Any\n\n  A value to append the Queue with.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Inserts \"6\" at the end of the Queue.\nqueue.add(6);\n```\n\n---\n\n### `Queue.prototype.remove`\n\n*Function*\n```JavaScript\nQueue.remove();\n```\nRemoves and returns an value from the beginning of the Queue.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Returns \"1\" and removes it from the beginning of the Queue.\nvar one = queue.remove();\n```\n\n---\n\n### `Queue.prototype.head`\n\n*Function*\n```JavaScript\nQueue.head();\n```\nReturns the value at the beginning of the Queue, or `null` if the Queue is empty.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Returns \"1\".\nvar one = queue.head();\n```\n\n---\n\n### `Queue.prototype.end`\n\n*Function*\n```JavaScript\nQueue.end();\n```\nReturns the value at the end of the Queue, or `null` if the Queue is empty.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Queue is created using the contents of `arr`.\nvar queue = new Queue(arr);\n\n// Returns \"5\".\nvar five = queue.last();\n```\n\n---\n\n# `Stack`\n\n*Constructor*\n\n```JavaScript\nnew Stack( [ iterable = null [, limit = Number.MAX_SAFE_INTEGER ]] );\n```\n\nA bounded Stack which inherits from a Doubly Linked List.\n\n## Constructor Parameters\n- **`iterable`** (*Optional*) Iterable\n\n  The values of the optional Iterable will be used to populate the new Stack.\n\n- **`limit`** (*Optional*) Number\n\n  A Number which specifies the maximum number of values allowed within the Stack.\n\n## Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Append \"6\" to the end of the Stack.\nstack.add(6);\n\n// Removes \"6\" from the end of the Stack.\nvar six = stack.remove();\n\n// Logs 1, 2, 3, 4, 5\nfor (const num of stack) {\n\tconsole.log(num);\n}\n```\n\n---\n\n## Instance Properties\n\n### `Stack.size`\n\n*Number*\n```JavaScript\nStack.size\n```\nA number representing the quantity of values within the Stack.\n\n### `Stack.limit`\n\n*Number*\n```JavaScript\nStack.limit\n```\nA Number which specifies the maximum number of values allowed within the Stack.\n\n---\n\n## Prototype Methods\n\n### `Stack.prototype.@@iterator`\n\n*Iterator*\n```JavaScript\nStack[Symbol.iterator]();\n```\nAn iterator which yields each value in the Stack.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Logs 1, 2, 3, 4, and 5.\nfor (const value of stack) console.log(value);\n```\n\n---\n\n### `Stack.prototype.clear`\n\n*Function*\n```JavaScript\nStack.clear();\n```\nRemoves all elements from the Stack.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Stack becomes empty.\nStack.clear();\n```\n\n---\n\n### `Stack.prototype.item`\n\n*Function*\n```JavaScript\nStack.item( index );\n```\nReturns the vakue at the specified 0-indexed offset from the beginning of the Stack, or `null` if it was not found.\n\n#### Parameters\n- **`index`** Number\n\n  An offset from the beginning of the Stack, starting at zero, to look for a value at.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Returns the value at index 4, the last element in Stack, which contains \"5\".\nvar five = stack.item(4);\n```\n\n---\n\n### `Stack.prototype.add`\n\n*Function*\n```JavaScript\nStack.add( element );\n```\nInserts a value at the end of the Stack.\n\n#### Parameters\n- **`element`** Any\n\n  A value to append the Stack with.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Inserts \"6\" at the end of the Stack.\nstack.add(6);\n```\n\n---\n\n### `Stack.prototype.remove`\n\n*Function*\n```JavaScript\nStack.remove();\n```\nRemoves and returns an value from the end of the Stack.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Returns \"5\" and removes it from the end of the Stack.\nvar one = stack.remove();\n```\n\n---\n\n### `Stack.prototype.head`\n\n*Function*\n```JavaScript\nStack.head();\n```\nReturns the value at the beginning of the Stack, or `null` if the Stack is empty.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Returns \"1\".\nvar one = stack.head();\n```\n\n---\n\n### `Stack.prototype.end`\n\n*Function*\n```JavaScript\nStack.end();\n```\nReturns the value at the end of the Stack, or `null` if the Stack is empty.\n\n#### Examples\nExample 1: Basic Usage:\n\n```JavaScript\n// Array of arbitrary numbers.\nvar arr = [1,2,3,4,5];\n\n// New Stack is created using the contents of `arr`.\nvar stack = new Stack(arr);\n\n// Returns \"5\".\nvar five = stack.last();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloofies%2Fqueuestack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloofies%2Fqueuestack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloofies%2Fqueuestack/lists"}