sptc 0.0.12 → 0.0.14
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/bin/sptcd.js +1 -1
- package/engine/index.js +1 -1
- package/engine/interpreter.js +7 -1
- package/package.json +1 -1
- package/utils/base.js +10 -0
package/bin/sptcd.js
CHANGED
package/engine/index.js
CHANGED
package/engine/interpreter.js
CHANGED
|
@@ -2,7 +2,7 @@ const _module=require('module')
|
|
|
2
2
|
const vm=require('vm')
|
|
3
3
|
const path=require('path')
|
|
4
4
|
const Compiler=require('./compiler')
|
|
5
|
-
const {generate_uuid}=require('../utils')
|
|
5
|
+
const {generate_uuid, PromiseWithResolvers}=require('../utils')
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
const tt={x: 2, b: [2, 5], c: _=>2, d: /xx/ig}
|
|
@@ -190,6 +190,11 @@ function buildContext(ctx0, option) {
|
|
|
190
190
|
}
|
|
191
191
|
priv.syncs.push(...x)
|
|
192
192
|
},
|
|
193
|
+
Lock: _=>{
|
|
194
|
+
const lock=PromiseWithResolvers()
|
|
195
|
+
priv.syncs.push(lock.promise)
|
|
196
|
+
return _=>lock.resolve()
|
|
197
|
+
},
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
ctx.defer=fn=>{
|
|
@@ -313,6 +318,7 @@ function executeVm(vm, ctx, priv) {
|
|
|
313
318
|
onError(e)
|
|
314
319
|
}
|
|
315
320
|
|
|
321
|
+
if(!isMaster) return;
|
|
316
322
|
for(let fn of priv._defers.splice(0)) {
|
|
317
323
|
try{
|
|
318
324
|
fn()
|
package/package.json
CHANGED
package/utils/base.js
CHANGED
|
@@ -53,6 +53,15 @@ function getLocalIpv4Addresses() {
|
|
|
53
53
|
return Object.keys(rr)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function PromiseWithResolvers() {
|
|
57
|
+
let _resolve, _reject
|
|
58
|
+
const promise=new Promise((resolve, reject)=>{
|
|
59
|
+
_resolve=resolve
|
|
60
|
+
_reject=reject
|
|
61
|
+
})
|
|
62
|
+
return {promise, resolve: _resolve, reject: _reject}
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
module.exports={
|
|
57
66
|
readTextFile,
|
|
58
67
|
mtime,
|
|
@@ -62,4 +71,5 @@ module.exports={
|
|
|
62
71
|
generate_uuid,
|
|
63
72
|
getExtension,
|
|
64
73
|
getLocalIpv4Addresses,
|
|
74
|
+
PromiseWithResolvers,
|
|
65
75
|
}
|