lib/device_curator.js
function(addresses) {
		var defered = q.defer();
		var currentStep = 0;
		var numSteps = addresses.length;
		var results = [];

		var handleReadSuccess = function(res) {
			results.push({'address': addresses[currentStep], 'isErr': false, 'data': res});
			if(currentStep < numSteps) {
				currentStep += 1;
				performRead();
			} else {
				defered.resolve(results);
			}
		};
		var handleReadError = function(err) {
			results.push({'address': addresses[currentStep], 'isErr': true, 'data': err});
			if(currentStep < numSteps) {
				currentStep += 1;
				performRead();
			} else {
				defered.resolve(results);
			}
		};
		var performRead = function() {
			self.qRead(addresses[currentStep])
			.then(handleReadSuccess, handleReadError);
		};

		performRead();

		return defered.promise;
	}
function(addresses) {
		var defered = q.defer();
		var currentStep = 0;
		var numSteps = addresses.length;
		var results = [];

		var handleReadSuccess = function(res) {
			results.push({'address': addresses[currentStep], 'isErr': false, 'data': res});
			if(currentStep < numSteps) {
				currentStep += 1;
				performRead();
			} else {
				defered.resolve(results);
			}
		};
		var handleReadError = function(err) {
			results.push({'address': addresses[currentStep], 'isErr': true, 'data': err});
			if(currentStep < numSteps) {
				currentStep += 1;
				performRead();
			} else {
				defered.resolve(results);
			}
		};
		var performRead = function() {
			self.qRead(addresses[currentStep])
			.then(handleReadSuccess, handleReadError);
		};

		performRead();

		return defered.promise;
	}
function ( addresses ) { var defered = q . defer ( ) ; var currentStep = 0 ; var numSteps = addresses . length ; var results = [ ] ; var handleReadSuccess = function ( res ) { results . push ( { 'address' : addresses [ currentStep ] , 'isErr' : false , 'data' : res } ) ; if ( currentStep < numSteps ) { currentStep += 1 ; performRead ( ) ; } else { defered . resolve ( results ) ; } } ; var handleReadError = function ( err ) { results . push ( { 'address' : addresses [ currentStep ] , 'isErr' : true , 'data' : err } ) ; if ( currentStep < numSteps ) { currentStep += 1 ; performRead ( ) ; } else { defered . resolve ( results ) ; } } ; var performRead = function ( ) { self . qRead ( addresses [ currentStep ] ) . then ( handleReadSuccess , handleReadError ) ; } ; performRead ( ) ; return defered . promise ; }
An experimental implementation of the readMultiple function that doesn't use the async library.
An experimental implementation of the readMultiple function that doesn t use the async library .