1.0.0 • Published 7 years ago

electra v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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