From a1cda1496f088c5f25d0cd6f8be39603e84f73c5 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Thu, 1 Mar 2018 16:15:29 +0100 Subject: [PATCH] Drop uncritical dependencies to enable alt runtimes Node is still supported, and IoT.js can be ported. Related links: https://engineering.upside.com/you-dont-need-lodash-3323ca2cfb4c https://github.com/rzr/webthing-iotjs Change-Id: I58c8c5b728ea6cd457e6618c952c0b7c8a406315 Bug: https://github.com/miroRucka/bh1750/pull/15 Origin: https://github.com/tizenteam/bh1750/tree/iotjs/master Signed-off-by: Philippe Coval --- bh1750.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bh1750.js b/bh1750.js index bf21be0..1ead5a4 100644 --- a/bh1750.js +++ b/bh1750.js @@ -1,26 +1,25 @@ var console = require('console'); var i2c = require('i2c'); -var _ = require('lodash'); -var utils = require('./utils'); var BH1750 = function (opts) { - this.options = _.extend({}, { + this.options = opts || { address: 0x23, device: '/dev/i2c-1', command: 0x10, length: 2 - }, opts); + }; this.verbose = this.options.verbose || false; this.wire = new i2c(this.options.address, {device: this.options.device}); }; BH1750.prototype.readLight = function (cb) { var self = this; - if (!utils.exists(cb)) { + if (!cb) { throw new Error("Invalid param"); } self.wire.readBytes(self.options.command, self.options.length, function (err, res) { - if (utils.exists(err)) { + + if (err) { if (self.verbose) console.error("error: I/O failure on BH1750 - command: ", self.options.command); return cb(err, null);