memory-pager

WebJar for memory-pager

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

memory-pager
Last Version

Last Version

1.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

memory-pager
WebJar for memory-pager
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mafintosh/memory-pager

Download memory-pager

Filename Size
memory-pager-1.5.0.pom -1 bytes
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/memory-pager/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>memory-pager</artifactId>
    <version>1.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/memory-pager/
implementation 'org.webjars.npm:memory-pager:1.5.0'
// https://jarcasting.com/artifacts/org.webjars.npm/memory-pager/
implementation ("org.webjars.npm:memory-pager:1.5.0")
'org.webjars.npm:memory-pager:jar:1.5.0'
<dependency org="org.webjars.npm" name="memory-pager" rev="1.5.0">
  <artifact name="memory-pager" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='memory-pager', version='1.5.0')
)
libraryDependencies += "org.webjars.npm" % "memory-pager" % "1.5.0"
[org.webjars.npm/memory-pager "1.5.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

memory-pager

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).

travis

npm install memory-pager

Usage

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

API

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

License

MIT

Versions

Version
1.5.0