<commit_before>'use strict';

/* eslint-disable no-console */

let leds;

try {
  const Blinkt = require('node-blinkt');

  leds = new Blinkt();
  console.log('Platform supported by Blinkt!');
} catch (e) {
  // Mock to run unit-tests on platforms not supported by Blinkt!
  leds = {
    clearAll () {},
    sendUpdate () {},
    setAllPixels () {},
    setPixel () {},
    setup () {}
  };
  console.error('Platform not supported by Blinkt!');
}

const shutdown = function () {
  console.log('Turning off lights.');

  leds.setAllPixels(0, 0, 0, 0);

  // Workaround: https://github.com/Irrelon/node-blinkt/issues/1
  leds.sendUpdate();
  leds.sendUpdate();

  /* eslint-disable no-process-exit */
  process.nextTick(() => {
    console.log('Terminating process.');
    process.exit(0);
  });
  /* eslint-enable no-process-exit */
};

const init = function () {
  leds.setup();
  leds.clearAll();

  process.on('SIGINT', shutdown);
  process.on('SIGTERM', shutdown);

  console.log('Initialized.');
};

const blinkt = function (colors) {
  colors = colors || [];

  colors.slice(-8).forEach((color, i) => {
    leds.setPixel(7 - i, color[0], color[1], color[2], 0.3);
  });

  for (let i = 0; i < 8 - colors.length; i++) {
    leds.setPixel(i, 0, 0, 0, 0);
  }

  // Workaround: https://github.com/Irrelon/node-blinkt/issues/1
  leds.sendUpdate();
  leds.sendUpdate();
};

init();

module.exports = blinkt;
<commit_msg>Use one direction for switching on and off.<commit_after>'use strict';

/* eslint-disable no-console */

let leds;

try {
  const Blinkt = require('node-blinkt');

  leds = new Blinkt();
  console.log('Platform supported by Blinkt!');
} catch (e) {
  // Mock to run unit-tests on platforms not supported by Blinkt!
  leds = {
    clearAll () {},
    sendUpdate () {},
    setAllPixels () {},
    setPixel () {},
    setup () {}
  };
  console.error('Platform not supported by Blinkt!');
}

const shutdown = function () {
  console.log('Turning off lights.');

  leds.setAllPixels(0, 0, 0, 0);

  // Workaround: https://github.com/Irrelon/node-blinkt/issues/1
  leds.sendUpdate();
  leds.sendUpdate();

  /* eslint-disable no-process-exit */
  process.nextTick(() => {
    console.log('Terminating process.');
    process.exit(0);
  });
  /* eslint-enable no-process-exit */
};

const init = function () {
  leds.setup();
  leds.clearAll();

  process.on('SIGINT', shutdown);
  process.on('SIGTERM', shutdown);

  console.log('Initialized.');
};

const blinkt = function (colors) {
  colors = colors || [];

  colors.slice(-8).forEach((color, i) => {
    leds.setPixel(7 - i, color[0], color[1], color[2], 0.3);
  });

  for (let i = 7 - colors.length; i >= 0; i--) {
    leds.setPixel(i, 0, 0, 0, 0);
  }

  // Workaround: https://github.com/Irrelon/node-blinkt/issues/1
  leds.sendUpdate();
  leds.sendUpdate();
};

init();

module.exports = blinkt;

{'fraction_non_alphanumeric': 0.1922675026123302, 'fraction_numerical': 0.013932427725531174, 'mean_word_length': 3.1683599419448476, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5343926', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1032, 'n_words': 219}