0

How to fully use buffer in projects and system. how can you take advantage of buffer in creating your project. tried looking at the documentation and articles but it doesn't show any use case regarding buffer on live projects.

Jieyo
  • 5
  • 3
  • Do you have a need for buffers? If not then why use them? They are just a representation of binary data in simple words. Thats nothing you have to use when not needed. – Marc Apr 08 '23 at 21:09
  • I just really want to fully utilize the syntax for development, I just thought that I might have missed the point of using buffer in projects. thats why I ask for clarification. – Jieyo Apr 09 '23 at 07:01

1 Answers1

0

Buffers in Javascript are generally for binary data or data that hasn't been decoded yet.

If your data is a string or a number, you just use those native types.

For example, if you wanted to read an image from disk and examine the EXIF data in the image, you would load at least the first part of the image into a buffer and then parse the binary data in the buffer to interpret the EXIF data.

Or, if you were writing code to decompress a file from scratch, you'd load a piece of the file into a buffer and run your decompression code on the binary data in the buffer.

Note, this is generally lower level programming (dealing with binary data) and there may be many projects that do not need to do that kind of manipulation themselves as you can often rely on already written libraries to do things like compression or decompression or encoding or decoding.

For example, if you use a library such as got() or axios() to make http requests, then those libraries will automatically handle the GZIP compression format for http responses so you don't have to handle the decompression yourself.

jfriend00
  • 683,504
  • 96
  • 985
  • 979