Full Code of delvedor/electron-is for AI

master 5f55f967fda5 cached
9 files
16.1 KB
4.6k tokens
3 symbols
1 requests
Download .txt
Repository: delvedor/electron-is
Branch: master
Commit: 5f55f967fda5
Files: 9
Total size: 16.1 KB

Directory structure:
gitextract_s8uz5w5z/

├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── is.d.ts
├── is.js
├── package.json
└── test/
    ├── assertions.js
    └── headless-test.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# mac files
.DS_Store

# vim swap files
*.swp

# locks
package-lock.json


================================================
FILE: .travis.yml
================================================
language: node_js

env:
  - NODE=6

os:
  - linux
  - osx

addons:
  apt:
    packages:
      - xvfb

install:
  - rm -rf ~/.nvm
  - git clone https://github.com/creationix/nvm.git ~/.nvm
  - source ~/.nvm/nvm.sh
  - nvm install $NODE
  - nvm --version
  - node --version
  - npm --version
  - npm install

script:
  - npm test


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2016 Tomas Della Vedova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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 NONINFRINGEMENT. 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.


================================================
FILE: README.md
================================================
# electron-is
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/delvedor/electron-is.svg?branch=master)](https://travis-ci.org/delvedor/electron-is)

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 <a href="#usage">usage</a> for more information.

## Install
```
$ npm install electron-is --save
```

## API

- **is.renderer()**  
Returns `true` if you are calling the function from the renderer process.

- **is.main()**  
Returns `true` if you are calling the function from the main process.

- **is.macOS()** *aliases* **is.osx()**  
Returns `true` if your app is running under Mac OS.

- **is.windows()**  
Returns `true` if your app is running under Windows OS.

- **is.linux()**  
Returns `true` if your app is running under Linux OS.

- **is.x86()**  
Returns `true` if you the architecture of the processor is `ia32`.

- **is.x64()**  
Returns `true` if you the architecture of the processor is `x64`.

- **is.production()**  
Returns `true` if you are running the app in a `production` environment.

- **is.dev()**  
Returns `true` if you are running the app in a `dev` environment.

- **is.sandbox()** *only* ***macOS***  
Returns `true` if you are running the app in a `sandbox` environment under macOS.

- **is.mas()**  
Returns `true` if the app is running as a Mac App Store build.

- **is.windowsStore()**  
Returns `true` if the app is running as a Windows Store (appx) build.

- **is.all(args)**  
Returns `true` if all the 'is functions' passed as argument are true.  
example: `is.all(is.osx, is.x64)`

- **is.none(args)**  
Returns `true` if all the 'is functions' passed as argument are false.  
example: `is.none(is.windows, is.x86, is.main)`

- **is.one(args)**  
Returns `true` if 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](https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history) 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](https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions) release you must pass the NT release, it can be *x.y* or *x.y.build* .

\* *Not implemented for Linux yet*

