]> khamidou — GitHub mirrors - electron.git/commitdiff
Don't hard-code API names
authorCheng Zhao <zcbenz@gmail.com>
Wed, 14 Jan 2015 00:27:58 +0000 (16:27 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 16 Jan 2015 19:01:38 +0000 (11:01 -0800)
atom/common/api/lib/screen.coffee

index e2913fcb8a9360230b982ad36ed6de12d761a587..bef5649d0f0943a61679ac9926372429d1080426 100644 (file)
@@ -4,14 +4,12 @@ checkAppIsReady = ->
   unless process.type is 'renderer' or require('app').isReady()
     throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
 
-module.exports =
-  if process.platform in ['linux', 'win32'] and process.type is 'renderer'
-    # On Linux we could not access screen in renderer process.
-    require('remote').require 'screen'
-  else
-    getCursorScreenPoint: ->
-      checkAppIsReady()
-      binding.getCursorScreenPoint()
-    getPrimaryDisplay: ->
-      checkAppIsReady()
-      binding.getPrimaryDisplay()
+if process.platform in ['linux', 'win32'] and process.type is 'renderer'
+  # On Linux and Windows we could not access screen in renderer process.
+  module.exports = require('remote').require 'screen'
+else
+  for name, _ of binding
+    do (name) ->
+      module.exports[name] = (args...) ->
+        checkAppIsReady()
+        binding[name](args...)