🐛 Add support for TypedArrays in IPC.
Fixes https://github.com/electron/electron/issues/2104.
This commit is contained in:
parent
99ec841a8e
commit
c717cd9192
3 changed files with 29 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
const electron = require('electron')
|
||||
const v8Util = process.atomBinding('v8_util')
|
||||
const {ipcMain, isPromise, webContents} = electron
|
||||
const {ipcMain, isPromise, isTypedArray, webContents} = electron
|
||||
|
||||
const objectsRegistry = require('./objects-registry')
|
||||
|
||||
|
@ -63,6 +63,8 @@ let valueToMeta = function (sender, value, optimizeSimpleObject = false) {
|
|||
meta.type = 'buffer'
|
||||
} else if (Array.isArray(value)) {
|
||||
meta.type = 'array'
|
||||
} else if (isTypedArray(value.buffer)) {
|
||||
meta.type = 'typed-array'
|
||||
} else if (value instanceof Error) {
|
||||
meta.type = 'error'
|
||||
} else if (value instanceof Date) {
|
||||
|
@ -149,6 +151,8 @@ const unwrapArgs = function (sender, args) {
|
|||
return unwrapArgs(sender, meta.value)
|
||||
case 'buffer':
|
||||
return new Buffer(meta.value)
|
||||
case 'typed-array':
|
||||
return Buffer.from(meta.value)
|
||||
case 'date':
|
||||
return new Date(meta.value)
|
||||
case 'promise':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue