Buffer is a temporary memory storage which stores the data when it is being moved from one place to another. It is like an array of integers.
The Buffer.copy() method simply copies all the values from input buffer to another buffer.
buffer.copy( target, targetStart, sourceStart, sourceEnd )
Parameters: This method accept two parameters as mentioned above and described below:
- target: It is a buffer in which you need to copy all the values.
- targetStart: It refers to the starting index from which the elements of target buffer will begin writing. Its default value is 0.
- sourceStart: It is the index of input buffer from which the copying of values will start. Its default value is 0.
- sourceEnd: The index of input buffer till which the copying of values will be done. Its default value is buffer.length size.
Return Value: This method returns the number that indicates the number of bytes copied.
Note: Copies the values from input buffer and overwrites them to output buffer even if the target memory regions (indexes) already exist. Copies data from a region of input buffer to a region in target buffer even if the target memory region overlaps with input buffer.
Below examples illustrate the use of Buffer.includes() Method in Node.js:
Note: The above program will compile and run by using the
node index.js command.
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs console.timeLog() Method
- Nodejs | DNS
- Web-Socket in NodeJS
- Nodejs | Jimp
- Nodejs | DNS | setServers()
- Nodejs | GM blur() Function
- Nodejs | GM monochrome() Function
- Nodejs | GM orderedDither() Function
- Nodejs | GM equalize() Function
- Nodejs | GM paint() Function
- Difference between NodeJS and AngularJS
- Nodejs | GM drawRectangle() Function
- Nodejs | GM enhance() Function
- Nodejs | GM randomThreshold() Function
- Nodejs | GM charcoal() Function
- Nodejs | GM motionBlur() Function
- Nodejs | GM whiteThreshold() Function
- Nodejs | GM write() Function
- Nodejs | GM chop() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.