/** * {} * @author yutent * @date 2023/10/27 12:14:05 */ import { parse } from 'node:querystring' import { EventEmitter } from 'node:events' export class UrlencodedParser extends EventEmitter { #buf = Buffer.from('') write(buffer) { this.#buf = Buffer.concat([this.#buf, buffer]) } end() { let data = this.#buf.toString() let fields = parse(data) this.#buf = null this.emit('field', fields) this.emit('end') } }