fix use of Ox.map, Ox.loop

This commit is contained in:
j 2012-05-23 17:13:38 +02:00
parent 9a7e86dceb
commit f97352ee61
6 changed files with 10 additions and 10 deletions

View file

@ -345,7 +345,7 @@ Ox.load.Image = function(options, callback) {
// Array of bits per byte to be modified (0 is LSB) // Array of bits per byte to be modified (0 is LSB)
bits = mode < 1 ? [-mode] : Ox.filter(Ox.range(8), function(i) { bits = mode < 1 ? [-mode] : Ox.filter(Ox.range(8), function(i) {
return mode & 1 << i; return mode & 1 << i;
}; }),
cap = getCapacity(bits.length), len; cap = getCapacity(bits.length), len;
// Compress the string // Compress the string
str = Ox[deflate ? 'encodeDeflate' : 'encodeUTF8'](str); str = Ox[deflate ? 'encodeDeflate' : 'encodeUTF8'](str);
@ -362,7 +362,7 @@ Ox.load.Image = function(options, callback) {
return Ox.range(8).map(function(i) { return Ox.range(8).map(function(i) {
return chr.charCodeAt(0) >> 7 - i & 1; return chr.charCodeAt(0) >> 7 - i & 1;
}); });
})); }).split(','));
b = 0; b = 0;
that.forEach(function(rgba, xy, index) { that.forEach(function(rgba, xy, index) {
// If alpha is not 255, the RGB values may not be preserved // If alpha is not 255, the RGB values may not be preserved

View file

@ -93,7 +93,7 @@ Ox.load.Unicode = function(options, callback) {
Ox.toASCII = function(str) { Ox.toASCII = function(str) {
return Ox.map(str, function(chr) { return Ox.map(str, function(chr) {
return chars[chr].ascii || chr; return chars[chr].ascii || chr;
}).join(''); });
}; };
callback(true); callback(true);

View file

@ -245,7 +245,7 @@ Ox.loop <f> For-loop, functional-style
step <n> Step value step <n> Step value
fn <f> Iterator function fn <f> Iterator function
i <n> Counter value i <n> Counter value
> Ox.loop(10, function(i) { return i != 4; }) > Ox.loop(10, function(i) { i == 4 && Ox.break() })
4 4
> Ox.loop(0, 3, 2, function() {}) > Ox.loop(0, 3, 2, function() {})
4 4

View file

@ -71,7 +71,7 @@ Ox.getDaysInMonth <f> Get the number of days in a given month
Ox.getDaysInMonth = function(year, month) { Ox.getDaysInMonth = function(year, month) {
year = Ox.makeYear(year); year = Ox.makeYear(year);
month = Ox.isNumber(month) ? month month = Ox.isNumber(month) ? month
: Ox.getIndexOf(Ox.MONTHS, function(v) { : Ox.indexOf(Ox.MONTHS, function(v) {
return v.substr(0, 3) == month.substr(0, 3); return v.substr(0, 3) == month.substr(0, 3);
}) + 1; }) + 1;
return new Date(year, month, 0).getDate(); return new Date(year, month, 0).getDate();

View file

@ -81,7 +81,7 @@
Ox.encodeBase32 = function(num) { Ox.encodeBase32 = function(num) {
return Ox.map(num.toString(32), function(char) { return Ox.map(num.toString(32), function(char) {
return Ox.BASE_32_DIGITS[parseInt(char, 32)]; return Ox.BASE_32_DIGITS[parseInt(char, 32)];
}).join(''); });
}; };
/*@ /*@
@ -100,7 +100,7 @@
Ox.BASE_32_ALIASES[char] || char Ox.BASE_32_ALIASES[char] || char
); );
return (index == -1 ? ' ' : index).toString(32); return (index == -1 ? ' ' : index).toString(32);
}).join(''), 32); }), 32);
}; };
/*@ /*@
@ -347,7 +347,7 @@
+ String.fromCharCode(code & 63 | 128); + String.fromCharCode(code & 63 | 128);
} }
return str; return str;
}).join(''); });
}; };
/*@ /*@

View file

@ -279,7 +279,7 @@ Ox.formatDateRange = function(start, end, utc) {
if (i == precision[0] - 1 && parts[0][i] != parts[1][i] - 1) { if (i == precision[0] - 1 && parts[0][i] != parts[1][i] - 1) {
isOneUnit = false; isOneUnit = false;
} }
return isOneUnit; !isOneUnit && Ox.break();
}); });
} }
if (isOneUnit) { if (isOneUnit) {