Last active
May 26, 2019 18:58
-
-
Save vbarbarosh/21a45d9f995f225250b81e6a20b87f94 to your computer and use it in GitHub Desktop.
node_buffer – How to work with Buffer https://codescreens.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // How to work with Buffer | |
| main().catch(panic); | |
| async function main() | |
| { | |
| // Use this if buffer will be immediately written to | |
| Buffer.allocUnsafe(1024); | |
| // Use this to allocate memory filled with zeroes | |
| Buffer.alloc(1024); | |
| // Use this to get a narrow view to the same memory | |
| Buffer.alloc(1024).slice(0, 100); | |
| } | |
| function panic(error) | |
| { | |
| console.error(error); | |
| process.exit(1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment