use lodash.js isEmpty , throw error: Value type not supported.
import { Worklets } from 'react-native-worklets-core';
import _ from 'lodash';
const dataStr = '{"test-1":"123"}';
const context = Worklets .defaultContext;
const res = await context.runAsync(()=>{
'worklet'
return JSON.parse(dataStr);
});
const testData = JSON.parse(dataStr);
_.isEmpty(testData) // sucess
try{
_.isEmpty(res) // throw error: Value type not supported.
}catch(e){
}
Not sure if I understand the difference between the two lines trying to call _.isEmpty(res) - they look the same to me except that the last one has a try..catch around it.
PS. I updated the code formatting a bit.
Could you try to explain a bit more in the description field?
Not sure if I understand the difference between the two lines trying to call
_.isEmpty(res)- they look the same to me except that the last one has a try..catch around it.PS. I updated the code formatting a bit.
Could you try to explain a bit more in the description field?
sorry , The code has been updated to address the above issue. One more problem: when executing runAsync, the method contains buffer , throw : array buffer is not supported as a shared value
I just added a test that verifies that JSON.parse returned from a worklet returns a correct JS object (and tested that _.isEmpty is working correctly). So I think this ticket is no longer valid / fixed already.