Skip to content

Class 04 Buffers

Erin Trainor edited this page Mar 17, 2019 · 1 revision

Original Resource Link

Definitions

Bit

Each number in a binary, each 1 and 0 in a set are called a Bit, which is a short form of Binary digIT.

Character Sets

Character Sets are already defined rules of what exact number represents each character.

  • You can get the character set of a letter by using this command in the browser developer tools - "insert letter here".charCodeAt(0)

Character Encoding

One of the rules for character coding is that they must use UTF-8. This means that they are required to be encoded in bytes. Since a byte is 8 bits this means that the number 15 would be written as 00001111.

Byte

A set of 8 bits

Stream

In Node.js stream simply means a sequence of data being moved from one point to the other over time. The whole concept is, you have a huge amount of data to process, but you don’t need to wait for all the data to be available before you start processing it.

Buffer

A temporary waiting area on your computer (typically in the RAM) where data that is sent is temporarily stored until it can be processed.

Really Awesome Buffer Analogy - Bus Station

We can think of the whole stream and buffer process as a bus station. In some bus stations, a bus is not allowed to depart until a certain amount of passengers arrive or until a specific departure time. Also, the passengers may arrive at different times with different speed. Neither the passengers nor the bus station has control over passengers’ arrival at the station.

In any case, passengers who arrive earlier will need to wait until the bus station decides to send the bus on its way. While passengers who arrive when the bus is already loading or when the bus has already departed need to wait for the next bus.

How to Count to 15 in Binary

Other Cool Visual Resource

Another Really Awesome Buffer Analogy - Video Streaming

A typical example where you could see buffer in action is when you’re streaming a video online. If your internet connection is fast enough, the speed of the stream will be fast enough to instantly fill up the buffer and send it out for processing, then fill another one, and send it out, then another, and yet another… till the stream is finished.

But if your connection is slow, after processing the first set of data that arrived, the video player will display a loading icon, or display the text “buffering”, which means gathering more data, or waiting for more data to arrive. And when the buffer is filled up and processed, the player shows the data, the video. While playing that, more data will continue to arrive and wait in the buffer.

If the player is done processing or playing the previous data, and the buffer is not yet filled up, the text “buffering” will be displayed again, waiting to gather more data to process.

Count to 15 in Binary

Other Notes

Clone this wiki locally