mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
adding weepy's suggestion to use (for .. in) for array comprehensions, which means that they're now object comprehensions as well
This commit is contained in:
29
test/fixtures/generation/each.js
vendored
29
test/fixtures/generation/each.js
vendored
@@ -3,28 +3,31 @@
|
||||
// The cornerstone, an each implementation.
|
||||
// Handles objects implementing forEach, arrays, and raw objects.
|
||||
_.each = function each(obj, iterator, context) {
|
||||
var __a, __b, __c, __d, __e, __f, __g, __h, i, index, item, key;
|
||||
var __a, __b, __c, __d, __e, i, index, item, key;
|
||||
index = 0;
|
||||
try {
|
||||
if (obj.forEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (_.isArray(obj) || _.isArguments(obj)) {
|
||||
__a = obj;
|
||||
__d = [];
|
||||
for (__b=0, __c=__a.length; __b<__c; __b++) {
|
||||
item = __a[__b];
|
||||
i = __b;
|
||||
__d[__b] = iterator.call(context, item, i, obj);
|
||||
__b = [];
|
||||
for (i in __a) {
|
||||
if (__a.hasOwnProperty(i)) {
|
||||
item = __a[i];
|
||||
__b[i] = iterator.call(context, item, i, obj);
|
||||
}
|
||||
}
|
||||
__d;
|
||||
__b;
|
||||
} else {
|
||||
__e = _.keys(obj);
|
||||
__h = [];
|
||||
for (__f=0, __g=__e.length; __f<__g; __f++) {
|
||||
key = __e[__f];
|
||||
__h[__f] = iterator.call(context, obj[key], key, obj);
|
||||
__c = _.keys(obj);
|
||||
__e = [];
|
||||
for (__d in __c) {
|
||||
if (__c.hasOwnProperty(__d)) {
|
||||
key = __c[__d];
|
||||
__e[__d] = iterator.call(context, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
__h;
|
||||
__e;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e !== breaker) {
|
||||
|
||||
29
test/fixtures/generation/each_no_wrap.js
vendored
29
test/fixtures/generation/each_no_wrap.js
vendored
@@ -2,28 +2,31 @@
|
||||
// The cornerstone, an each implementation.
|
||||
// Handles objects implementing forEach, arrays, and raw objects.
|
||||
_.each = function each(obj, iterator, context) {
|
||||
var __a, __b, __c, __d, __e, __f, __g, __h, i, index, item, key;
|
||||
var __a, __b, __c, __d, __e, i, index, item, key;
|
||||
index = 0;
|
||||
try {
|
||||
if (obj.forEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (_.isArray(obj) || _.isArguments(obj)) {
|
||||
__a = obj;
|
||||
__d = [];
|
||||
for (__b=0, __c=__a.length; __b<__c; __b++) {
|
||||
item = __a[__b];
|
||||
i = __b;
|
||||
__d[__b] = iterator.call(context, item, i, obj);
|
||||
__b = [];
|
||||
for (i in __a) {
|
||||
if (__a.hasOwnProperty(i)) {
|
||||
item = __a[i];
|
||||
__b[i] = iterator.call(context, item, i, obj);
|
||||
}
|
||||
}
|
||||
__d;
|
||||
__b;
|
||||
} else {
|
||||
__e = _.keys(obj);
|
||||
__h = [];
|
||||
for (__f=0, __g=__e.length; __f<__g; __f++) {
|
||||
key = __e[__f];
|
||||
__h[__f] = iterator.call(context, obj[key], key, obj);
|
||||
__c = _.keys(obj);
|
||||
__e = [];
|
||||
for (__d in __c) {
|
||||
if (__c.hasOwnProperty(__d)) {
|
||||
key = __c[__d];
|
||||
__e[__d] = iterator.call(context, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
__h;
|
||||
__e;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e !== breaker) {
|
||||
|
||||
Reference in New Issue
Block a user