push
github
15 of 17 branches covered (88.24%)
Branch coverage included in aggregate %.
3 of 3 new or added lines in 1 file covered. (100.0%)
86 of 96 relevant lines covered (89.58%)
26.06 hits per line
1 |
'use strict'
|
|
2 |
|
1✔ |
|
const { serializeError } = require('serialize-error')
|
1✔ |
4 |
const debug = require('debug-logfmt')('splashy') |
1✔ |
5 |
const createVibrant = require('./vibrant')
|
1✔ |
6 |
|
1✔ |
7 |
const toPalette = swatch => |
|
8 |
Object.keys(swatch) |
28✔ |
9 |
.reduce((acc, key) => { |
|
10 |
const value = swatch[key] |
168✔ |
11 |
if (value) {
|
168✔ |
12 |
acc.push({ |
168✔ |
13 |
popularity: value.getPopulation(),
|
168✔ |
14 |
hex: value.getHex()
|
168✔ |
15 |
}) |
168✔ |
16 |
} |
168✔ |
17 |
return acc
|
168✔ |
18 |
}, []) |
28✔ |
19 |
.sort((a, b) => a.popularity <= b.popularity) |
|
20 |
.map(color => color.hex) |
|
21 |
|
1✔ |
22 |
module.exports = async input => { |
|
23 |
let swatch |
28✔ |
24 |
|
28✔ |
25 |
try {
|
28✔ |
26 |
const vibrant = createVibrant(input) |
28✔ |
27 |
swatch = await vibrant.getPalette() |
28✔ |
|
} catch (error) {
|
|
|
debug.error(serializeError(error)) |
× |
30 |
swatch = {} |
× |
31 |
} |
× |
32 |
|
28✔ |
33 |
return toPalette(swatch)
|
28✔ |
34 |
} |
28✔ |