This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 297
/
Copy pathbootstrap.js
70 lines (62 loc) · 1.47 KB
/
bootstrap.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
65
66
67
68
69
70
'use strict'
const promisify = require('promisify-es6')
module.exports = (send) => {
return {
add: promisify((args, opts, callback) => {
if (typeof opts === 'function' &&
!callback) {
callback = opts
opts = {}
}
// opts is the real callback --
// 'callback' is being injected by promisify
if (typeof opts === 'function' &&
typeof callback === 'function') {
callback = opts
opts = {}
}
if (args && typeof args === 'object') {
opts = args
args = undefined
}
send({
path: 'bootstrap/add',
args: args,
qs: opts
}, callback)
}),
rm: promisify((args, opts, callback) => {
if (typeof opts === 'function' &&
!callback) {
callback = opts
opts = {}
}
// opts is the real callback --
// 'callback' is being injected by promisify
if (typeof opts === 'function' &&
typeof callback === 'function') {
callback = opts
opts = {}
}
if (args && typeof args === 'object') {
opts = args
args = undefined
}
send({
path: 'bootstrap/rm',
args: args,
qs: opts
}, callback)
}),
list: promisify((opts, callback) => {
if (typeof (opts) === 'function') {
callback = opts
opts = {}
}
send({
path: 'bootstrap/list',
qs: opts
}, callback)
})
}
}