Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async toJSON(fields: string): Promise {
return await extractor.get(this, fields, {
onRead: async (data, key) => {
// Key can accept ":" separated arguments, so we have to make sure those are parsed.
const received = this.__parseKeyParams(key);
if (typeof data.getAttribute === "function") {
if (!data.getAttribute(received.key)) {
return [received.key];
}
return [
received.key,
await data.getAttribute(received.key).getJSONValue(...received.arguments)
];
}
return [received.key, await data[received.key]];
}
});