<a name="usage"></a>
## Usage
- In Main process:
```javascript
// es6
import is from 'electron-is'
// es5
const is = require('electron-is')
console.log(is.main())
```
- In Renderer process:
```html
<script>
    const is = require('electron-is')
    console.log(is.renderer())
</script>
```
## Acknowledgements
`electron-is` makes use of [electron-is-dev](https://github.com/sindresorhus/electron-is-dev) package from [@sindresorhus](https://github.com/sindresorhus).

## Contributing
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.  
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
______________________________________________________________________________________________________________________
## License
**[MIT](https://github.com/delvedor/electron-is/blob/master/LICENSE)**

*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


================================================
FILE: is.d.ts
================================================
declare namespace is {
  export function renderer(): boolean;
  export function main(): boolean;
  export function osx(): boolean;
  export function macOS(): boolean;
  export function windows(): boolean;
  export function linux(): boolean;
  export function x86(): boolean;
  export function x64(): boolean;
  export function production(): boolean;
  export function dev(): boolean;
  export function sandbox(): boolean;
  export function mas(): boolean;
  export function windowsStore(): boolean;
  export function all(): boolean;
  export function none(): boolean;
  export function one(): boolean;
  export function release(requested: string): boolean;
  export function gtRelease(requested: string): boolean;
  export function ltRelease(requested: string): boolean;
}
declare function is (): any;
export = is;


================================================
FILE: is.js
================================================
/*
 * Project: electron-is
 * Version: 3.0.0
 * Author: delvedor
 * Twitter: @delvedor
 * License: MIT
 * GitHub: https://github.com/delvedor/electron-is
 */
'use strict'

const semver = require('semver')
const gt = semver.gt
const lt = semver.lt
const release = require('os').release
const isDev = require('electron-is-dev')

module.exports = {
  // Checks if we are in renderer process
  renderer: function () {
    return process.type === 'renderer'
  },
  // Checks if we are in main process
  main: function () {
    return process.type === 'browser'
  },
  // Checks if we are under Mac OS
  osx: function () {
    return process.platform === 'darwin'
  },
  // Checks if we are under Mac OS
  macOS: function () {
    return this.osx()
  },
  // Checks if we are under Windows OS
  windows: function () {
    return process.platform === 'win32'
  },
  // Checks if we are under Linux OS
  linux: function () {
    return process.platform === 'linux'
  },
  // Checks if we are the processor's arch is x86
  x86: function () {
    return process.arch === 'ia32'
  },
  // Checks if we are the processor's arch is x64
  x64: function () {
    return process.arch === 'x64'
  },
  // Checks if the env is setted to 'production'
  production: function () {
    return !isDev
  },
  // Checks if the env is setted to 'dev'
  dev: function () {
    return isDev
  },
  // Checks if the app is running in a sandbox on macOS
  sandbox: function () {
    return 'APP_SANDBOX_CONTAINER_ID' in process.env
  },
  // Checks if the app is running as a Mac App Store build
  mas: function () {
    return process.mas === true
  },
  // Checks if the app is running as a Windows Store (appx) build
  windowsStore: function () {
    return process.windowsStore === true
  },
  // checks if all the 'is functions' passed as arguments are true
  all: function () {
    const isFunctions = new Array(arguments.length)
    for (var i = 0; i < isFunctions.length; i++) {
      isFunctions[i] = arguments[i]
    }
    if (!isFunctions.length) return
    for (i = 0; i < isFunctions.length; i++) {
      if (!isFunctions[i]()) return false
    }
    return true
  },
  // checks if all the 'is functions' passed as arguments are false
  none: function () {
    const isFunctions = new Array(arguments.length)
    for (var i = 0; i < isFunctions.length; i++) {
      isFunctions[i] = arguments[i]
    }
    if (!isFunctions.length) return
    for (i = 0; i < isFunctions.length; i++) {
      if (isFunctions[i]()) return false
    }
    return true
  },
  // returns true if one of the 'is functions' passed as argument is true
  one: function () {
    const isFunctions = new Array(arguments.length)
    for (var i = 0; i < isFunctions.length; i++) {
      isFunctions[i] = arguments[i]
    }
    if (!isFunctions.length) return
    for (i = 0; i < isFunctions.length; i++) {
      if (isFunctions[i]()) return true
    }
    return false
  },
  // checks the if the given release is the same of the OS
  release: function (requested) {
    if (this.osx()) {
      return requested === osxRelease()
    } else if (this.windows()) {
      requested = requested.split('.')
      const actual = release().split('.')
      if (requested.length === 2) {
        return `${actual[0]}.${actual[1]}` === `${requested[0]}.${requested[1]}`
      }
      return `${actual[0]}.${actual[1]}.${actual[2]}` === `${requested[0]}.${requested[1]}.${requested[2]}`
    } else {
      // Not implemented for Linux yet
      return null
    }
  },
  // checks if the given release is greater than the current OS release
  gtRelease: function (requested) {
    if (this.osx()) {
      return gt(requested, osxRelease())
    } else if (this.windows()) {
      requested = requested.split('.')
      const actual = release().split('.')
      if (requested.length === 2) {
        return gt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
      }
      return gt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
    } else {
      // Not implemented for Linux yet
      return null
    }
  },
  // checks if the given release is less than the current OS release
  ltRelease: function (requested) {
    if (this.osx()) {
      return lt(requested, osxRelease())
    } else if (this.windows()) {
      requested = requested.split('.')
      const actual = release().split('.')
      if (requested.length === 2) {
        return lt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
      }
      return lt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
    } else {
      // Not implemented for Linux yet
      return null
    }
  }
}

// returns the current osx release
function osxRelease () {
  const actual = release().split('.')
  return `10.${actual[0] - 4}.${actual[1]}`
}


================================================
FILE: package.json
================================================
{
  "name": "electron-is",
  "version": "3.0.0",
  "description": "An 'is' utility for Electron which provides a set of handy functions, with a self-descriptive name.",
  "main": "is.js",
  "scripts": {
    "pretest": "standard",
    "test": "node test/headless-test.js"
  },
  "keywords": [
    "platform",
    "type",
    "process",
    "arch",
    "env",
    "electron",
    "os",
    "release",
    "is",
    "main",
    "renderer"
  ],
  "author": "Tomas Della Vedova - @delvedor (http://delved.org)",
  "contributors": [
    "Masoud Ghorbani <msud.ghorbani@gmail.com> (http://msud.ir)"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/delvedor/electron-is.git"
  },
  "bugs": {
    "url": "https://github.com/delvedor/electron-is/issues"
  },
  "homepage": "https://github.com/delvedor/electron-is#readme",
  "devDependencies": {
    "electron-eval": "^0.9.10",
    "standard": "^11.0.1"
  },
  "dependencies": {
    "electron-is-dev": "^0.3.0",
    "semver": "^5.5.0"
  }
}


================================================
FILE: test/assertions.js
================================================
'use strict'

const assert = require('assert')
const release = require('os').release
const path = require('path')
const is = require(path.join(__dirname, '..', '..', '..', 'is'))

function assertions () {
  assert.equal(is.main(), process.type === 'browser', 'is.main() not ok!')
  assert.equal(is.renderer(), process.type === 'renderer', 'is.renderer() not ok!')

  assert.equal(is.osx(), process.platform === 'darwin', 'is.osx() not ok!')
  assert.equal(is.macOS(), process.platform === 'darwin', 'is.macOS() not ok!')
  assert.equal(is.windows(), process.platform === 'win32', 'is.windows() not ok!')
  assert.equal(is.linux(), process.platform === 'linux', 'is.linux() not ok!')

  assert.equal(is.x86(), process.arch === 'ia32', 'is.x86() not ok!')
  assert.equal(is.x64(), process.arch === 'x64', 'is.x64() not ok!')

  assert.equal(is.production(), (process.env.NODE_ENV || 'dev') === 'production', 'is.production() not ok!')
  assert.equal(is.dev(), (process.env.NODE_ENV || 'dev') === 'dev', 'is.dev() not ok!')

  assert.equal(is.sandbox(), ('APP_SANDBOX_CONTAINER_ID' in process.env), 'is.sandbox() not ok!')
  assert.equal(is.mas(), process.mas === true, 'is.mas() not ok!')
  assert.equal(is.windowsStore(), process.windowsStore === true, 'is.windowsStore() not ok!')

  assert.equal(is.all(is.osx, is.x64), is.osx() && is.x64(), 'is.all() 1 not ok!')
  assert.equal(is.all(is.osx, is.x86), is.osx() && is.x86(), 'is.all() 2 not ok!')
  assert.equal(is.none(is.windows, is.x86), !is.windows() && !is.x86(), 'is.none() 1 not ok!')
  assert.equal(is.none(is.windows, is.x64), !is.windows() && !is.x64(), 'is.none() 2 not ok!')
  assert.equal(is.one(is.windows, is.osx), is.windows() || is.osx(), 'is.one() 1 not ok!')
  assert.equal(is.one(is.windows, is.linux), is.windows() || is.linux(), 'is.one() 2 not ok!')

  if (is.osx()) {
    const osx = osxRelease()
    // mac el capitan
    assert.equal(is.release(osx), true, 'is.release() not ok!')

    assert.equal(is.gtRelease(osx), false, 'is.gtRelease() 1 not ok!')
    assert.equal(is.gtRelease('100.100.100'), true, 'is.gtRelease() 2 not ok!')
    assert.equal(is.gtRelease('1.0.0'), false, 'is.gtRelease() 3 not ok!')

    assert.equal(is.ltRelease(osx), false, 'is.ltRelease() 1 not ok!')
    assert.equal(is.ltRelease('100.100.100'), false, 'is.ltRelease() 2 not ok!')
    assert.equal(is.ltRelease('1.0.0'), true, 'is.ltRelease() 3 not ok!')
  } else if (is.windows()) {
    // tests Windows 10 AU
    assert.equal(is.release('10.0'), true, 'is.release() not ok!')
    assert.equal(is.release('10.0.14393'), true, 'is.release() not ok!')
  } else {
    assert.equal(is.release('1.2.3'), null, 'is.release() not ok!')
  }

  return true
}

// returns the current osx release
function osxRelease () {
  const actual = release().split('.')
  return `10.${actual[0] - 4}.${actual[1]}`
}

assertions()


================================================
FILE: test/headless-test.js
================================================
'use strict'

const fs = require('fs')
const electronEval = require('electron-eval')

const assertions = fs.readFileSync('./test/assertions.js', 'utf8')
const daemon = electronEval()

;(function test (options) {
  daemon.eval(assertions, { mainProcess: options.main }, (err, res) => {
    if (err) {
      console.log(err.message)
      process.exit(1)
    }
    if (options.main) {
      test({ main: false })
    } else {
      daemon.close()
      console.log('All test passed!')
      process.exit(0)
    }
  })
})({ main: true })
Download .txt
gitextract_s8uz5w5z/

├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── is.d.ts
├── is.js
├── package.json
└── test/
    ├── assertions.js
    └── headless-test.js
Download .txt
SYMBOL INDEX (3 symbols across 2 files)

FILE: is.js
  function osxRelease (line 157) | function osxRelease () {

FILE: test/assertions.js
  function assertions (line 8) | function assertions () {
  function osxRelease (line 58) | function osxRelease () {
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (17K chars).
[
  {
    "path": ".gitignore",
    "chars": 615,
    "preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n\n# Directory for instrumented libs generated by jscov"
  },
  {
    "path": ".travis.yml",
    "chars": 328,
    "preview": "language: node_js\n\nenv:\n  - NODE=6\n\nos:\n  - linux\n  - osx\n\naddons:\n  apt:\n    packages:\n      - xvfb\n\ninstall:\n  - rm -r"
  },
  {
    "path": "LICENSE",
    "chars": 1085,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2016 Tomas Della Vedova\n\nPermission is hereby granted, free of charge, to any perso"
  },
  {
    "path": "README.md",
    "chars": 4305,
    "preview": "# electron-is\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http"
  },
  {
    "path": "is.d.ts",
    "chars": 815,
    "preview": "declare namespace is {\n  export function renderer(): boolean;\n  export function main(): boolean;\n  export function osx()"
  },
  {
    "path": "is.js",
    "chars": 4864,
    "preview": "/*\n * Project: electron-is\n * Version: 3.0.0\n * Author: delvedor\n * Twitter: @delvedor\n * License: MIT\n * GitHub: https:"
  },
  {
    "path": "package.json",
    "chars": 1029,
    "preview": "{\n  \"name\": \"electron-is\",\n  \"version\": \"3.0.0\",\n  \"description\": \"An 'is' utility for Electron which provides a set of "
  },
  {
    "path": "test/assertions.js",
    "chars": 2867,
    "preview": "'use strict'\n\nconst assert = require('assert')\nconst release = require('os').release\nconst path = require('path')\nconst "
  },
  {
    "path": "test/headless-test.js",
    "chars": 535,
    "preview": "'use strict'\n\nconst fs = require('fs')\nconst electronEval = require('electron-eval')\n\nconst assertions = fs.readFileSync"
  }
]

About this extraction

This page contains the full source code of the delvedor/electron-is GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 9 files (16.1 KB), approximately 4.6k tokens, and a symbol index with 3 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!