...

/

Exercise: The Lazy Buffer

Exercise: The Lazy Buffer

Practice how to create a factory function that generates a virtual proxy for a buffer.

Problem statement

Can you implement a createLazyBuffer(size) named factory function that generates a virtual proxy for a buffer (Buffer) of the given size? The proxy instance should instantiate a Buffer object (effectively allocating the given amount of memory) only when write() is being invoked for the first time. If no attempt to write into the buffer is made, no ...