nodo 1.6.3 → 1.6.4
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.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/nodo/nodo.js +7 -3
- data/lib/nodo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4870340520e40bf14cf0e9261711983d5332eaf04419ff1281626ed5b4716e1
|
4
|
+
data.tar.gz: 162b5e4f6739728c91f64422acb579db9c004429f92402db5f393cfb76ffa675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbe6fb8dce3f39968b26800a28f50b7d2c1ac49ffc60537a50950af598bc329b6ae59fae2db8285b16167238448ef370502d7b6f736c4dc4e66563ae0050ccfd
|
7
|
+
data.tar.gz: 37dd504e71489566a9b57df0e217c2f25d09ce3d511dab2ac6daf849829b90f1293ed07dd4e320eb70ef573da7b466263c704bb99cf46cb555449a8253909089
|
data/README.md
CHANGED
@@ -91,6 +91,23 @@ class FooBar < Nodo::Core
|
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
94
|
+
### Dynamic ESM imports
|
95
|
+
|
96
|
+
ES modules can be imported dynamically using `nodo.import()`:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
class DynamicFoo < Nodo::Core
|
100
|
+
function :v4, <<~JS
|
101
|
+
async () => {
|
102
|
+
const uuid = await nodo.import('uuid');
|
103
|
+
return await uuid.v4()
|
104
|
+
}
|
105
|
+
JS
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
Note that the availability of dynamic imports depends on your Node version.
|
110
|
+
|
94
111
|
### Alternate function definition syntax
|
95
112
|
|
96
113
|
JS code can also be supplied using the `code:` keyword argument:
|
data/lib/nodo/nodo.js
CHANGED
@@ -9,7 +9,7 @@ module.exports = (function() {
|
|
9
9
|
const path = require('path');
|
10
10
|
const fs = require('fs');
|
11
11
|
const performance = require('perf_hooks').performance;
|
12
|
-
|
12
|
+
|
13
13
|
let server, closing;
|
14
14
|
const classes = {};
|
15
15
|
const contexts = {};
|
@@ -48,7 +48,11 @@ module.exports = (function() {
|
|
48
48
|
console.log(`[Nodo] ${message}`);
|
49
49
|
}
|
50
50
|
}
|
51
|
-
|
51
|
+
|
52
|
+
async function import_module(specifier) {
|
53
|
+
return await import(specifier);
|
54
|
+
}
|
55
|
+
|
52
56
|
const core = {
|
53
57
|
run: (socket) => {
|
54
58
|
debug('Starting up...');
|
@@ -135,5 +139,5 @@ module.exports = (function() {
|
|
135
139
|
}
|
136
140
|
};
|
137
141
|
|
138
|
-
return { core: core, debug: debug };
|
142
|
+
return { core: core, debug: debug, import: import_module };
|
139
143
|
})();
|
data/lib/nodo/version.rb
CHANGED