mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
switched from alphabetical __a __b temporary variables, to numeric _1, _2, which will be shorter in most cases
This commit is contained in:
@@ -40,22 +40,22 @@
|
||||
// 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, i, index, key, val;
|
||||
var _1, _2, _3, _4, _5, _6, i, index, key, val;
|
||||
index = 0;
|
||||
try {
|
||||
if (obj.forEach) {
|
||||
return obj.forEach(iterator, context);
|
||||
}
|
||||
if (_.isNumber(obj.length)) {
|
||||
__a = []; __d = 0; __e = obj.length;
|
||||
for (__c=0, i=__d; (__d <= __e ? i < __e : i > __e); (__d <= __e ? i += 1 : i -= 1), __c++) {
|
||||
__a.push(iterator.call(context, obj[i], i, obj));
|
||||
_1 = []; _4 = 0; _5 = obj.length;
|
||||
for (_3=0, i=_4; (_4 <= _5 ? i < _5 : i > _5); (_4 <= _5 ? i += 1 : i -= 1), _3++) {
|
||||
_1.push(iterator.call(context, obj[i], i, obj));
|
||||
}
|
||||
return __a;
|
||||
return _1;
|
||||
}
|
||||
__f = obj;
|
||||
for (key in __f) if (__hasProp.call(__f, key)) {
|
||||
val = __f[key];
|
||||
_6 = obj;
|
||||
for (key in _6) if (__hasProp.call(_6, key)) {
|
||||
val = _6[key];
|
||||
iterator.call(context, val, key, obj);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -173,13 +173,13 @@
|
||||
// Determine if a given value is included in the array or object,
|
||||
// based on '==='.
|
||||
_.include = function include(obj, target) {
|
||||
var __a, key, val;
|
||||
var _1, key, val;
|
||||
if (obj && _.isFunction(obj.indexOf)) {
|
||||
return _.indexOf(obj, target) !== -1;
|
||||
}
|
||||
__a = obj;
|
||||
for (key in __a) if (__hasProp.call(__a, key)) {
|
||||
val = __a[key];
|
||||
_1 = obj;
|
||||
for (key in _1) if (__hasProp.call(_1, key)) {
|
||||
val = _1[key];
|
||||
if (val === target) {
|
||||
return true;
|
||||
}
|
||||
@@ -188,15 +188,15 @@
|
||||
};
|
||||
// Invoke a method with arguments on every item in a collection.
|
||||
_.invoke = function invoke(obj, method) {
|
||||
var __a, __b, __c, args, val;
|
||||
var _1, _2, _3, args, val;
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
args = _.rest(arguments, 2);
|
||||
__a = []; __b = obj;
|
||||
for (__c = 0; __c < __b.length; __c++) {
|
||||
val = __b[__c];
|
||||
__a.push((method ? val[method] : val).apply(val, args));
|
||||
_1 = []; _2 = obj;
|
||||
for (_3 = 0; _3 < _2.length; _3++) {
|
||||
val = _2[_3];
|
||||
_1.push((method ? val[method] : val).apply(val, args));
|
||||
}
|
||||
return __a;
|
||||
return _1;
|
||||
};
|
||||
// Convenience version of a common use case of map: fetching a property.
|
||||
_.pluck = function pluck(obj, key) {
|
||||
@@ -315,14 +315,14 @@
|
||||
};
|
||||
// Trim out all falsy values from an array.
|
||||
_.compact = function compact(array) {
|
||||
var __a, __b, __c, __d, __e, i;
|
||||
__a = []; __d = 0; __e = array.length;
|
||||
for (__c=0, i=__d; (__d <= __e ? i < __e : i > __e); (__d <= __e ? i += 1 : i -= 1), __c++) {
|
||||
var _1, _2, _3, _4, _5, i;
|
||||
_1 = []; _4 = 0; _5 = array.length;
|
||||
for (_3=0, i=_4; (_4 <= _5 ? i < _5 : i > _5); (_4 <= _5 ? i += 1 : i -= 1), _3++) {
|
||||
if (array[i]) {
|
||||
__a.push(array[i]);
|
||||
_1.push(array[i]);
|
||||
}
|
||||
}
|
||||
return __a;
|
||||
return _1;
|
||||
};
|
||||
// Return a completely flattened version of an array.
|
||||
_.flatten = function flatten(array) {
|
||||
@@ -336,26 +336,26 @@
|
||||
};
|
||||
// Return a version of the array that does not contain the specified value(s).
|
||||
_.without = function without(array) {
|
||||
var __a, __b, __c, val, values;
|
||||
var _1, _2, _3, val, values;
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
values = _.rest(arguments);
|
||||
__a = []; __b = _.toArray(array);
|
||||
for (__c = 0; __c < __b.length; __c++) {
|
||||
val = __b[__c];
|
||||
_1 = []; _2 = _.toArray(array);
|
||||
for (_3 = 0; _3 < _2.length; _3++) {
|
||||
val = _2[_3];
|
||||
if (!_.include(values, val)) {
|
||||
__a.push(val);
|
||||
_1.push(val);
|
||||
}
|
||||
}
|
||||
return __a;
|
||||
return _1;
|
||||
};
|
||||
// Produce a duplicate-free version of the array. If the array has already
|
||||
// been sorted, you have the option of using a faster algorithm.
|
||||
_.uniq = function uniq(array, isSorted) {
|
||||
var __a, el, i, memo;
|
||||
var _1, el, i, memo;
|
||||
memo = [];
|
||||
__a = _.toArray(array);
|
||||
for (i = 0; i < __a.length; i++) {
|
||||
el = __a[i];
|
||||
_1 = _.toArray(array);
|
||||
for (i = 0; i < _1.length; i++) {
|
||||
el = _1[i];
|
||||
if (i === 0 || (isSorted === true ? _.last(memo) !== el : !_.include(memo, el))) {
|
||||
memo.push(el);
|
||||
}
|
||||
@@ -377,12 +377,12 @@
|
||||
// Zip together multiple lists into a single array -- elements that share
|
||||
// an index go together.
|
||||
_.zip = function zip() {
|
||||
var __a, __b, __c, __d, i, length, results;
|
||||
var _1, _2, _3, _4, i, length, results;
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
length = _.max(_.pluck(arguments, 'length'));
|
||||
results = new Array(length);
|
||||
__c = 0; __d = length;
|
||||
for (__b=0, i=__c; (__c <= __d ? i < __d : i > __d); (__c <= __d ? i += 1 : i -= 1), __b++) {
|
||||
_3 = 0; _4 = length;
|
||||
for (_2=0, i=_3; (_3 <= _4 ? i < _4 : i > _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
|
||||
results[i] = _.pluck(arguments, String(i));
|
||||
}
|
||||
return results;
|
||||
@@ -427,7 +427,7 @@
|
||||
// the native Python range() function. See:
|
||||
// http://docs.python.org/library/functions.html#range
|
||||
_.range = function range(start, stop, step) {
|
||||
var __a, a, i, idx, len, range, solo;
|
||||
var _1, a, i, idx, len, range, solo;
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
a = arguments;
|
||||
solo = a.length <= 1;
|
||||
@@ -440,7 +440,7 @@
|
||||
}
|
||||
range = new Array(len);
|
||||
idx = 0;
|
||||
__a = [];
|
||||
_1 = [];
|
||||
while (true) {
|
||||
if ((step > 0 ? i - stop : stop - i) >= 0) {
|
||||
return range;
|
||||
@@ -449,7 +449,7 @@
|
||||
idx++;
|
||||
i += step;
|
||||
}
|
||||
return __a;
|
||||
return _1;
|
||||
};
|
||||
// ----------------------- Function Functions: -----------------------------
|
||||
// Create a function bound to a given object (assigning 'this', and arguments,
|
||||
@@ -506,11 +506,11 @@
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
funcs = arguments;
|
||||
return (function() {
|
||||
var __a, __b, __c, __d, args, i;
|
||||
var _1, _2, _3, _4, args, i;
|
||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||
args = arguments;
|
||||
__c = (funcs.length - 1); __d = 0;
|
||||
for (__b=0, i=__c; (__c <= __d ? i <= __d : i >= __d); (__c <= __d ? i += 1 : i -= 1), __b++) {
|
||||
_3 = (funcs.length - 1); _4 = 0;
|
||||
for (_2=0, i=_3; (_3 <= _4 ? i <= _4 : i >= _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
|
||||
args = [funcs[i].apply(this, args)];
|
||||
}
|
||||
return args[0];
|
||||
@@ -519,16 +519,16 @@
|
||||
// ------------------------- Object Functions: ----------------------------
|
||||
// Retrieve the names of an object's properties.
|
||||
_.keys = function keys(obj) {
|
||||
var __a, __b, key, val;
|
||||
var _1, _2, key, val;
|
||||
if (_.isArray(obj)) {
|
||||
return _.range(0, obj.length);
|
||||
}
|
||||
__a = []; __b = obj;
|
||||
for (key in __b) if (__hasProp.call(__b, key)) {
|
||||
val = __b[key];
|
||||
__a.push(key);
|
||||
_1 = []; _2 = obj;
|
||||
for (key in _2) if (__hasProp.call(_2, key)) {
|
||||
val = _2[key];
|
||||
_1.push(key);
|
||||
}
|
||||
return __a;
|
||||
return _1;
|
||||
};
|
||||
// Retrieve the values of an object's properties.
|
||||
_.values = function values(obj) {
|
||||
@@ -542,10 +542,10 @@
|
||||
};
|
||||
// Extend a given object with all of the properties in a source object.
|
||||
_.extend = function extend(destination, source) {
|
||||
var __a, key, val;
|
||||
__a = source;
|
||||
for (key in __a) if (__hasProp.call(__a, key)) {
|
||||
val = __a[key];
|
||||
var _1, key, val;
|
||||
_1 = source;
|
||||
for (key in _1) if (__hasProp.call(_1, key)) {
|
||||
val = _1[key];
|
||||
destination[key] = val;
|
||||
}
|
||||
return destination;
|
||||
|
||||
Reference in New Issue
Block a user