@avonjs/avonjs
Version:
A fluent Node.js API generator.
26 lines (25 loc) • 676 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class QueryParser {
query;
handlers;
constructor(query, handlers) {
this.query = query;
this.handlers = handlers;
}
/**
* Get pair of handlers and matched values.
*/
matches() {
return this.handlers
.filter((handler) => this.query[handler.key()] !== undefined)
.map((handler) => {
const value = this.query[handler.key()];
return {
handler,
value: handler.isValidNullValue(value) ? null : value,
};
});
}
}
exports.default = QueryParser;