mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixing #723; switch cases not iterated by eachChild.
This commit is contained in:
parent
8f96f5f20f
commit
52e7d9a672
2 changed files with 24 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
(function() {
|
||||
var extend, indexOf;
|
||||
var extend, flatten, indexOf;
|
||||
indexOf = (exports.indexOf = Array.indexOf || (Array.prototype.indexOf ? function(array, item, from) {
|
||||
return array.indexOf(item, from);
|
||||
} : function(array, item, from) {
|
||||
|
@ -55,9 +55,20 @@
|
|||
}
|
||||
return object;
|
||||
});
|
||||
exports.flatten = function(array) {
|
||||
return array.concat.apply([], array);
|
||||
};
|
||||
exports.flatten = (flatten = function(array) {
|
||||
var _i, _len, _ref, element, flattened;
|
||||
flattened = [];
|
||||
_ref = array;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
element = _ref[_i];
|
||||
if (Array.isArray(element)) {
|
||||
flattened = flattened.concat(flatten(element));
|
||||
} else {
|
||||
flattened.push(element);
|
||||
}
|
||||
}
|
||||
return flattened;
|
||||
});
|
||||
exports.del = function(obj, key) {
|
||||
var val;
|
||||
val = obj[key];
|
||||
|
|
|
@ -50,10 +50,16 @@ extend = exports.extend = (object, properties) ->
|
|||
object[key] = val
|
||||
object
|
||||
|
||||
# Return a flattened version of an array (shallow and nonrecursive).
|
||||
# Return a flattened version of an array.
|
||||
# Handy for getting a list of `children` from the nodes.
|
||||
exports.flatten = (array) ->
|
||||
array.concat.apply [], array
|
||||
exports.flatten = flatten = (array) ->
|
||||
flattened = []
|
||||
for element in array
|
||||
if Array.isArray(element)
|
||||
flattened = flattened.concat flatten(element)
|
||||
else
|
||||
flattened.push element
|
||||
flattened
|
||||
|
||||
# Delete a key from an object, returning the value. Useful when a node is
|
||||
# looking for a particular method in an options hash.
|
||||
|
|
Loading…
Reference in a new issue