Sha256: 60685a771013f7081e55c1721dae6983194e0b661aeb64d0b6570faed0754d86

Contents?: true

Size: 762 Bytes

Versions: 4

Compression:

Stored size: 762 Bytes

Contents

var stream = require("stream")
var util = require("util")

function DeviceStream(device) {
  stream.Readable.call(this, {objectMode: true})
  this.device = device
}

util.inherits(DeviceStream, stream.Readable)

DeviceStream.prototype.createResponseHandler = function() {
  var that = this
  return function(err, res, data) {
    if (err) return that.emit("error", err)

    var data = data.response && data.response.obs

    if (!data) {
      return process.exit()
    }
    that.push(data)
  };
}

DeviceStream.prototype.httpRequestOptions = function() {
  var ret = {
    uri: "https://www.lacrossealerts.com/v1/observations/",
    qs: {id: this.device.id},
    jar: this.device.client.jar,
    json: true
  };
  return ret;
}

module.exports = DeviceStream

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
freezerwatch-0.2.0 node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js
freezerwatch-0.1.2 node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js
freezerwatch-0.1.1 node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js
freezerwatch-0.1.0 node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js