uniswap-v2-loader 5.0.19 → 5.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +11 -10
- package/package.json +1 -1
- package/test-esm.mjs +0 -18
package/index.js
CHANGED
|
@@ -99,14 +99,10 @@ const load = (params = {}) => {
|
|
|
99
99
|
.then(() => pairs)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const missed = []
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
missed.push(ids)
|
|
107
|
-
}
|
|
108
|
-
ids.push(i)
|
|
109
|
-
}
|
|
102
|
+
const missed = Array(workers).fill(null).map(() => [])
|
|
103
|
+
|
|
104
|
+
for (var i = start_loading_from, iw = 0; i < all_pairs_length; i++)
|
|
105
|
+
missed[iw++ % workers].push(i)
|
|
110
106
|
|
|
111
107
|
cluster.setupPrimary({ exec: path.join(__dirname, 'loader.js') })
|
|
112
108
|
|
|
@@ -114,11 +110,16 @@ const load = (params = {}) => {
|
|
|
114
110
|
missed
|
|
115
111
|
.filter(_ => _.length)
|
|
116
112
|
.map((ids, i) => new Promise(y => {
|
|
113
|
+
if (abort_signal?.aborted) return y()
|
|
117
114
|
const w = cluster.fork()
|
|
118
|
-
|
|
115
|
+
const onabort = () => w.send('abort')
|
|
116
|
+
abort_signal?.addEventListener('abort', onabort, { once: true })
|
|
119
117
|
w.send({ ids, factory, key, multicall_size })
|
|
120
118
|
w.on('message', onpair)
|
|
121
|
-
w.on('exit',
|
|
119
|
+
w.on('exit', () => {
|
|
120
|
+
abort_signal?.removeEventListener('abort', onabort)
|
|
121
|
+
y()
|
|
122
|
+
})
|
|
122
123
|
}))
|
|
123
124
|
).then(() => pairs)
|
|
124
125
|
})
|
package/package.json
CHANGED
package/test-esm.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { load, subscribe } from './index.mjs'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { describe, it } from 'node:test'
|
|
4
|
-
|
|
5
|
-
describe('ESM Support', () => {
|
|
6
|
-
it('should import load and subscribe', () => {
|
|
7
|
-
assert.equal(typeof load, 'function')
|
|
8
|
-
assert.equal(typeof subscribe, 'function')
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('should load first pair', () =>
|
|
12
|
-
load({ to: 1 })
|
|
13
|
-
.then(pairs => {
|
|
14
|
-
assert.equal(pairs.length, 1)
|
|
15
|
-
assert.equal(pairs[0].id, 0)
|
|
16
|
-
})
|
|
17
|
-
)
|
|
18
|
-
})
|