Refactor to remove IDBFS & NODEFS, use Transferable to handle large files
This commit is contained in:
16
src/utils/getTransferables.js
Normal file
16
src/utils/getTransferables.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = (packet) => {
|
||||
const transferables = [];
|
||||
const check = (b) => {
|
||||
if (b instanceof Uint8Array) {
|
||||
transferables.push(b.buffer);
|
||||
} else if (b instanceof ArrayBuffer) {
|
||||
transferables.push(b);
|
||||
}
|
||||
};
|
||||
const { payload: { args, data } } = packet;
|
||||
check(data);
|
||||
if (Array.isArray(args)) {
|
||||
args.forEach((arg) => check(arg));
|
||||
}
|
||||
return transferables;
|
||||
};
|
||||
Reference in New Issue
Block a user