1
- var config = require ( './config' )
2
- var IPFSRepo = require ( 'ipfs-repo' )
1
+ 'use strict'
2
+
3
+ const config = require ( './config' )
4
+ const IPFSRepo = require ( 'ipfs-repo' )
3
5
4
6
exports = module . exports = IPFS
5
7
exports . config = config
6
8
7
9
function IPFS ( ) {
8
- var self = this
9
-
10
- if ( ! ( self instanceof IPFS ) ) {
10
+ if ( ! ( this instanceof IPFS ) ) {
11
11
throw new Error ( 'Must be instantiated with new' )
12
12
}
13
13
14
14
var repo = new IPFSRepo ( config . repoPath )
15
15
16
- self . daemon = function ( callback ) {
16
+ this . daemon = ( callback ) => {
17
17
// 1. read repo to get peer data
18
18
}
19
19
20
- self . version = function ( opts , callback ) {
20
+ this . version = ( opts , callback ) => {
21
21
if ( typeof opts === 'function' ) {
22
22
callback = opts
23
23
opts = { }
24
24
}
25
25
26
- repo . exists ( function ( err , exists ) {
26
+ repo . exists ( ( err , exists ) => {
27
27
if ( err ) { return callback ( err ) }
28
28
29
- repo . config . get ( function ( err , config ) {
29
+ repo . config . get ( ( err , config ) => {
30
30
if ( err ) { return callback ( err ) }
31
31
32
32
callback ( null , config . Version . Current )
33
33
} )
34
34
} )
35
35
}
36
36
37
- self . id = function ( opts , callback ) {
37
+ this . id = ( opts , callback ) => {
38
38
if ( typeof opts === 'function' ) {
39
39
callback = opts
40
40
opts = { }
41
41
}
42
- repo . exists ( function ( err , exists ) {
43
- if ( err ) {
44
- return callback ( err )
45
- }
42
+ repo . exists ( ( err , exists ) => {
43
+ if ( err ) { return callback ( err ) }
46
44
47
- repo . config . read ( function ( err , config ) {
45
+ repo . config . read ( ( err , config ) => {
48
46
if ( err ) {
49
47
return callback ( err )
50
48
}
@@ -60,20 +58,18 @@ function IPFS () {
60
58
} )
61
59
}
62
60
63
- self . repo = {
64
- init : function ( bits , force , empty , callback ) {
61
+ this . repo = {
62
+ init : ( bits , force , empty , callback ) => {
65
63
// 1. check if repo already exists
66
64
} ,
67
65
68
- version : function ( opts , callback ) {
66
+ version : ( opts , callback ) => {
69
67
if ( typeof opts === 'function' ) {
70
68
callback = opts
71
69
opts = { }
72
70
}
73
- repo . exists ( function ( err , res ) {
74
- if ( err ) {
75
- return callback ( err )
76
- }
71
+ repo . exists ( ( err , res ) => {
72
+ if ( err ) { return callback ( err ) }
77
73
repo . version . read ( callback )
78
74
} )
79
75
} ,
0 commit comments