@live-change/dao 0.5.10 → 0.5.11
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/lib/Dao.js +14 -4
- package/package.json +2 -2
- package/.github/workflows/npmpublish.yml +0 -31
package/lib/Dao.js
CHANGED
|
@@ -4,6 +4,15 @@ const ReactiveConnection = require("./ReactiveConnection.js")
|
|
|
4
4
|
const ObservableList = require("./ObservableList.js")
|
|
5
5
|
const debug = require('debug')('dao')
|
|
6
6
|
|
|
7
|
+
function isConstructor(f) {
|
|
8
|
+
try {
|
|
9
|
+
Reflect.construct(String, [], f);
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
class Dao extends EventEmitter {
|
|
8
17
|
constructor(credentials, definition) {
|
|
9
18
|
super()
|
|
@@ -25,10 +34,11 @@ class Dao extends EventEmitter {
|
|
|
25
34
|
const protocol = this.definition.protocols[proto]
|
|
26
35
|
if(!protocol) throw new Error("Protocol "+proto+" not supported")
|
|
27
36
|
debug("connecting to "+url)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
|
|
38
|
+
if(isConstructor(protocol)) {
|
|
39
|
+
connection = new protocol(this.credentials, url, defn.settings ?? this.definition.connectionSettings)
|
|
40
|
+
} else {
|
|
41
|
+
connection = protocol(this.credentials, url, defn.settings ?? this.definition.connectionSettings)
|
|
32
42
|
}
|
|
33
43
|
this.connections.set(connectionId, connection)
|
|
34
44
|
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: Node.js Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v1
|
|
12
|
-
- uses: actions/setup-node@v1
|
|
13
|
-
with:
|
|
14
|
-
node-version: 12
|
|
15
|
-
- run: npm ci
|
|
16
|
-
- run: npm test
|
|
17
|
-
|
|
18
|
-
publish-npm:
|
|
19
|
-
needs: build
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v1
|
|
23
|
-
- uses: actions/setup-node@v1
|
|
24
|
-
with:
|
|
25
|
-
node-version: 12
|
|
26
|
-
registry-url: https://registry.npmjs.org/
|
|
27
|
-
- run: npm ci
|
|
28
|
-
- run: npm publish
|
|
29
|
-
env:
|
|
30
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
|
31
|
-
|