Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
75
node_modules/yocto-queue/index.d.ts
generated
vendored
Normal file
75
node_modules/yocto-queue/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
export default class Queue<ValueType> implements Iterable<ValueType> {
|
||||
/**
|
||||
The size of the queue.
|
||||
*/
|
||||
readonly size: number;
|
||||
|
||||
/**
|
||||
Tiny queue data structure.
|
||||
|
||||
The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop, or use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
|
||||
|
||||
@example
|
||||
```
|
||||
import Queue from 'yocto-queue';
|
||||
|
||||
const queue = new Queue();
|
||||
|
||||
queue.enqueue('🦄');
|
||||
queue.enqueue('🌈');
|
||||
|
||||
console.log(queue.size);
|
||||
//=> 2
|
||||
|
||||
console.log(...queue);
|
||||
//=> '🦄 🌈'
|
||||
|
||||
console.log(queue.dequeue());
|
||||
//=> '🦄'
|
||||
|
||||
console.log(queue.dequeue());
|
||||
//=> '🌈'
|
||||
```
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop. Using the iterator will not remove the items from the queue. If you want that, use `drain()` instead.
|
||||
|
||||
You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<ValueType>;
|
||||
|
||||
/**
|
||||
Returns an iterator that dequeues items as you consume it.
|
||||
|
||||
This allows you to empty the queue while processing its items.
|
||||
|
||||
If you want to not remove items as you consume it, use the `Queue` object as an iterator.
|
||||
*/
|
||||
drain(): IterableIterator<ValueType>;
|
||||
|
||||
/**
|
||||
Add a value to the queue.
|
||||
*/
|
||||
enqueue(value: ValueType): void;
|
||||
|
||||
/**
|
||||
Remove the next value in the queue.
|
||||
|
||||
@returns The removed value or `undefined` if the queue is empty.
|
||||
*/
|
||||
dequeue(): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Get the next value in the queue without removing it.
|
||||
|
||||
@returns The value or `undefined` if the queue is empty.
|
||||
*/
|
||||
peek(): ValueType | undefined;
|
||||
|
||||
/**
|
||||
Clear the queue.
|
||||
*/
|
||||
clear(): void;
|
||||
}
|
84
node_modules/yocto-queue/index.js
generated
vendored
Normal file
84
node_modules/yocto-queue/index.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
How it works:
|
||||
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
||||
*/
|
||||
|
||||
class Node {
|
||||
value;
|
||||
next;
|
||||
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
export default class Queue {
|
||||
#head;
|
||||
#tail;
|
||||
#size;
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
enqueue(value) {
|
||||
const node = new Node(value);
|
||||
|
||||
if (this.#head) {
|
||||
this.#tail.next = node;
|
||||
this.#tail = node;
|
||||
} else {
|
||||
this.#head = node;
|
||||
this.#tail = node;
|
||||
}
|
||||
|
||||
this.#size++;
|
||||
}
|
||||
|
||||
dequeue() {
|
||||
const current = this.#head;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#head = this.#head.next;
|
||||
this.#size--;
|
||||
return current.value;
|
||||
}
|
||||
|
||||
peek() {
|
||||
if (!this.#head) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.#head.value;
|
||||
|
||||
// TODO: Node.js 18.
|
||||
// return this.#head?.value;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#head = undefined;
|
||||
this.#tail = undefined;
|
||||
this.#size = 0;
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.#size;
|
||||
}
|
||||
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.#head;
|
||||
|
||||
while (current) {
|
||||
yield current.value;
|
||||
current = current.next;
|
||||
}
|
||||
}
|
||||
|
||||
* drain() {
|
||||
while (this.#head) {
|
||||
yield this.dequeue();
|
||||
}
|
||||
}
|
||||
}
|
9
node_modules/yocto-queue/license
generated
vendored
Normal file
9
node_modules/yocto-queue/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
48
node_modules/yocto-queue/package.json
generated
vendored
Normal file
48
node_modules/yocto-queue/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "yocto-queue",
|
||||
"version": "1.2.1",
|
||||
"description": "Tiny queue data structure",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/yocto-queue",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"types": "./index.d.ts",
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=12.20"
|
||||
},
|
||||
"scripts": {
|
||||
"//test": "xo && ava && tsd",
|
||||
"test": "ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"queue",
|
||||
"data",
|
||||
"structure",
|
||||
"algorithm",
|
||||
"queues",
|
||||
"queuing",
|
||||
"list",
|
||||
"array",
|
||||
"linkedlist",
|
||||
"fifo",
|
||||
"enqueue",
|
||||
"dequeue",
|
||||
"data-structure"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.17.0",
|
||||
"xo": "^0.44.0"
|
||||
}
|
||||
}
|
80
node_modules/yocto-queue/readme.md
generated
vendored
Normal file
80
node_modules/yocto-queue/readme.md
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# yocto-queue [](https://bundlephobia.com/result?p=yocto-queue)
|
||||
|
||||
> Tiny queue data structure
|
||||
|
||||
You should use this package instead of an array if you do a lot of `Array#push()` and `Array#shift()` on large arrays, since `Array#shift()` has [linear time complexity](https://medium.com/@ariel.salem1989/an-easy-to-use-guide-to-big-o-time-complexity-5dcf4be8a444#:~:text=O(N)%E2%80%94Linear%20Time) *O(n)* while `Queue#dequeue()` has [constant time complexity](https://medium.com/@ariel.salem1989/an-easy-to-use-guide-to-big-o-time-complexity-5dcf4be8a444#:~:text=O(1)%20%E2%80%94%20Constant%20Time) *O(1)*. That makes a huge difference for large arrays.
|
||||
|
||||
> A [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) is an ordered list of elements where an element is inserted at the end of the queue and is removed from the front of the queue. A queue works based on the first-in, first-out ([FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics))) principle.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install yocto-queue
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import Queue from 'yocto-queue';
|
||||
|
||||
const queue = new Queue();
|
||||
|
||||
queue.enqueue('🦄');
|
||||
queue.enqueue('🌈');
|
||||
|
||||
console.log(queue.size);
|
||||
//=> 2
|
||||
|
||||
console.log(...queue);
|
||||
//=> '🦄 🌈'
|
||||
|
||||
console.log(queue.dequeue());
|
||||
//=> '🦄'
|
||||
|
||||
console.log(queue.dequeue());
|
||||
//=> '🌈'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `queue = new Queue()`
|
||||
|
||||
The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop. Using the iterator will not remove the items from the queue. If you want that, use [`drain()`](#drain) instead.
|
||||
|
||||
You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
|
||||
|
||||
#### `.enqueue(value)`
|
||||
|
||||
Add a value to the queue.
|
||||
|
||||
#### `.dequeue()`
|
||||
|
||||
Remove the next value in the queue.
|
||||
|
||||
Returns the removed value or `undefined` if the queue is empty.
|
||||
|
||||
#### `.peek()`
|
||||
|
||||
Get the next value in the queue without removing it.
|
||||
|
||||
Returns the value or `undefined` if the queue is empty.
|
||||
|
||||
#### `.drain()`
|
||||
|
||||
Returns an iterator that dequeues items as you consume it.
|
||||
|
||||
This allows you to empty the queue while processing its items.
|
||||
|
||||
If you want to not remove items as you consume it, use the `Queue` object as an iterator.
|
||||
|
||||
#### `.clear()`
|
||||
|
||||
Clear the queue.
|
||||
|
||||
#### `.size`
|
||||
|
||||
The size of the queue.
|
||||
|
||||
## Related
|
||||
|
||||
- [quick-lru](https://github.com/sindresorhus/quick-lru) - Simple “Least Recently Used” (LRU) cache
|
Reference in New Issue
Block a user