demo/js/vendor/ractive.js
function getStarMap( num ) {
			var ones = '',
				max, binary, starMap, mapper, i;
			if ( !starMaps[ num ] ) {
				starMap = [];
				while ( ones.length < num ) {
					ones += 1;
				}
				max = parseInt( ones, 2 );
				mapper = function( digit ) {
					return digit === '1';
				};
				for ( i = 0; i <= max; i += 1 ) {
					binary = i.toString( 2 );
					while ( binary.length < num ) {
						binary = '0' + binary;
					}
					starMap[ i ] = Array.prototype.map.call( binary, mapper );
				}
				starMaps[ num ] = starMap;
			}
			return starMaps[ num ];
		}
function getStarMap( num ) {
			var ones = '',
				max, binary, starMap, mapper, i;
			if ( !starMaps[ num ] ) {
				starMap = [];
				while ( ones.length < num ) {
					ones += 1;
				}
				max = parseInt( ones, 2 );
				mapper = function( digit ) {
					return digit === '1';
				};
				for ( i = 0; i <= max; i += 1 ) {
					binary = i.toString( 2 );
					while ( binary.length < num ) {
						binary = '0' + binary;
					}
					starMap[ i ] = Array.prototype.map.call( binary, mapper );
				}
				starMaps[ num ] = starMap;
			}
			return starMaps[ num ];
		}
function getStarMap ( num ) { var ones = '' , max , binary , starMap , mapper , i ; if ( ! starMaps [ num ] ) { starMap = [ ] ; while ( ones . length < num ) { ones += 1 ; } max = parseInt ( ones , 2 ) ; mapper = function ( digit ) { return digit === '1' ; } ; for ( i = 0 ; i <= max ; i += 1 ) { binary = i . toString ( 2 ) ; while ( binary . length < num ) { binary = '0' + binary ; } starMap [ i ] = Array . prototype . map . call ( binary , mapper ) ; } starMaps [ num ] = starMap ; } return starMaps [ num ] ; }
This function returns all the possible true/false combinations for a given number - e.g. for two, the possible combinations are [ true, true ], [ true, false ], [ false, true ], [ false, false ]. It does so by getting all the binary values between 0 and e.g. 11
This function returns all the possible true / false combinations for a given number - e . g . for two the possible combinations are [ true true ] [ true false ] [ false true ] [ false false ] . It does so by getting all the binary values between 0 and e . g . 11