JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22544
  • Score
    100M100P100Q157642F
  • License MIT

Exposes the same interface as random-access-file but instead of writing/reading data to a file it maintains it in memory

Package Exports

  • random-access-memory

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (random-access-memory) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

random-access-memory

Exposes the same interface as random-access-file but instead of writing/reading data to a file it maintains it in memory. This is useful when running tests where you don't want to write files to disk.

npm install random-access-memory

Usage

var ram = require('random-access-memory')
var file = ram()

file.write(0, Buffer.from('hello'), function () {
  file.write(5, Buffer.from(' world'), function () {
    file.read(0, 11, console.log) // returns Buffer(hello world)
  })
})

You can also initialize a ram instance with a Buffer:

var file = ram(Buffer.from('hello world'))

License

MIT