Skip to content

Commit

Permalink
Re-wrap indentation of Array reduce shim
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed May 2, 2012
1 parent ad3badc commit 319b770
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions q.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,32 +142,34 @@ if (Function.prototype.bind) {

var Array_slice = uncurryThis(Array.prototype.slice);

var Array_reduce = uncurryThis(Array.prototype.reduce || function (callback, basis) {
var index = 0,
length = this.length;
// concerning the initial value, if one is not provided
if (arguments.length === 1) {
// seek to the first value in the array, accounting
// for the possibility that is is a sparse array
do {
var Array_reduce = uncurryThis(
Array.prototype.reduce || function (callback, basis) {
var index = 0,
length = this.length;
// concerning the initial value, if one is not provided
if (arguments.length === 1) {
// seek to the first value in the array, accounting
// for the possibility that is is a sparse array
do {
if (index in this) {
basis = this[index++];
break;
}
if (++index >= length) {
throw new TypeError();
}
} while (1);
}
// reduce
for (; index < length; index++) {
// account for the possibility that the array is sparse
if (index in this) {
basis = this[index++];
break;
}
if (++index >= length) {
throw new TypeError();
basis = callback(basis, this[index], index);
}
} while (1);
}
// reduce
for (; index < length; index++) {
// account for the possibility that the array is sparse
if (index in this) {
basis = callback(basis, this[index], index);
}
return basis;
}
return basis;
});
);

var Object_create = Object.create || function (prototype) {
function Type() { }
Expand Down

0 comments on commit 319b770

Please sign in to comment.