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:
11
node_modules/dset/dist/index.js
generated
vendored
Normal file
11
node_modules/dset/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
function dset(obj, keys, val) {
|
||||
keys.split && (keys=keys.split('.'));
|
||||
var i=0, l=keys.length, t=obj, x, k;
|
||||
while (i < l) {
|
||||
k = ''+keys[i++];
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
t = t[k] = (i === l) ? val : (typeof(x=t[k])===typeof(keys)) ? x : (keys[i]*0 !== 0 || !!~(''+keys[i]).indexOf('.')) ? {} : [];
|
||||
}
|
||||
}
|
||||
|
||||
exports.dset = dset;
|
1
node_modules/dset/dist/index.min.js
generated
vendored
Normal file
1
node_modules/dset/dist/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.dset={})}(this,(function(t){t.dset=function(t,e,o){e.split&&(e=e.split("."));for(var n,f,p=0,i=e.length,d=t;p<i&&"__proto__"!=(f=""+e[p++])&&"constructor"!==f&&"prototype"!==f;)d=d[f]=p===i?o:typeof(n=d[f])==typeof e?n:0*e[p]!=0||~(""+e[p]).indexOf(".")?{}:[]}}));
|
9
node_modules/dset/dist/index.mjs
generated
vendored
Normal file
9
node_modules/dset/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export function dset(obj, keys, val) {
|
||||
keys.split && (keys=keys.split('.'));
|
||||
var i=0, l=keys.length, t=obj, x, k;
|
||||
while (i < l) {
|
||||
k = ''+keys[i++];
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
t = t[k] = (i === l) ? val : (typeof(x=t[k])===typeof(keys)) ? x : (keys[i]*0 !== 0 || !!~(''+keys[i]).indexOf('.')) ? {} : [];
|
||||
}
|
||||
}
|
1
node_modules/dset/index.d.ts
generated
vendored
Normal file
1
node_modules/dset/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function dset<T extends object, V>(obj: T, keys: string | ArrayLike<string | number>, value: V): void;
|
21
node_modules/dset/license
generated
vendored
Normal file
21
node_modules/dset/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.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.
|
2
node_modules/dset/merge/index.d.ts
generated
vendored
Normal file
2
node_modules/dset/merge/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export function merge(foo: any, bar: any): any; // TODO
|
||||
export function dset<T extends object, V>(obj: T, keys: string | ArrayLike<string | number>, value: V): void;
|
29
node_modules/dset/merge/index.js
generated
vendored
Normal file
29
node_modules/dset/merge/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
function merge(a, b, k) {
|
||||
if (typeof a === 'object' && typeof b === 'object') {
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
for (k=0; k < b.length; k++) {
|
||||
a[k] = merge(a[k], b[k]);
|
||||
}
|
||||
} else {
|
||||
for (k in b) {
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
a[k] = merge(a[k], b[k]);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
function dset(obj, keys, val) {
|
||||
keys.split && (keys=keys.split('.'));
|
||||
var i=0, l=keys.length, t=obj, x, k;
|
||||
while (i < l) {
|
||||
k = ''+keys[i++];
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
t = t[k] = (i === l) ? merge(t[k],val) : (typeof(x=t[k])===typeof keys) ? x : (keys[i]*0 !== 0 || !!~(''+keys[i]).indexOf('.')) ? {} : [];
|
||||
}
|
||||
}
|
||||
|
||||
exports.dset = dset;
|
||||
exports.merge = merge;
|
1
node_modules/dset/merge/index.min.js
generated
vendored
Normal file
1
node_modules/dset/merge/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.dset={})}(this,(function(t){function e(t,o,r){if("object"==typeof t&&"object"==typeof o){if(Array.isArray(t)&&Array.isArray(o))for(r=0;r<o.length;r++)t[r]=e(t[r],o[r]);else for(r in o){if("__proto__"===r||"constructor"===r||"prototype"===r)break;t[r]=e(t[r],o[r])}return t}return o}t.dset=function(t,o,r){o.split&&(o=o.split("."));for(var f,n,i=0,p=o.length,s=t;i<p&&"__proto__"!=(n=""+o[i++])&&"constructor"!==n&&"prototype"!==n;)s=s[n]=i===p?e(s[n],r):typeof(f=s[n])==typeof o?f:0*o[i]!=0||~(""+o[i]).indexOf(".")?{}:[]},t.merge=e}));
|
26
node_modules/dset/merge/index.mjs
generated
vendored
Normal file
26
node_modules/dset/merge/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
export function merge(a, b, k) {
|
||||
if (typeof a === 'object' && typeof b === 'object') {
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
for (k=0; k < b.length; k++) {
|
||||
a[k] = merge(a[k], b[k]);
|
||||
}
|
||||
} else {
|
||||
for (k in b) {
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
a[k] = merge(a[k], b[k]);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
export function dset(obj, keys, val) {
|
||||
keys.split && (keys=keys.split('.'));
|
||||
var i=0, l=keys.length, t=obj, x, k;
|
||||
while (i < l) {
|
||||
k = ''+keys[i++];
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
t = t[k] = (i === l) ? merge(t[k],val) : (typeof(x=t[k])===typeof keys) ? x : (keys[i]*0 !== 0 || !!~(''+keys[i]).indexOf('.')) ? {} : [];
|
||||
}
|
||||
}
|
60
node_modules/dset/package.json
generated
vendored
Normal file
60
node_modules/dset/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "dset",
|
||||
"version": "3.1.4",
|
||||
"repository": "lukeed/dset",
|
||||
"description": "A tiny (194B) utility for safely writing deep Object values~!",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"umd:main": "dist/index.min.js",
|
||||
"module": "dist/index.mjs",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.d.ts",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"./merge": {
|
||||
"types": "./merge/index.d.ts",
|
||||
"import": "./merge/index.mjs",
|
||||
"require": "./merge/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"test": "uvu test -r esm -i suites"
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"merge",
|
||||
"dist"
|
||||
],
|
||||
"modes": {
|
||||
"merge": "src/merge.js",
|
||||
"default": "src/index.js"
|
||||
},
|
||||
"keywords": [
|
||||
"deepset",
|
||||
"values",
|
||||
"object",
|
||||
"write",
|
||||
"deep",
|
||||
"safe",
|
||||
"set"
|
||||
],
|
||||
"devDependencies": {
|
||||
"bundt": "1.1.2",
|
||||
"esm": "3.2.25",
|
||||
"uvu": "0.5.1"
|
||||
}
|
||||
}
|
199
node_modules/dset/readme.md
generated
vendored
Normal file
199
node_modules/dset/readme.md
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
# dset [](https://github.com/lukeed/dset/actions) [](https://codecov.io/gh/lukeed/dset)
|
||||
|
||||
> A tiny (197B) utility for safely writing deep Object values~!
|
||||
|
||||
For _accessing_ deep object properties, please see [`dlv`](https://github.com/developit/dlv).
|
||||
|
||||
> **Using GraphQL?** You may want `dset/merge` – see [Merging](#merging) for more info.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save dset
|
||||
```
|
||||
|
||||
## Modes
|
||||
|
||||
There are two "versions" of `dset` available:
|
||||
|
||||
#### `dset`
|
||||
> **Size (gzip):** 197 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/dset/dist/index.js), [ES Module](https://unpkg.com/dset/dist/index.mjs), [UMD](https://unpkg.com/dset/dist/index.min.js)
|
||||
|
||||
```js
|
||||
import { dset } from 'dset';
|
||||
```
|
||||
|
||||
#### `dset/merge`
|
||||
> **Size (gzip):** 307 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/dset/merge/index.js), [ES Module](https://unpkg.com/dset/merge/index.mjs), [UMD](https://unpkg.com/dset/merge/index.min.js)
|
||||
|
||||
```js
|
||||
import { dset } from 'dset/merge';
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { dset } from 'dset';
|
||||
|
||||
let foo = { abc: 123 };
|
||||
dset(foo, 'foo.bar', 'hello');
|
||||
// or: dset(foo, ['foo', 'bar'], 'hello');
|
||||
console.log(foo);
|
||||
//=> {
|
||||
//=> abc: 123,
|
||||
//=> foo: { bar: 'hello' },
|
||||
//=> }
|
||||
|
||||
dset(foo, 'abc.hello', 'world');
|
||||
// or: dset(foo, ['abc', 'hello'], 'world');
|
||||
console.log(foo);
|
||||
//=> {
|
||||
//=> abc: { hello: 'world' },
|
||||
//=> foo: { bar: 'hello' },
|
||||
//=> }
|
||||
|
||||
let bar = { a: { x: 7 }, b:[1, 2, 3] };
|
||||
dset(bar, 'b.1', 999);
|
||||
// or: dset(bar, ['b', 1], 999);
|
||||
// or: dset(bar, ['b', '1'], 999);
|
||||
console.log(bar);
|
||||
//=> {
|
||||
//=> a: { x: 7 },
|
||||
//=> b: [1, 999, 3],
|
||||
//=> }
|
||||
|
||||
dset(bar, 'a.y.0', 8);
|
||||
// or: dset(bar, ['a', 'y', 0], 8);
|
||||
// or: dset(bar, ['a', 'y', '0'], 8);
|
||||
console.log(bar);
|
||||
//=> {
|
||||
//=> a: {
|
||||
//=> x: 7,
|
||||
//=> y: [8],
|
||||
//=> },
|
||||
//=> b: [1, 999, 3],
|
||||
//=> }
|
||||
|
||||
let baz = {};
|
||||
dset(baz, 'a.0.b.0', 1);
|
||||
dset(baz, 'a.0.b.1', 2);
|
||||
console.log(baz);
|
||||
//=> {
|
||||
//=> a: [{ b: [1, 2] }]
|
||||
//=> }
|
||||
```
|
||||
|
||||
## Merging
|
||||
|
||||
The main/default `dset` module forcibly writes values at the assigned key-path. However, in some cases, you may prefer to _merge_ values at the key-path. For example, when using [GraphQL's `@stream` and `@defer` directives](https://foundation.graphql.org/news/2020/12/08/improving-latency-with-defer-and-stream-directives/), you will need to merge the response chunks into a single object/list. This is why `dset/merge` exists~!
|
||||
|
||||
Below is a quick illustration of the difference between `dset` and `dset/merge`:
|
||||
|
||||
```js
|
||||
let input = {
|
||||
hello: {
|
||||
abc: 123
|
||||
}
|
||||
};
|
||||
|
||||
dset(input, 'hello', { world: 123 });
|
||||
console.log(input);
|
||||
|
||||
// via `dset`
|
||||
//=> {
|
||||
//=> hello: {
|
||||
//=> world: 123
|
||||
//=> }
|
||||
//=> }
|
||||
|
||||
// via `dset/merge`
|
||||
//=> {
|
||||
//=> hello: {
|
||||
//=> abc: 123,
|
||||
//=> world: 123
|
||||
//=> }
|
||||
//=> }
|
||||
```
|
||||
|
||||
|
||||
## Immutability
|
||||
|
||||
As shown in the examples above, all `dset` interactions mutate the source object.
|
||||
|
||||
If you need immutable writes, please visit [`clean-set`](https://github.com/fwilkerson/clean-set) (182B).<br>
|
||||
Alternatively, you may pair `dset` with [`klona`](https://github.com/lukeed/klona), a 366B utility to clone your source(s). Here's an example pairing:
|
||||
|
||||
```js
|
||||
import { dset } from 'dset';
|
||||
import { klona } from 'klona';
|
||||
|
||||
export function deepset(obj, path, val) {
|
||||
let copy = klona(obj);
|
||||
dset(copy, path, val);
|
||||
return copy;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### dset(obj, path, val)
|
||||
|
||||
Returns: `void`
|
||||
|
||||
#### obj
|
||||
|
||||
Type: `Object`
|
||||
|
||||
The Object to traverse & mutate with a value.
|
||||
|
||||
#### path
|
||||
|
||||
Type: `String` or `Array`
|
||||
|
||||
The key path that should receive the value. May be in `x.y.z` or `['x', 'y', 'z']` formats.
|
||||
|
||||
> **Note:** Please be aware that only the _last_ key actually receives the value!
|
||||
|
||||
> **Important:** New Objects are created at each segment if there is not an existing structure.<br>However, when integers are encounted, Arrays are created instead!
|
||||
|
||||
#### value
|
||||
|
||||
Type: `Any`
|
||||
|
||||
The value that you want to set. Can be of any type!
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
For benchmarks and full results, check out the [`bench`](/bench) directory!
|
||||
|
||||
```
|
||||
# Node 10.13.0
|
||||
|
||||
Validation:
|
||||
✔ set-value
|
||||
✔ lodash/set
|
||||
✔ dset
|
||||
|
||||
Benchmark:
|
||||
set-value x 1,701,821 ops/sec ±1.81% (93 runs sampled)
|
||||
lodash/set x 975,530 ops/sec ±0.96% (91 runs sampled)
|
||||
dset x 1,797,922 ops/sec ±0.32% (94 runs sampled)
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [dlv](https://github.com/developit/dlv) - safely read from deep properties in 120 bytes
|
||||
- [dequal](https://github.com/lukeed/dequal) - safely check for deep equality in 247 bytes
|
||||
- [klona](https://github.com/lukeed/klona) - quickly "deep clone" data in 200 to 330 bytes
|
||||
- [clean-set](https://github.com/fwilkerson/clean-set) - fast, immutable version of `dset` in 182 bytes
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
Reference in New Issue
Block a user