# mmap
**Repository Path**: mirrors_yorkie/mmap
## Basic Information
- **Project Name**: mmap
- **Description**: node mmap implementation
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-11-23
- **Last Updated**: 2026-05-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# mmap
mmap(2) bindings for node.js that work in 0.10
## Installing
npm test
npm install -g
## Usage
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()](http://pubs.opengroup.org/onlinepubs/9699919799/functions/msync.html) 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()
## See Also
* POSIX 1003.1 [mmap](http://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html) and [msync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/msync.html)
* The `example/` directory contains some sample uses of the mmap module
* [bnoordhuis/node-mmap](https://github.com/bnoordhuis/node-mmap), the original node-mmap, on which this is based.