Browse Source

fix self/this issue

Kieran Gibb 2 years ago
parent
commit
5f0d161133
No known key found for this signature in database
1 changed files with 6 additions and 8 deletions
  1. 6
    8
      index.js

+ 6
- 8
index.js View File

@@ -76,17 +76,15 @@ class KappaDrive extends Nanoresource {
76 76
     this.vectorClock = {}
77 77
     this.log = opts.logger || debug('kappa-drive')
78 78
 
79
-    this._feeds.feeds().forEach(onfeed)
80
-    this._feeds.on('feed', onfeed)
81
-
82
-    var self = this
83
-
84
-    function onfeed (feed) {
85
-      if (self._indexer.feed(feed.key)) return
79
+    const onfeed = (feed) => {
80
+      if (this._indexer.feed(feed.key)) return
86 81
       scopeFeeds(feed, (err) => {
87
-        if (!err) self._indexer.add(feed, { scan: true })
82
+        if (!err) this._indexer.add(feed, { scan: true })
88 83
       })
89 84
     }
85
+
86
+    this._feeds.feeds().forEach(onfeed)
87
+    this._feeds.on('feed', onfeed)
90 88
   }
91 89
 
92 90
   ready (callback) {