-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrgbToAbgr.js
44 lines (32 loc) · 847 Bytes
/
rgbToAbgr.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
// - - - WORKING
const argError = new Error('Invalid arguments')
const ignore = '#'
const a = 'ff'
export default function rgbToAbgr(...args) {
let [hex = ''] = Array.from(args).filter(Boolean)
hex = hex.slice(ignore)
if (hex.length !== 6)
return argError
const r = hex.slice(0, 2)
const g = hex.slice(2, 4)
const b = hex.slice(4)
return a.concat(b, g, r)
}
// const argError = new Error('Invalid arguments')
// const ignore = '#'
// const a = 'ff'
// export default function rgbToAbgr(
// { args : [...args] = Array.from(...arguments) }
// ) {
// const {
// hex: {
// length
// }
// } = str.slice(ignore)
// if (length !== 6) return argError
// const r = hex.slice(0, 2)
// const g = hex.slice(2, 4)
// const b = hex.slice(4)
// return a.concat(b, g, r)
// }
// rgbToAbgr(false)