dstructures Flashcards
js: a blob is
the binary string of an entire file stored in ram. Like a file stored fully in ram.
cs: a binary is
a string sequence of 0s or 1s that make up any file
cs: a bit is
a string, either 0 or 1
cs: a byte is
a string of 8 bits (which are either 0 or 1)
cs: All digital media (text, pictures, videos, etc) is
stored as bits at the lowest level
cs: bit stands for
binary digit
https://medium.freecodecamp.org/do-you-want-a-better-understanding-of-buffer-in-node-js-check-this-out-2e29de2968e8
cs: To save a number, a computer must first
convert it to its binary representation whic is the same number written in base-2. So, 3 becomes 11.
cs: To save a letter, a computer must first
convert it to a number (using the character to number dictionary called character set, usually unicode), and then convert that number into binary aka base-2.
cs: To know which letter corresponds with which number, a computer must check the
character to number dictionary, aka, character set, usually unicode
cs: The most common character set is
Unicode
cs: A character set is
a character to number dictionary
cs: A character encoding is a
set of rules about how to format the binary you created from a letter
cs: The most popular character encoding it
UTF-8
cs: The UTF-8 rules about converting a character to a byte force you to
save into a bytes (8 digits). When the letter’s number’s base-2 version is less than 8 digits, you must add 0s to the beginning of the byte.
cs: Chunks are kinda big
a large text file can have just 2 chunks.
js: During a stream, node automatically creates
an internal buffer
cs: The three types of stream are
readable, writable and duplex
cs: Some common uses of streams are
reading and writing to disk, sending response to client from server, console.log()
cs: In http streams, usually
an internal buffer in ram gets filled with bytes, and then when the internal buffer is full it sends a chunk to the client and asks for new data.
https: //www.youtube.com/watch?v=GpGTYp_G9VE
https: //www.youtube.com/watch?v=YpVDaVufDVU
cs: streams emit
events, like data and end
node: To write a script that echos back whatever you type into the console, type
process. stdin.pipe(process.stdout)
process. stdout is a callback function that gets the process.stdin return as a parameter
cs: To start a stream’s transfer of bits, type
myStream.read()
cs: A buffer is
an object that holds binary string
held in ram
fills with data up to allocated limit
https: //nodejs.org/api/stream.html#stream_buffering
https: //hackernoon.com/https-medium-com-amanhimself-converting-a-buffer-to-json-and-utf8-strings-in-nodejs-2150b1e3de57
https: //allenkim67.github.io/programming/2016/05/17/nodejs-buffer-tutorial.html
js: A stream is basically an
object that spits out bytes of data continuously into an internal buffer which fills up to its byte limit, and then sends all that data as a chunk to a stream receiver, and asks for next data.
The stream runs .emit(‘data’, payload) whenever it wants to send data and then your event handler runs with that data payload as a param.
https://medium.freecodecamp.org/node-js-streams-everything-you-need-to-know-c9141306be93
To make a stream stop sending data
https://youtu.be/lQAV3bPOYHo?t=168