random-access-pause-wrapper
Pause wrapper for a random-access-storage that adds a pause/resume method.
Last updated 2 years ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install random-access-pause-wrapper 
SYNC missed versions from official npm registry.

random-access-pause-wrapper

Wraps any random-access-storage instance and adds a pause() and resume() method to pause the execution of operations and continue at a later point.

npm install random-access-pause-wrapper

build status

Usage

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

console.log(file.paused) // false

file.write(
  0,
  Buffer.from('hello'),
  function () { // This callback will be triggered on-resume
    file.write(5, Buffer.from(' world'), function () {
      file.read(0, 11, console.log) // returns Buffer(hello world)
    })
  }
)

file.pause() // file.paused = true is an alternative API
console.log(file.paused) // true

file.on('pause', function () { console.log('pause called') })
file.on('resume', function () { console.log('resume called') })
file.on('paused', function (paused) { console.log('paused: ' + paused) })

file.resume() // file.paused = false works too.

License

MIT

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

2 Versions

  • 1.0.0                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (2)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |