replace functions with arrow functions
This commit is contained in:
parent
91f6c0a57a
commit
5b22396e0d
1 changed files with 11 additions and 11 deletions
|
@ -41,7 +41,7 @@ function powerOff() {
|
||||||
|
|
||||||
// parse a color object from given request arguments
|
// parse a color object from given request arguments
|
||||||
function parseColor(value) {
|
function parseColor(value) {
|
||||||
if (!value || value == RANDOM) {
|
if (!value || value === RANDOM) {
|
||||||
return RANDOM;
|
return RANDOM;
|
||||||
}
|
}
|
||||||
let parsedColor = parseRGBColor(value);
|
let parsedColor = parseRGBColor(value);
|
||||||
|
@ -95,16 +95,16 @@ function parseHexColor(value) {
|
||||||
if (value.length === 4) {
|
if (value.length === 4) {
|
||||||
value = (value[0] + value[1] + value[1] + value[2] + value[2] + value[3] + value[3]);
|
value = (value[0] + value[1] + value[1] + value[2] + value[2] + value[3] + value[3]);
|
||||||
}
|
}
|
||||||
if (hexcolor({ strict: true }).test(value)) {
|
if (hexcolor({strict: true}).test(value)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass the options to the blinkstick accordingly
|
// pass the options to the blinkstick accordingly
|
||||||
function illuminate(blinkstickConfig) {
|
function illuminate(blinkstickConfig) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
findBlinkstick()
|
findBlinkstick()
|
||||||
.then(function () {
|
.then(() => {
|
||||||
switch (blinkstickConfig.mode) {
|
switch (blinkstickConfig.mode) {
|
||||||
case 'morph':
|
case 'morph':
|
||||||
morph(blinkstickConfig, resolve, reject);
|
morph(blinkstickConfig, resolve, reject);
|
||||||
|
@ -124,10 +124,10 @@ function illuminate(blinkstickConfig) {
|
||||||
// set a static color
|
// set a static color
|
||||||
function setColor(blinkstickConfig, resolve, reject) {
|
function setColor(blinkstickConfig, resolve, reject) {
|
||||||
stopAnimation()
|
stopAnimation()
|
||||||
.then(function () {
|
.then(() => {
|
||||||
setAnimationProperties(blinkstickConfig);
|
setAnimationProperties(blinkstickConfig);
|
||||||
logger.debug('setting color to \'' + blinkstickConfig.color + '\'...');
|
logger.debug('setting color to \'' + blinkstickConfig.color + '\'...');
|
||||||
led.setColor(blinkstickConfig.color, blinkstickConfig.options, function (err) {
|
led.setColor(blinkstickConfig.color, blinkstickConfig.options, (err) => {
|
||||||
clearAnimationProperties();
|
clearAnimationProperties();
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject('error setting color \'' + blinkstickConfig.color + '\' (' + err + ')');
|
return reject('error setting color \'' + blinkstickConfig.color + '\' (' + err + ')');
|
||||||
|
@ -140,10 +140,10 @@ function setColor(blinkstickConfig, resolve, reject) {
|
||||||
// morph to a color
|
// morph to a color
|
||||||
function morph(blinkstickConfig, resolve, reject) {
|
function morph(blinkstickConfig, resolve, reject) {
|
||||||
stopAnimation()
|
stopAnimation()
|
||||||
.then(function () {
|
.then(() => {
|
||||||
setAnimationProperties(blinkstickConfig);
|
setAnimationProperties(blinkstickConfig);
|
||||||
logger.debug('morphing color to \'' + blinkstickConfig.color + '\'...');
|
logger.debug('morphing color to \'' + blinkstickConfig.color + '\'...');
|
||||||
led.morph(blinkstickConfig.color, blinkstickConfig.options, function (err) {
|
led.morph(blinkstickConfig.color, blinkstickConfig.options, (err) => {
|
||||||
clearAnimationProperties();
|
clearAnimationProperties();
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject('error morphing color to \'' + blinkstickConfig.color + '\' (' + err + ')');
|
return reject('error morphing color to \'' + blinkstickConfig.color + '\' (' + err + ')');
|
||||||
|
@ -169,7 +169,7 @@ function startPulsing(blinkstickConfig, resolve, reject) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setAnimationProperties(blinkstickConfig);
|
setAnimationProperties(blinkstickConfig);
|
||||||
led.pulse(blinkstickConfig.color, blinkstickConfig.options, function (err) {
|
led.pulse(blinkstickConfig.color, blinkstickConfig.options, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
clearAnimationProperties();
|
clearAnimationProperties();
|
||||||
return reject('error pulsing color \'' + blinkstickConfig.color + '\' (' + err + ')');
|
return reject('error pulsing color \'' + blinkstickConfig.color + '\' (' + err + ')');
|
||||||
|
@ -198,7 +198,7 @@ function clearAnimationProperties() {
|
||||||
|
|
||||||
// stop the current animation
|
// stop the current animation
|
||||||
function stopAnimation() {
|
function stopAnimation() {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
if (!isAnimationInProgress()) {
|
if (!isAnimationInProgress()) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ function waitForAnimation(timestamp, resolve, reject) {
|
||||||
if (!isAnimationInProgress()) {
|
if (!isAnimationInProgress()) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
waitForAnimation(timestamp, resolve, reject);
|
waitForAnimation(timestamp, resolve, reject);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue