File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # random-access-pause-wrapper
2
+
3
+ Wraps any [ random-access-storage] ( https://github.com/random-access-storage/random-access-storage ) instance and adds a ` pause() ` and ` resume() ` method
4
+ that
5
+
6
+ ```
7
+ npm install random-access-pause-wrapper
8
+ ```
9
+
10
+ [ ![ build status] ( http://img.shields.io/travis/martinheidegger/random-access-pause-wrapper.svg?style=flat )] ( http://travis-ci.org/martinheidegger/random-access-pause-wrapper )
11
+
12
+ ## Usage
13
+
14
+ ``` js
15
+ var ram = require (' random-access-memory' )
16
+ var pause = require (' random-access-pause-wrapper' )
17
+ var file = pause (ram ())
18
+
19
+ console .log (file .paused ) // false
20
+
21
+ file .write (
22
+ 0 ,
23
+ Buffer .from (' hello' ),
24
+ function () { // This callback will be triggered on-resume
25
+ file .write (5 , Buffer .from (' world' ), function () {
26
+ file .read (0 , 11 , console .log ) // returns Buffer(hello world)
27
+ })
28
+ }
29
+ )
30
+
31
+ file .pause () // file.paused = true is an alternative API
32
+ console .log (file .paused ) // true
33
+
34
+ file .on (' pause' , function () { console .log (' pause called' ) })
35
+ file .on (' resume' , function () { console .log (' resume called' ) })
36
+ file .on (' paused' , function (paused ) { console .log (' paused: ' + paused) })
37
+
38
+ file .resume () // file.paused = false works too.
39
+ ```
40
+
41
+ ## License
42
+
43
+ MIT
You can’t perform that action at this time.
0 commit comments