<commit_before>/* jshint node:true */
/*

 Turns off stabalisation and gently pulses a nice green colour

 This file expected to be run as follows:

 $ node examples/repl.js
 S> .load examples/vege.js

 */
var o = { resetTimeout:true, requestAcknowledgement:true };
var s = sphero();

s.on('error', function(error) {
  console.log('Sphero error:', error);
});

var colourStart = 0x006600;
var colourStop = 0x00FF00;

s.on('open', function() {

  console.log('Sphero connected');

});

s.open(dev);

var repeat = false;

var police = function(delay1, delay2) {
  s.write(commands.api.setRGB(0x000000, false, o));
  setTimeout(function() {
    s.write(commands.api.setRGB(0x0000FF, false, o));
  }, delay1);
  setTimeout(function() {
    s.write(commands.api.setRGB(0x000000, false, o));
  }, delay1*2);
  setTimeout(function() {
    s.write(commands.api.setRGB(0x0000FF, false, o));
  }, delay1*3);
  setTimeout(function() {
    s.write(commands.api.setRGB(0x000000, false, o));
  }, delay1*4);

  setTimeout(function() {
    s.write(commands.api.setRGB(0xFF0000, false, o));
  }, delay1*5);
  setTimeout(function() {
    s.write(commands.api.setRGB(0x000000, false, o));
  }, delay1*6);
  setTimeout(function() {
    s.write(commands.api.setRGB(0xFF0000, false, o));
  }, delay1*7);
  setTimeout(function() {
    s.write(commands.api.setRGB(0x000000, false, o));
  }, delay1*8);

  if (repeat) {
    setTimeout(function() {
      police(delay1, delay2);
    }, delay2+delay1*8);
  }
};

<commit_msg>Update police example to use chained methods<commit_after>/* jshint node:true */
/*

 Turns off stabalisation and gently pulses a nice green colour

 This file is expected to be run something like this:

 $ node examples/repl.js
 S> .load examples/vege.js
 S> police(100, 500);
 S> repeat = true;
 S> police(100,500);
 S> repeat = false;

 */
var o = { resetTimeout:true, requestAcknowledgement:true };
var s = sphero().resetTimeout(true).requestAcknowledgement(true);

s.on('error', function(error) {
  console.log('Sphero error:', error);
});

s.on('open', function() {

  console.log('Sphero connected');

});

s.open(dev);

var repeat = false;

var police = function(delay1, delay2) {
  s.setRGB(0x000000, false);
  setTimeout(function() {
    s.setRGB(0x0000FF);
  }, delay1);
  setTimeout(function() {
    s.setRGB(0x000000, false);
  }, delay1*2);
  setTimeout(function() {
    s.setRGB(0x0000FF, false);
  }, delay1*3);
  setTimeout(function() {
    s.setRGB(0x000000, false);
  }, delay1*4);

  setTimeout(function() {
    s.setRGB(0xFF0000, false);
  }, delay1*5);
  setTimeout(function() {
    s.setRGB(0x000000, false);
  }, delay1*6);
  setTimeout(function() {
    s.setRGB(0xFF0000, false);
  }, delay1*7);
  setTimeout(function() {
    s.setRGB(0x000000, false);
  }, delay1*8);

  if (repeat) {
    setTimeout(function() {
      police(delay1, delay2);
    }, delay2+delay1*8);
  }
};

{'fraction_non_alphanumeric': 0.17172413793103447, 'fraction_numerical': 0.06137931034482759, 'mean_word_length': 4.054006968641115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '6049712', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1056, 'n_words': 213}