Using underscore for an any() function.

This commit is contained in:
Jeremy Ashkenas
2010-02-13 02:29:37 -05:00
parent e6a53bd852
commit 1ab3b183a8
2 changed files with 5 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
process.mixin require './scope'
_: require('./underscore')._
# Some helper functions
@@ -38,11 +39,6 @@ merge: (src, dest) ->
(fresh[key]: val) for key, val of dest
fresh
# Do any of the elements in the list pass a truth test?
any: (list, test) ->
result: true for item in list when test(item)
!!result.length
# Delete a key from an object, returning the value.
del: (obj, key) ->
val: obj[key]
@@ -337,7 +333,7 @@ CallNode: exports.CallNode: inherit Node, {
# Compile a vanilla function call.
compile_node: (o) ->
return @compile_splat(o) if any @args, (a) -> a instanceof SplatNode
return @compile_splat(o) if _.any @args, (a) -> a instanceof SplatNode
args: (arg.compile(o) for arg in @args).join(', ')
return @compile_super(args, o) if @variable is 'super'
@prefix + @variable.compile(o) + '(' + args + ')'