mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
Using underscore for an any() function.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
(function(){
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, any, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var AccessorNode, ArrayNode, AssignNode, CallNode, ClosureNode, CodeNode, CommentNode, ExistenceNode, Expressions, ExtendsNode, ForNode, IDENTIFIER, IfNode, IndexNode, LiteralNode, Node, ObjectNode, OpNode, ParentheticalNode, PushNode, RangeNode, ReturnNode, SliceNode, SplatNode, TAB, TRAILING_WHITESPACE, ThisNode, ThrowNode, TryNode, ValueNode, WhileNode, _, compact, del, dup, flatten, inherit, merge, statement;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
process.mixin(require('./scope'));
|
||||
_ = require('./underscore')._;
|
||||
// Some helper functions
|
||||
// Tabs are two spaces for pretty printing.
|
||||
TAB = ' ';
|
||||
@@ -77,21 +78,6 @@
|
||||
}
|
||||
return fresh;
|
||||
};
|
||||
// Do any of the elements in the list pass a truth test?
|
||||
any = function any(list, test) {
|
||||
var __a, __b, __c, item, result;
|
||||
result = (function() {
|
||||
__a = []; __b = list;
|
||||
for (__c = 0; __c < __b.length; __c++) {
|
||||
item = __b[__c];
|
||||
if (test(item)) {
|
||||
__a.push(true);
|
||||
}
|
||||
}
|
||||
return __a;
|
||||
}).call(this);
|
||||
return !!result.length;
|
||||
};
|
||||
// Delete a key from an object, returning the value.
|
||||
del = function del(obj, key) {
|
||||
var val;
|
||||
@@ -457,7 +443,7 @@
|
||||
// Compile a vanilla function call.
|
||||
compile_node: function compile_node(o) {
|
||||
var __a, __b, __c, arg, args;
|
||||
if (any(this.args, function(a) {
|
||||
if (_.any(this.args, function(a) {
|
||||
return a instanceof SplatNode;
|
||||
})) {
|
||||
return this.compile_splat(o);
|
||||
|
||||
Reference in New Issue
Block a user