light-my-request
light-my-request copied to clipboard
Parsing socket
migrate to class syntax (Chain, request, response) add a mock socket class (parse headers, body, trailers) change emitting and subscription
this is the sequel to https://github.com/fastify/light-my-request/pull/252
bun.js support update usage of deprecated attribute
some test was changed due to unexpected behavior the main tests were tested with
http.createServer(inj).listen(3000, () => {
const r = http.request({ port: 3000, method: 'POST' }, (res) => cb(null, res)).on('error', cb)
payload && payload.pipe(r)
r.end()
});
Checklist
- [X] run
npm run testandnpm run benchmark - [X] tests and/or benchmarks are included
- [X] documentation is changed or added (.d.ts)
- [X] commit message and code follows the Developer's Certification of Origin and the Code of conduct
It takes some time to optimize but generally open to discussion
light-my-request on parsing-socket [!+⇕] is 📦 v5.10.0 via v20.5.0 on ☁️ (us-west-2) took 5s
❯ npm run benchmark
> [email protected] benchmark
> node benchmark/benchmark.js
Request x 160,977 ops/sec ±3.86% (80 runs sampled)
Custom Request x 14,371 ops/sec ±4.12% (81 runs sampled)
Request With Cookies x 136,650 ops/sec ±1.94% (87 runs sampled)
Request With Cookies n payload x 134,341 ops/sec ±2.71% (81 runs sampled)
ParseUrl x 1,207,543 ops/sec ±1.39% (87 runs sampled)
ParseUrl and query x 114,550 ops/sec ±2.00% (90 runs sampled)
light-my-request on master [!⇕] is 📦 v5.10.0 via v20.5.0 on ☁️ (us-west-2) took 11s
❯ npm run benchmark
> [email protected] benchmark
> node benchmark/benchmark.js
Request x 267,087 ops/sec ±14.67% (72 runs sampled)
Custom Request x 21,130 ops/sec ±3.09% (85 runs sampled)
Request With Cookies x 203,067 ops/sec ±7.45% (74 runs sampled)
Request With Cookies n payload x 205,931 ops/sec ±2.17% (83 runs sampled)
ParseUrl x 1,168,402 ops/sec ±5.19% (80 runs sampled)
ParseUrl and query x 141,309 ops/sec ±2.21% (94 runs sampled)
I don't think we agreed to https://github.com/fastify/light-my-request/pull/252, this PR seems a bit premature too.
I don't think we agreed to https://github.com/fastify/light-my-request/pull/252, this PR seems a bit premature too.
Yes, so I made a another PR with planning for the long future
This PR will simply allow it to be more native, with support for most events and most attribute, methods that are currently available in native request Node but not in light-my-request
that's why I used extends Socket and IncomingMessage