octet-stream / form-data

Spec-compliant FormData implementation for Node.js
https://www.npmjs.com/package/formdata-node
MIT License
142 stars 17 forks source link

[QUESTION]: form-data vs formdata-node #1

Closed xr0master closed 5 years ago

xr0master commented 5 years ago

Hey guys. Can you explain your motivation to create this project, please? What is different between form-data and formdata-node?

Thank you

octet-stream commented 5 years ago

Hello. That's a good question. In short: I decided to implement FormData other way and drop old Node.js versions.

Initially this project was just my experiment with Node.js streams and was made because of these reasons:

xr0master commented 5 years ago

Thank you very much for such a detailed response.

I see that the packet size is pretty much the same. What about benchmark versus competitor? And CPU load due to while(true)?

You know, when a server has more than half a million requests, each optimization has its own price. So it is very important for me.

PS I'll be happy to have a typescript definition file as TS fanboy :) PPS And again thank you for your amazing job!

octet-stream commented 5 years ago

I understand your point, but to be honest, I never thought about benchmarking in this project since this was an experiment. I'm also never wrote benchmarks, so I don't know how it works with a lots of data. Sorry about that :) By the way, I think we might don't need while(true) in FormData#__getField since it is the asynchronous iterator. But StreamIterator still needs infinite loop to read the data from Read/Readable streams. At least I don't know other way to make it works. Maybe this project needs some refactoring :)

I thought you can use standard definitions of the FormData in TS, so I didn't added them here. But if it doesn't work, I think we can fix that :) Honestly, I barely familiar with TS, but I think we can jus get standard definitions and extend them with formdata-node specific things.

I'm also don't support any way to get size of the FormData, but I'm planning this feature for next releases.

octet-stream commented 5 years ago

Oh, I just realised that browser implementation uses different data types for FormData entry values, which means that you can't use it here :D Sure I will add typings file. I guess I figured out how it could be made. Is there a way to test .d.ts files? Just to be sure if I'm working in the right direction since I'm barely familiar with TS.

octet-stream commented 5 years ago

I'm closing this thread because of inactivity.

TS typings will be added if only I'd learn TS or somebody help me with that.

octet-stream commented 5 years ago

@xr0master hey 👋 I've added some typings to use the library with TS. You can try it in 1.7.0 version. Please, let me know if you have any issue with them.