<commit_before>var Bowline = require('bowline');

var adapter = {};

adapter.sensorName = 'twine';

adapter.types = [
  {
    id: 'string',
    name: 'twine',
    fields: {
      timestamp: 'date',
      meta: {
        sensor: 'string',
        battery: 'string',
        wifiSignal: 'string'
      },
      measureTime: {
        age: 'float',
        timestamp: 'integer'
      },
      values: {
        batteryVoltage: 'float',
        firmwareVersion: 'string',
        isVibrating: 'boolean',
        orientation: 'string',
        temperature: 'integer',
        updateMode: 'string',
        vibration: 'integer'
      }
    }
  }
];

adapter.promptProps = {
  properties: {
    email: {
      description: 'Enter your Twine account (e-mail address)'.magenta
    },
    password: {
      description: 'Enter your password'.magenta
    },
    deviceId: {
      description: 'Enter your Twine device ID'.magenta
    }
  }
};

adapter.storeConfig = function(c8, result) {
  return c8.config(result).then(function(){
    console.log('Configuration stored.');
    c8.release();
  });
}

adapter.importData = function(c8, conf, opts) {
  return new Promise(function (fulfill, reject){
    if (conf.deviceId) {
      var client = new Bowline(conf);
      return client.fetch(function(err, response){
        if (err) {
          console.trace(err);
          return;
        }
        response.id = response.time.timestamp + '-' + conf.deviceId;
        response.meta.sensor = conf.deviceId;
        response.timestamp = new Date(response.time.timestamp * 1000);
        response.measureTime = response.time;
        delete(response.time);
        c8.insert(response).then(function(result) {
          // console.log(result);
          console.log(response.timestamp + ': ' + result.result);
          // console.log('Indexed ' + result.items.length + ' documents in ' + result.took + ' ms.');
        }).catch(function(error) {
          reject(error);
        });
      });<commit_msg>explicitly cast isVibrating to boolean<commit_after>var Bowline = require('bowline');

var adapter = {};

adapter.sensorName = 'twine';

adapter.types = [
  {
    id: 'string',
    name: 'twine',
    fields: {
      timestamp: 'date',
      meta: {
        sensor: 'string',
        battery: 'string',
        wifiSignal: 'string'
      },
      measureTime: {
        age: 'float',
        timestamp: 'integer'
      },
      values: {
        batteryVoltage: 'float',
        firmwareVersion: 'string',
        isVibrating: 'boolean',
        orientation: 'string',
        temperature: 'integer',
        updateMode: 'string',
        vibration: 'integer'
      }
    }
  }
];

adapter.promptProps = {
  properties: {
    email: {
      description: 'Enter your Twine account (e-mail address)'.magenta
    },
    password: {
      description: 'Enter your password'.magenta
    },
    deviceId: {
      description: 'Enter your Twine device ID'.magenta
    }
  }
};

adapter.storeConfig = function(c8, result) {
  return c8.config(result).then(function(){
    console.log('Configuration stored.');
    c8.release();
  });
}

adapter.importData = function(c8, conf, opts) {
  return new Promise(function (fulfill, reject){
    if (conf.deviceId) {
      var client = new Bowline(conf);
      return client.fetch(function(err, response){
        if (err) {
          console.trace(err);
          return;
        }
        response.id = response.time.timestamp + '-' + conf.deviceId;
        response.meta.sensor = conf.deviceId;
        response.timestamp = new Date(response.time.timestamp * 1000);
        response.measureTime = response.time;
        response.isVibrating = response.isVibrating ? true : false;
        delete(response.time);
        c8.insert(response).then(function(result) {
          // console.log(result);
          console.log(response.timestamp + ': ' + result.result);
          // console.log('Indexed ' + result.items.length + ' documents in ' + result.took + ' ms.');
        }).catch(function(error) {
          reject(error);
        });
      });
{'fraction_non_alphanumeric': 0.1424711373126996, 'fraction_numerical': 0.004421518054532056, 'mean_word_length': 2.2576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7341291', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1213, 'n_words': 244}