UNPKG

@mojojs/core

Version:

Real-time web framework

30 lines 738 B
import { URLSearchParams } from 'node:url'; /** * GET/POST parameter class. */ export class Params extends URLSearchParams { /** * Check if parameters are empty. */ get isEmpty() { return [...this].length === 0; } /* * Create a new `Params` object with all empty values removed. */ removeEmpty() { const params = new Params(); for (const [name, value] of this.entries()) { if (value !== '') params.append(name, value); } return params; } /** * Convert parameters into a plain object, useful for validation. */ toObject() { return Object.fromEntries(this); } } //# sourceMappingURL=params.js.map