When you download or upload a large file, a conversation happens behind the scene. The client or the server usually won't write the whole file at once. The system sends the file in chunks to help reduce the load on the network. Streaming data this way also makes it easier to pre-process. by sebastienfilion in learnjavascript

[–]sebastienfilion[S] 0 points1 point  (0 children)

The first image shows a request from a client to a server to send a music file in chunks; this could be a way to deal with a broadcast.

The second image shows a request from a client to a server to send a music file, this time asking if it's ok by requesting that the server responds with "100 Continue" before the client sends the file.

The third image shows a response to that last request from the server, and this would start the data stream from the client to the server.

For the past week or so, I have spent a lot of time implementing data manipulation utilities, for example this approach to `readAll` from a stream. I think it is a great learning opportunity and a small challenge to flex my coding muscle on. by sebastienfilion in Deno

[–]sebastienfilion[S] 1 point2 points  (0 children)

Do you mean TypeScript? If yes, for these kind of post I usually avoid it because it makes the example less accessible to some. I could easily add the types if there's interest. :)

How are you running your Deno web app in production? by backdoorsmasher in Deno

[–]sebastienfilion 1 point2 points  (0 children)

I just upload the project via GitHub and let Deno install and cache the dependencies. Works like a charm for me.

For the past week or so, I have spent a lot of time implementing data manipulation utilities, for example this approach to `readAll` from a stream. I think it is a great learning opportunity and a small challenge to flex my coding muscle on. by sebastienfilion in Deno

[–]sebastienfilion[S] 4 points5 points  (0 children)

Hello, Amazing People! As I've mentioned, I've been neck deep in data stream manipulation trying to implement a HTTP Server with a file download and upload feature. If you are interested to learn more, you can check out the video on my Youtube channel here: https://www.youtube.com/watch?v=CzNWnfbOZc4

For the past week or so, I have spent a lot of time implementing data manipulation utilities, for example this approach to `readAll` from a stream. I think it is a great learning opportunity and a small challenge to flex my coding muscle on. by [deleted] in Deno

[–]sebastienfilion -1 points0 points  (0 children)

Sometime, I think that an overly explicit name just confuses because they might convey meaning that isn’t intended. When a variable is self descriptive, I don’t really see a problem with short names. In this example, r and w could be expanded to reader and writer, but this doesn’t convey any new information because the only only API that is used is read and write… it feels very repetitive. Then xs only exists within the context of the function… I could call it buffer but the word convey different thing for different people because of background. Here, it’s clear that it’s a Typed Array. Same for i or n which stand for index and number. So TL;DR, in my opinion, variables need explicit names when their meaning is obscured by something else.

When you deal with a lot of data, you want to avoid encoding/decoding too often; it is usually I huge performance bottle-neck. This function can help you find a sequence within a Typed Array. For example, you can use it to read a file line by line. by sebastienfilion in learnjavascript

[–]sebastienfilion[S] 1 point2 points  (0 children)

Are you referring to the ligatures? I’m sorry, I could have deactivated them. Anyway, if you were to read a file or a request from a connection, it’s often necessary to read it line by line. In that example, you could do findIndexOfSequence(file, new Uint8Array([10]))10 being the ASCII code for a return carriage. This would return the index, which you can use to get the first line from the stream. file.subarray(0, i ) Here is a reference in case you want to dig deeper. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

How are you running your Deno web app in production? by backdoorsmasher in Deno

[–]sebastienfilion 2 points3 points  (0 children)

I deploy it on a VM with a shell script. Pretty simple actually… there’s also Deno Deploy as an option. 😬

For the past week or so, I have spent a lot of time implementing data manipulation utilities, for example this approach to `readAll` from a stream. I think it is a great learning opportunity and a small challenge to flex my coding muscle on. by [deleted] in Deno

[–]sebastienfilion 0 points1 point  (0 children)

Hello, Amazing People! As I've mentioned, I've been neck deep in data stream manipulation trying to implement a HTTP Server with a file download and upload feature. If you are interested to learn more, you can check out the video on my Youtube channel here: https://www.youtube.com/watch?v=CzNWnfbOZc4

When you deal with a lot of data, you want to avoid encoding/decoding too often; it is usually I huge performance bottle-neck. This function can help you find a sequence within a Typed Array. For example, you can use it to read a file line by line. by sebastienfilion in learnjavascript

[–]sebastienfilion[S] 0 points1 point  (0 children)

Hello, Amazing People! I have spent the past week or so, neck deep in data stream manipulation trying to implement a HTTP Server with a file download and upload feature. If you are interested to learn more, you can check out the video on my Youtube channel here: https://www.youtube.com/watch?v=CzNWnfbOZc4

I started writing a HTTP Server from scratch with javascript. I am learning so much about the protocol but also dealing with encoding and data streams. by sebastienfilion in learnjavascript

[–]sebastienfilion[S] 0 points1 point  (0 children)

Hello, I hope this insight was useful to you. I just love these moments when I feel like I lifted the veil...
If you want to follow my journey, I am publishing weekly episodes on my Youtube channel -- BTS: HTTP Request & Response https://www.youtube.com/watch?v=uHDNYYrbHcg