wspromisify 2.4.4 → 2.5.0
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/LICENSE +1 -1
- package/README.md +1 -2
- package/TODO +9 -0
- package/dist/bundle.cjs +1 -1
- package/dist/bundle.d.ts +7 -2
- package/dist/bundle.mjs +1 -1
- package/package.json +91 -94
- package/rollup.config.js +1 -1
- package/src/WSC.ts +271 -0
- package/src/config.ts +7 -6
- package/src/utils.ts +5 -23
- package/test/index.ts +21 -0
- package/test/mock/WS.ts +43 -0
- package/test/mock/server.ts +17 -0
- package/test/specs/close.ts +18 -0
- package/test/specs/drops.ts +30 -0
- package/test/specs/echo.ts +24 -0
- package/test/specs/encode-decode.ts +1 -0
- package/test/specs/existing_socket.ts +55 -0
- package/test/specs/lazy.ts +22 -0
- package/test/specs/lazySendBeforeOpen.ts +19 -0
- package/test/specs/no-native-throws.ts +18 -0
- package/test/specs/ready.ts +12 -0
- package/test/specs/reconnect.ts +23 -0
- package/test/specs/socket.ts +13 -0
- package/test/suite.ts +3 -0
- package/test/utils.ts +27 -0
- package/tsconfig.json +3 -2
- package/src/WS.ts +0 -166
- package/src/connectLib.ts +0 -120
- package/test/mock/WS.js +0 -51
- package/test/mock/index.js +0 -52
- package/test/specs/close.js +0 -25
- package/test/specs/drops.js +0 -29
- package/test/specs/echo.js +0 -26
- package/test/specs/encode-decode.js +0 -3
- package/test/specs/existing_socket.js +0 -55
- package/test/specs/lazy.js +0 -26
- package/test/specs/ready.js +0 -16
- package/test/specs/reconnect.js +0 -28
- package/test/specs/sendBeforeOpen.js +0 -23
- package/test/specs/socket.js +0 -22
- package/test/specs/utils_once.js +0 -16
- package/test/utils.js +0 -27
package/test/specs/utils_once.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import test from 'ava'
|
|
2
|
-
import mockServer from '../mock/index.js'
|
|
3
|
-
import { once as onceTest } from '../../src/utils'
|
|
4
|
-
|
|
5
|
-
/** Utils::once should cache a result and call a func just once. */
|
|
6
|
-
test.serial('once', (t) => {
|
|
7
|
-
return new Promise(async (ff) => {
|
|
8
|
-
await mockServer()
|
|
9
|
-
const fn = (a) => a*2
|
|
10
|
-
const cached = onceTest(fn)
|
|
11
|
-
|
|
12
|
-
t.is(cached(5), cached(10))
|
|
13
|
-
t.is(cached(25), 10)
|
|
14
|
-
return ff()
|
|
15
|
-
})
|
|
16
|
-
})
|
package/test/utils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import WSP from '../dist/bundle.mjs'
|
|
3
|
-
import axios from 'axios'
|
|
4
|
-
import WS from 'ws'
|
|
5
|
-
|
|
6
|
-
const turnOn = async (port = 8095) => {
|
|
7
|
-
await axios.get('http://127.0.0.1:8085/on/' + port)
|
|
8
|
-
return true
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const shutDown = async (port = 8095) => {
|
|
12
|
-
await axios.get('http://127.0.0.1:8085/off/' + port)
|
|
13
|
-
return true
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const createNew = async (config = {}, port = 8095) => {
|
|
17
|
-
await turnOn(port)
|
|
18
|
-
const ws = new WSP(Object.assign({
|
|
19
|
-
url: '127.0.0.1:' + port,
|
|
20
|
-
// log: (...a) => console.log(...a),
|
|
21
|
-
adapter: (host, protocols) => new WS(host, protocols)
|
|
22
|
-
}, config))
|
|
23
|
-
|
|
24
|
-
return ws
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { createNew, turnOn, shutDown }
|