-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
64 lines (58 loc) · 1.2 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const ipc = require('electron').ipcRenderer
// Messaging
// Quit function
const quit = () => ipc.send('msg', 'quit')
/*
Execute function
c: command to execute
*/
// const exec = c => {
// ipc.send('exec', c)
// }
/*
Node processes in order to keep everything in the "back end"
exec: sends 'exec' message for spawning and executing
c = command to execute
fs: sends 'fs' message for file system functions
f = file system function
args = arguments to be used
*/
const node = {
exec: c => ipc.send('exex', c),
fs: (f, ...args) => ipc.send('fs', args)
}
const isLetter = (val) => {
if (typeof val !== 'string') return false
val = val.toLowerCase()
return (
val === 'a' ||
val === 'b' ||
val === 'c' ||
val === 'd' ||
val === 'e' ||
val === 'f' ||
val === 'g' ||
val === 'h' ||
val === 'i' ||
val === 'j' ||
val === 'k' ||
val === 'l' ||
val === 'm' ||
val === 'n' ||
val === 'o' ||
val === 'p' ||
val === 'q' ||
val === 'r' ||
val === 's' ||
val === 't' ||
val === 'u' ||
val === 'v' ||
val === 'w' ||
val === 'x' ||
val === 'y' ||
val === 'z'
)
}
module.exports = {
quit, isLetter, node
}