An 'is' utility for Electron.
electron-is provides a set of isomorphic 'is' APIs, that you can use it both in main and renderer process.
See usage for more information.
$ npm install electron-is --save
-
is.renderer()
Returnstrueif you are calling the function from the renderer process. -
is.main()
Returnstrueif you are calling the function from the main process. -
is.macOS() aliases is.osx()
Returnstrueif your app is running under Mac OS. -
is.windows()
Returnstrueif your app is running under Windows OS. -
is.linux()
Returnstrueif your app is running under Linux OS. -
is.x86()
Returnstrueif you the architecture of the processor isia32. -
is.x64()
Returnstrueif you the architecture of the processor isx64. -
is.production()
Returnstrueif you are running the app in aproductionenvironment. -
is.dev()
Returnstrueif you are running the app in adevenvironment. -
is.sandbox() only macOS
Returnstrueif you are running the app in asandboxenvironment under macOS. -
is.mas()
Returnstrueif the app is running as a Mac App Store build. -
is.windowsStore()
Returnstrueif the app is running as a Windows Store (appx) build. -
is.all(args)
Returnstrueif all the 'is functions' passed as argument are true.
example:is.all(is.osx, is.x64) -
is.none(args)
Returnstrueif all the 'is functions' passed as argument are false.
example:is.none(is.windows, is.x86, is.main) -
is.one(args)
Returnstrueif one of the 'is functions' passed as argument is true.
example:is.one(is.osx, is.linux) -
is.release(args)
Checks the if the given release is the same of the OS (*)
example:is.release('10.0.10586') -
is.gtRelease(args)
Checks if the given release is greater than the current OS release (*)
example:is.gtRelease('10.9.5') -
is.ltRelease(args)
Checks if the given release is less than the current OS release (*)
example:is.ltRelease('6.3')
The Mac versions are mapped as osx: darwin, you must pass the 9.x.y or 10.x.y OSX version as argument and not the darwin version.
If you are testing a Windows release you must pass the NT release, it can be x.y or x.y.build .
* Not implemented for Linux yet
- In Main process:
// es6
import is from 'electron-is'
// es5
const is = require('electron-is')
console.log(is.main())- In Renderer process:
<script>
const is = require('electron-is')
console.log(is.renderer())
</script>electron-is makes use of electron-is-dev package from @sindresorhus.
If you feel you can help in any way, be it with examples, extra testing, or new features please open a pull request or open an issue.
The code follows the Standard code style.
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
Copyright © 2016 Tomas Della Vedova