Pathfinder
Pathfinder is a class to find a path to an object.
import { Pathfinder } from "@schukai/monster/source/data/pathfinder.mjs";Example 1
import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
let value = new Pathfinder({
a: {
b: {
f: [
{
g: false,
}
],
}
}
}).getVia("a.b.f.0.g");
console.log(value);
// ↦ false
try {
new Pathfinder({}).getVia("a.b.f.0.g");
} catch (e) {
console.log(e.toString());
// ↦ Error: the journey is not at its end (b.f.0.g)
}Example 2
import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
let p = new Pathfinder({
a: {
x: [
{c: 1}, {c: 2}
],
y: true
},
b: {
x: [
{c: 1, d: false}, {c: 2}
],
y: true
},
});
let r = p.getVia("*.x.*.c");
console.log(r);Exported
Pathfinder, DELIMITER, WILDCARDDerived from
BaseOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the Base.
Properties
The Properties listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Properties from these parent classes. If you cannot find a specific Properties in this list, we recommend consulting the documentation of the Base.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the Base.
Constructor
constructor(object)object{object}: - The object parameter for the constructor.
{Error}Throws an error if the provided object parameter is a simple type.
Structural methods
getVia(path)1.4.0path{string|array}: path
- {*}
{TypeError}unsupported type{Error}the journey is not at its end{TypeError}value is not a string{TypeError}value is not an integer{Error}unsupported action for this data type
setVia(path,value)1.4.0path{string|array}: pathvalue{*}: value
- {Pathfinder}
{TypeError}unsupported type{TypeError}value is not a string{TypeError}value is not an integer{Error}unsupported action for this data type
setWildCard(wildcard)1.7.0wildcard{string}: wildcard
- {Pathfinder}
Other methods
deleteVia(path)1.6.0path{string|array}: path
- {Pathfinder}
{TypeError}unsupported type{TypeError}value is not a string{TypeError}value is not an integer{Error}unsupported action for this data type
exists(path)1.4.0path{string|array}: path
- {bool}
{TypeError}unsupported type{TypeError}value is not a string{TypeError}value is not an integer
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.