2012-03-26 17 views

回答

9

这些函数似乎是供CoffeeScript编译器专用的。如果您需要这些功能,使用通用库如Underscore.js可能会更好。

coffee> _ = require('underscore') 
coffee> _.flatten [1, 2, 3, [4, 5]] 
[ 1, 2, 3, 4, 5 ] 
+0

正是。 'helpers.coffee'只存在,以便CoffeeScript编译器不需要像Underscore这样的外部依赖。 – 2012-03-26 15:07:56

+1

只是一个注意事项,在咖啡壳中,_已被用作代表先前值的关键字。所以使用'u = require('underscore')''u.flatten [1,2,3,[4,5]]' – user1012566 2012-04-04 01:37:24