lib/x10.js
function UnitCode(unitCode) {
	switch (typeof unitCode) {
	case "string":
		unitCode = parseInt(unitCode, 10);
		if (unitCode || unitCode === 0) {
			var index = unitCode - 1;
			if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
				this.raw = deviceCodes[index];
			} else {
				throw new Error("Unit code string out of range.");
			}
		} else {
			throw new Error("Invalid unit code.");
		}
		break;
	default:
		if (deviceCodes.indexOf(unitCode) !== -1) {
			this.raw = unitCode;
		} else {
			throw new Error("Unit code number out of range.");
		}
		break;
	}
	return this.raw;
}
function UnitCode(unitCode) {
	switch (typeof unitCode) {
	case "string":
		unitCode = parseInt(unitCode, 10);
		if (unitCode || unitCode === 0) {
			var index = unitCode - 1;
			if ((index >= 0) && (index <= (deviceCodes.length - 1))) {
				this.raw = deviceCodes[index];
			} else {
				throw new Error("Unit code string out of range.");
			}
		} else {
			throw new Error("Invalid unit code.");
		}
		break;
	default:
		if (deviceCodes.indexOf(unitCode) !== -1) {
			this.raw = unitCode;
		} else {
			throw new Error("Unit code number out of range.");
		}
		break;
	}
	return this.raw;
}
function UnitCode ( unitCode ) { switch ( typeof unitCode ) { case "string" : unitCode = parseInt ( unitCode , 10 ) ; if ( unitCode || unitCode === 0 ) { var index = unitCode - 1 ; if ( ( index >= 0 ) && ( index <= ( deviceCodes . length - 1 ) ) ) { this . raw = deviceCodes [ index ] ; } else { throw new Error ( "Unit code string out of range." ) ; } } else { throw new Error ( "Invalid unit code." ) ; } break ; default : if ( deviceCodes . indexOf ( unitCode ) !== - 1 ) { this . raw = unitCode ; } else { throw new Error ( "Unit code number out of range." ) ; } break ; } return this . raw ; }
object to convert X-10 unit codes from numbers to strings and back
object to convert X - 10 unit codes from numbers to strings and back