Set prototype of constructor directly

This commit is contained in:
Cheng Zhao 2016-08-02 20:38:35 +09:00
parent 8c3232dc56
commit 844f32aa36
19 changed files with 84 additions and 158 deletions

View file

@ -1,7 +1,7 @@
'use strict'
const bindings = process.atomBinding('app')
const {app} = bindings
const {app, App} = bindings
// Only one app object permitted.
module.exports = app
@ -10,7 +10,7 @@ const electron = require('electron')
const {deprecate, Menu} = electron
const {EventEmitter} = require('events')
Object.setPrototypeOf(app.__proto__, EventEmitter.prototype)
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
let appPath = null
@ -76,7 +76,5 @@ for (let name of events) {
}
// Wrappers for native classes.
process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => {
// downloadItem is an EventEmitter.
Object.setPrototypeOf(downloadItem.__proto__, EventEmitter.prototype)
})
const {DownloadItem} = process.atomBinding('download_item')
Object.setPrototypeOf(DownloadItem.prototype, EventEmitter.prototype)