Socket
Book a DemoInstallSign in
Socket

electra

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electra

The simplest API for running code inside electron

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

electra

The simplest API for running code inside electron!

screenshot

Features

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

Usage

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

$ 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

FAQs

Package last updated on 26 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts