🐛 Add support for TypedArrays in IPC.

Fixes https://github.com/electron/electron/issues/2104.
This commit is contained in:
haad 2016-07-22 19:44:19 +01:00
parent 99ec841a8e
commit c717cd9192
3 changed files with 29 additions and 2 deletions

View file

@ -1,7 +1,7 @@
'use strict'
const v8Util = process.atomBinding('v8_util')
const {ipcRenderer, isPromise, CallbacksRegistry} = require('electron')
const {ipcRenderer, isPromise, isTypedArray, CallbacksRegistry} = require('electron')
const callbacksRegistry = new CallbacksRegistry()
@ -35,6 +35,11 @@ const wrapArgs = function (args, visited) {
type: 'buffer',
value: Array.prototype.slice.call(value, 0)
}
} else if (isTypedArray(value.buffer)) {
return {
type: 'typed-array',
value: Array.prototype.slice.call(value)
}
} else if (value instanceof Date) {
return {
type: 'date',
@ -164,6 +169,8 @@ const metaToValue = function (meta) {
return results
case 'buffer':
return new Buffer(meta.value)
case 'typed-array':
return Buffer.from(meta.value)
case 'promise':
return Promise.resolve({
then: metaToValue(meta.then)