The simplest API for running code inside electron
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)
})
$ npm install --save electra
fn
can be a function with zero or one arguments or a function string.
Returns a Promise
.
MIT