-
Notifications
You must be signed in to change notification settings - Fork 4
/
argument.js
90 lines (81 loc) · 1.67 KB
/
argument.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict'
exports.boolAt = pos => (...args) => {
args[pos] = args[pos] ? 1 : 0
return args
}
exports.dbList = (tag, filter, ...groups) => {
const args = groups.flatMap(group => ['group', group])
if (filter !== false) {
args.unshift(filter)
}
args.unshift(tag)
return args.filter(s => !!s)
}
exports.stickerSet = (...args) => {
// remove `=` from the sticker name as this
// is delimiter between key and value in MPD
let name = args[1]
if (typeof name === 'string' && name.indexOf('=') !== -1) {
args[1] = name.replace(/=/g, ' ')
}
return args
}
exports.stickerDel = exports.stickerSet
/**
* @param name
* @param [uri='']
*/
exports.stickerFind = (...args) => {
// reverse uri and sticker name and
// default uri to ''
let [name, uri] = args
if (typeof uri !== 'string') {
uri = ''
}
// fix to MPD arg order
args[0] = uri
args[1] = name
return args
}
/**
* @param name
* @param value
* @param [comparator='=']
* @param [uri='']
*/
exports.stickerSearch = (...args) => {
let [name, value, comparator, uri] = args
if (typeof comparator !== 'string') {
comparator = '='
}
if (typeof uri !== 'string') {
uri = ''
}
// fix to MPD arg order
args[0] = uri
args[1] = name
args[2] = comparator
args[3] = value
return args
}
/**
* @param {Number|boolean}
*/
exports.mixrampdelay = (...args) => {
if (args[0] === false) {
args[0] = 'nan' // disables the mixrampdb
}
return args
}
exports.single = (...args) => {
if (typeof args[0] !== 'string') {
args[0] = args[0] ? 1 : 0
}
return args
}
exports.replaygain = (...args) => {
if (args[0] === false) {
args[0] = 'off'
}
return args
}