Assign Promise.resolve to constant
This commit is contained in:
parent
e0260d6f53
commit
dbe9893d29
2 changed files with 4 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
||||||
const {Buffer} = require('buffer')
|
const {Buffer} = require('buffer')
|
||||||
const v8Util = process.atomBinding('v8_util')
|
const v8Util = process.atomBinding('v8_util')
|
||||||
const {ipcRenderer, isPromise, CallbacksRegistry} = require('electron')
|
const {ipcRenderer, isPromise, CallbacksRegistry} = require('electron')
|
||||||
|
const resolvePromise = Promise.resolve.bind(Promise)
|
||||||
|
|
||||||
const callbacksRegistry = new CallbacksRegistry()
|
const callbacksRegistry = new CallbacksRegistry()
|
||||||
|
|
||||||
|
@ -207,9 +208,7 @@ const metaToValue = function (meta) {
|
||||||
case 'buffer':
|
case 'buffer':
|
||||||
return Buffer.from(meta.value)
|
return Buffer.from(meta.value)
|
||||||
case 'promise':
|
case 'promise':
|
||||||
return Promise.resolve({
|
return resolvePromise({then: metaToValue(meta.then)})
|
||||||
then: metaToValue(meta.then)
|
|
||||||
})
|
|
||||||
case 'error':
|
case 'error':
|
||||||
return metaToPlainObject(meta)
|
return metaToPlainObject(meta)
|
||||||
case 'date':
|
case 'date':
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
const events = require('events')
|
const events = require('events')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const Module = require('module')
|
const Module = require('module')
|
||||||
|
const resolvePromise = Promise.resolve.bind(Promise)
|
||||||
|
|
||||||
// We modified the original process.argv to let node.js load the
|
// We modified the original process.argv to let node.js load the
|
||||||
// atom-renderer.js, we need to restore it here.
|
// atom-renderer.js, we need to restore it here.
|
||||||
|
@ -39,7 +40,7 @@ electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_SYNC_WEB_FRAME_METHOD', (eve
|
||||||
|
|
||||||
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
||||||
const responseCallback = function (result) {
|
const responseCallback = function (result) {
|
||||||
Promise.resolve(result)
|
resolvePromise(result)
|
||||||
.then((resolvedResult) => {
|
.then((resolvedResult) => {
|
||||||
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, null, resolvedResult)
|
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, null, resolvedResult)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue