Closed xr0master closed 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:
.append()
method from the API: https://github.com/form-data/form-data/issues/124 (I mean, look at this issue, it's unresolved for few years). formdata-node supports .append()
, .set()
, .get()
, .getAll()
, .has()
, .delete()
, .forEach()
, .keys()
, .values()
, .entries()
and .[Symbol.iterator]
so you can use (in about) full implementation of the FormData in your Node.js projects, for tests or something else.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!
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.
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.
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.
@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.
Hey guys. Can you explain your motivation to create this project, please? What is different between form-data and formdata-node?
Thank you