mmap(2) bindings for node.js that work in 5.00
mmap = require("mmap")
buffer = mmap(n_bytes, protection, flags, fd, offset)
n_bytes | The number of bytes to map into memory. |
protection | Memory protection: either mmap.PROT_NONE or a bitwise OR of mmap.PROT_READ, mmap.PROT_WRITE and mmap.PROT_EXEC. |
flags | Flags: either mmap.MAP_SHARED or mmap.MAP_PRIVATE. |
fd | File descriptor. You can also use a file name (string). When you do this, mmap() tries to do the right thing by creating or growing the file to n_bytes if necessary. |
offset | File offset. Must be either zero or a multiple of mmap.PAGESIZE. |
While a finaliser is installed to automatically unmap buffer, you can force it to unmap immediately with:
buffer.unmap()
You can also msync() by calling: buffer.sync([offset, [length, [flags]]])
method:
offset | The start address to sync. This argument optional, the default is 0. |
length | The number of bytes to sync. This argument optional, the default is the entire buffer. |
flags | Flags: either mmap.MS_SYNC or mmap.MS_ASYNC optionally bitwise OR with mmap.MS_INVALIDATE. This argument is optional, the default is mmap.MS_SYNC. |
For compatibility, mmap.map() is an alias for mmap()