File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ using `Buffer.from()`.
4242
4343Buffers can also be instantiated by size using ` Buffer.alloc() ` , ` Buffer.allocUnsafe() ` and ` Buffer.allocUnsafeSlow() `
4444
45+ // The next line should be an 'aside', how to do this in markdown and the rendered site?
46+
4547> _ Unsafe_ as the memory containing the buffer is not initialised - i.e. not zeroed-out, so the potential exists for sensitive data to be leaked.
4648
4749```
@@ -57,4 +59,28 @@ console.log(myBuffer2);
5759const myBuffer3 = Buffer.alloc(3, 'a');
5860console.log(myBuffer3);
5961// <Buffer 61 61 61>
60- ```
62+ ```
63+
64+ ### Caveat: Buffer size
65+
66+ Once instantiated, using either ` from() ` or one of the ` alloc() ` methods a Buffer cannot be resized.
67+
68+ A Buffer's size is measured in Octets which is a more accurate way of saying 'an 8-bit byte'.
69+
70+ ```
71+ const myBuffer4 = Buffer.alloc(4);
72+ console.log(myBuffer4);
73+ // <Buffer 00 00 00 00>
74+ myBuffer4.write('card');
75+ console.log(myBuffer4);
76+ // <Buffer 63 61 72 64>
77+ myBuffer4.write('cards');
78+ console.log(myBuffer4);
79+ // <Buffer 63 61 72 64> - last character is lost
80+ ```
81+
82+ ## Terminology
83+
84+ ** Octet**
85+
86+ An Octet is a more accurate way to describe a byte consisting of 8-bits. In some systems a byte can have more or less bits.
You can’t perform that action at this time.
0 commit comments