hap-nodejs
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -64,5 +64,5 @@ var inherits = require('util').inherits; | ||
// of Characteristic. Coerce if necessary. | ||
if (typeof characteristic === 'function') | ||
characteristic = new (Function.prototype.bind.apply(characteristic, arguments)); | ||
if (typeof characteristic === 'function') { | ||
characteristic = new (Function.prototype.bind.apply(characteristic, arguments)); | ||
} | ||
// check for UUID conflict | ||
@@ -86,10 +86,38 @@ for (var index in this.characteristics) { | ||
Service.prototype.getCharacteristic = function(name) { | ||
for (var index in this.characteristics) { | ||
var characteristic = this.characteristics[index]; | ||
if (typeof name === 'string' && characteristic.displayName === name) | ||
return characteristic; | ||
else if (typeof name === 'function' && characteristic instanceof name) | ||
return characteristic; | ||
} | ||
// returns a characteristic object from the service | ||
// If Service.prototype.getCharacteristic(Characteristic.Type) does not find the characteristic, | ||
// but the type is in optionalCharacteristics, it adds the characteristic.type to the service and returns it. | ||
var index, characteristic; | ||
for (index in this.characteristics) { | ||
characteristic = this.characteristics[index]; | ||
if (typeof name === 'string' && characteristic.displayName === name) { | ||
return characteristic; | ||
} | ||
else if (typeof name === 'function' && characteristic instanceof name) { | ||
return characteristic; | ||
} | ||
} | ||
if (typeof name === 'function') { | ||
for (index in this.optionalCharacteristics) { | ||
characteristic = this.optionalCharacteristics[index]; | ||
if (characteristic instanceof name) { | ||
return this.addCharacteristic(name); | ||
} | ||
} | ||
} | ||
}; | ||
Service.prototype.testCharacteristic = function(name) { | ||
// checks for the existence of a characteristic object in the service | ||
var index, characteristic; | ||
for (index in this.characteristics) { | ||
characteristic = this.characteristics[index]; | ||
if (typeof name === 'string' && characteristic.displayName === name) { | ||
return true; | ||
} | ||
else if (typeof name === 'function' && characteristic instanceof name) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
@@ -96,0 +124,0 @@ |
{ | ||
"name": "hap-nodejs", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "HAP-NodeJS is a Node.js implementation of HomeKit Accessory Server.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218238
32
5126
5