fix: getRequestVar shim, boolean values in vm (#2887)

This commit is contained in:
lohit 2024-08-22 10:10:15 +05:30 committed by GitHub
parent e31c552dee
commit 4aff61b665
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -63,6 +63,12 @@ const addBruShimToContext = (vm, bru) => {
vm.setProp(bruObject, 'getSecretVar', getSecretVar); vm.setProp(bruObject, 'getSecretVar', getSecretVar);
getSecretVar.dispose(); getSecretVar.dispose();
let getRequestVar = vm.newFunction('getRequestVar', function (key) {
return marshallToVm(bru.getRequestVar(vm.dump(key)), vm);
});
vm.setProp(bruObject, 'getRequestVar', getRequestVar);
getRequestVar.dispose();
const sleep = vm.newFunction('sleep', (timer) => { const sleep = vm.newFunction('sleep', (timer) => {
const t = vm.getString(timer); const t = vm.getString(timer);
const promise = vm.newPromise(); const promise = vm.newPromise();

View File

@ -10,7 +10,7 @@ const marshallToVm = (value, vm) => {
} else if (typeof value === 'number') { } else if (typeof value === 'number') {
return vm.newNumber(value); return vm.newNumber(value);
} else if (typeof value === 'boolean') { } else if (typeof value === 'boolean') {
return vm.newBoolean(value); return value ? vm.true : vm.false;
} else if (typeof value === 'object') { } else if (typeof value === 'object') {
if (Array.isArray(value)) { if (Array.isArray(value)) {
const arr = vm.newArray(); const arr = vm.newArray();