Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const value = this.store.get(key)
if (value === undefined) {
return Promise.resolve(null)
}
switch (type) {
case 'text':
return Promise.resolve(value.toString())
case 'arrayBuffer':
return Promise.resolve(Uint8Array.from(value).buffer)
case 'json':
return Promise.resolve(JSON.parse(value.toString()))
case 'stream':
const { readable, writable } = new streams.TransformStream()
const writer = writable.getWriter()
writer.write(Uint8Array.from(value)).then(() => writer.close())
return Promise.resolve(readable)
}
}