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