-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
54 lines (42 loc) · 950 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var raf = require('random-access-file')
var join = require('path').join
module.exports = createFactory
function createFactory (fn) {
if (typeof fn === 'string') {
var dir = fn
fn = function (name) {
return raf(join(dir, name))
}
}
function createRad (name) {
function rad (name) {
return createRad(name)
}
var store = fn(name)
rad.open = function (cb) {
store.open(cb)
}
rad.write = function (offset, buf, cb) {
store.write(offset, buf, cb)
}
rad.read = function (offset, len, cb) {
store.read(offset, len, cb)
}
rad.close = function (cb) {
store.close(cb)
}
rad.end = function (opts, cb) {
store.end(opts, cb)
}
rad.unlink = function (cb) {
store.unlink(cb)
}
Object.defineProperty(rad, 'length', {
get: function () {
return store.length
}
})
return rad
}
return createRad
}