<commit_before>var rest = require('restler'),
    util = require('util');

function constructor(key, feed_id, id, options) {

  this.defaults.headers['X-AIO-Key'] = key;
  this.feed_id = feed_id;
  this.id = id;

  this.baseURL += feed_id + '/';

  util._extend(this.defaults, options || {});

  return this;

}

var defaults = {
  feed_id: false,
  id: false,
  baseURL: 'https://io.adafruit.com/api/feeds/',
  headers: {
    'Accept': 'application/json',
    'User-Agent': 'aio-client-node'
  }
};

var methods = {
  load: function(cb) {

    var self = this,
        get;

    // check if user provided id or cb as first arg
    if(this.id) {
      get = this.get('streams/' + this.id + '.json');
    } else {
      get = this.get('streams.json');
    }

    // if user provides a callback, call it with the result or err
    if(typeof cb == 'function') {
      get.on('complete', function(result, res) {

        if(result instanceof Error) {
          return cb(result);
        }

        cb(null, result);

      });
    }

    return this;

  },
  create: function(data, cb) {

    data = { value: data };

    var post = this.post('streams.json', { data: data });

    // if user provides a callback, call it with any errors and a bool for creation
    if(typeof cb == 'function') {

      post.on('complete', function(result, res) {

        if(res.statusCode === 201) {
          return cb(null, true);<commit_msg>adds next, last, and previous methods to stream module<commit_after>var rest = require('restler'),
    util = require('util');

function constructor(key, feed_id, id, options) {

  this.defaults.headers['X-AIO-Key'] = key;
  this.feed_id = feed_id;
  this.id = id;

  this.baseURL += feed_id + '/';

  util._extend(this.defaults, options || {});

  return this;

}

var defaults = {
  feed_id: false,
  id: false,
  baseURL: 'https://io.adafruit.com/api/feeds/',
  headers: {
    'Accept': 'application/json',
    'User-Agent': 'aio-client-node'
  }
};

var methods = {
  load: function(cb) {

    var self = this,
        get;

    // check if user provided id or cb as first arg
    if(this.id) {
      get = this.get('streams/' + this.id + '.json');
    } else {
      get = this.get('streams.json');
    }

    // if user provides a callback, call it with the result or err
    if(typeof cb == 'function') {
      get.on('complete', function(result, res) {

        if(result instanceof Error) {
          return cb(result);
        }

        cb(null, result);

      });
    }

    return this;

  },
  last: function(cb) {

    var get = this.get('streams/last.json');

    // if user provides a callback, call it with the err and result
    if(typeof cb == 'function') {
      get.on('complete', function(result, res) {

        if(result instanceof Error) {
          return cb(result);
        }

        cb(null, result);

      });
    }

    return this;

  },
  next: function(cb) {

    var get = this.get('streams/next.json');

    // if user provides a callback, call it with the err and result
    if(typeof cb == 'function') {
      get.on('complete', function(result, res) {

        if(result instanceof Error) {
          return cb(result);
        }

        cb(null, result);

      });
    }

    return this;

  },
  previous: function(cb) {

    var get = this.get('streams/previous.json');

    // if user provides a callback, call it with the err and result
    if(typeof cb == 'function') {
      get.on('complete', function(result, res) {

        if(result instanceof Error) {
          return cb(result);
        }

        cb(null, result);

      });
    }

    return this;

  },
  create: function(data, cb) {

    data = { value: data };

    var post = this.post('streams.json', { data: data });

    // if user provides a callback, call it with any errors and a bool for creation
    if(typeof cb == 'function') {

      post.on('complete', function(result, res) {

        if(res.statusCode === 201) {
          return cb(null, true);
{'fraction_non_alphanumeric': 0.15, 'fraction_numerical': 0.0015, 'mean_word_length': 2.2714636140637774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1739284', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1267, 'n_words': 353}