# electra

> The simplest API for running code inside electron

Latest version **1.0.0** (published 2017-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install electra
pnpm add electra
yarn add electra
bun add electra
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-04-26 |
| First published | 2017-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Maintainers | juliangruber |

## Links

- npm: https://www.npmjs.com/package/electra
- Repository: https://github.com/juliangruber/electra
- Homepage: https://github.com/juliangruber/electra#readme
- Issues: https://github.com/juliangruber/electra/issues
- npm.io page: https://npm.io/package/electra

## Dependencies (2)

- [electron-stream](https://npm.io/package/electron-stream.md) ^5.0.4
- [stream-to-string](https://npm.io/package/stream-to-string.md) ^1.1.0

## Recent versions

- 1.0.0 (latest) — 2017-04-26

## README

<div align="center">

# electra

#### The simplest API for running code inside electron!

![screenshot](screenshot.png)

</div>

## Features

* Full access to the DOM and browser APIs
* Synchronous and asynchronous code execution with Promise support
* Electron comes bundled!

## Usage

```js
const electra = require('electra')

// synchronous

electra(`
  return window.location.href
`)
.then(location => {
  console.log(location)
})

electra(() => {
  return window.location.href
})
.then(location => {
  console.log(location)
})

// promise

electra(() => {
  return fetch('/')
    .then(res => res.status)
})
.then(status => {
  console.log(status)
})

electra(`
  return fetch('/')
    .then(res => res.status)
`)
.then(status => {
  console.log(status)
})

// callback

electra(cb => {
  cb(null, window.location.href)
})
.then(location => {
  console.log(location)
})
```

## Installation

```bash
$ npm install --save electra
```

## API

### electra(fn)

`fn` can be a function with zero or one arguments or a function string.

Returns a `Promise`.

## License

MIT

---
_Source: https://npm.io/package/electra · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
