@sapphire/plugin-api
Version:
Plugin for @sapphire/framework to expose a REST API
56 lines (54 loc) • 1.44 kB
JavaScript
import { __name, __publicField, __privateAdd, __privateGet } from '../../../chunk-S573YWRP.mjs';
import { Collection } from 'discord.js';
var _methods;
var _RouterNode = class _RouterNode {
constructor(parent) {
/**
* The branch containing this node.
*/
__publicField(this, "parent");
/**
* The methods this node supports.
*/
__privateAdd(this, _methods, new Collection());
this.parent = parent;
}
get path() {
return this.parent.path;
}
extractParameters(parts) {
const parameters = {};
let branch = this.parent;
let index = parts.length - 1;
do {
if (branch.dynamic) parameters[branch.name] = parts[index];
branch = branch.parent;
--index;
} while (branch);
return parameters;
}
get(method) {
return __privateGet(this, _methods).get(method) ?? null;
}
set(method, route) {
__privateGet(this, _methods).set(method, route);
return this;
}
delete(method, route) {
const existing = __privateGet(this, _methods).get(method);
if (existing === route) {
__privateGet(this, _methods).delete(method);
return true;
}
return false;
}
methods() {
return __privateGet(this, _methods).keys();
}
};
_methods = new WeakMap();
__name(_RouterNode, "RouterNode");
var RouterNode = _RouterNode;
export { RouterNode };
//# sourceMappingURL=RouterNode.mjs.map
//# sourceMappingURL=RouterNode.mjs.map