E
E
eugene_tihonov2012-01-03 20:37:48
Node.js
eugene_tihonov, 2012-01-03 20:37:48

Readable Stream from Node.js to browser or any polymorphic alternative

Hello.

Let there be some JavaScript code that runs on the server (node.js) and in the browser. In the process of writing, there was a need for a function that should process some text. In the north, this text can be in a file (and the file can be large), and in the browser it is inserted, for example, in a textarea. In such cases, in C# I used TextReader , and the right place to use an instance of the appropriate descendant ( String- or StreamReader ).

Passing the contents of the entire file as a string is not very correct, so it would be nice to use some analogue of the stream classes, while such classes should work both in the browser and on the server.

So far, only one solution is seen: write an analogue of the My_Readable_Stream interface, then write an implementation for the browser and an adapter Readable_Stream_from_Node to My_Readable_Stream.

But there is a suspicion that there should be a ready-made solution to such a problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question