Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
memory-pager
Advanced tools
Package description
The memory-pager package is a utility for managing and abstracting over pages of memory, allowing for efficient memory allocation and manipulation in a paged manner. It is particularly useful in scenarios where managing large datasets or buffers in a memory-efficient way is crucial, such as in databases or file systems.
Page allocation and retrieval
This feature allows for the allocation and retrieval of memory pages. The code sample demonstrates how to allocate a new page (or retrieve it if it already exists) and then fill it with zeros.
const pager = require('memory-pager')();
let page = pager.get(0, true);
page.fill(0); // Allocate and fill the first page with zeros
Page updates and access
This feature enables updating and accessing data within a page. The code sample shows how to write data to a page and then read it back.
const data = Buffer.from('hello world');
page.set(data, 0); // Write data to the beginning of the page
const readData = page.get(0, data.length); // Read data from the page
Similar to memory-pager, random-access-memory provides an abstraction for memory storage, allowing for random access reads and writes. The key difference is that random-access-memory focuses on a single buffer abstraction, whereas memory-pager manages multiple pages of memory.
Dat-pager offers functionality for managing data in a paged manner, similar to memory-pager. However, it is specifically designed for use with the Dat protocol, focusing on efficient data synchronization and sharing over a peer-to-peer network.
Readme
Access memory using small fixed sized buffers instead of allocating a huge buffer. Useful if you are implementing sparse data structures (such as large bitfield).
npm install memory-pager
var pager = require('paged-memory')
var pages = pager(1024) // use 1kb per page
var page = pages.get(10) // get page #10
console.log(page.offset) // 10240
console.log(page.buffer) // a blank 1kb buffer
var pages = pager(pageSize)
Create a new pager. pageSize
defaults to 1024
.
var page = pages.get(pageNumber, [noAllocate])
Get a page. The page will be allocated at first access.
Optionally you can set the noAllocate
flag which will make the
method return undefined if no page has been allocated already
A page looks like this
{
offset: byteOffset,
buffer: bufferWithPageSize
}
pages.set(pageNumber, buffer)
Explicitly set the buffer for a page.
pages.updated(page)
Mark a page as updated.
pages.lastUpdate()
Get the last page that was updated.
var buf = pages.toBuffer()
Concat all pages allocated pages into a single buffer
MIT
FAQs
Access memory using small fixed sized buffers
The npm package memory-pager receives a total of 2,684,462 weekly downloads. As such, memory-pager popularity was classified as popular.
We found that memory-pager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.