1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

ported over a little more underscore

This commit is contained in:
Jeremy Ashkenas 2009-12-23 21:09:32 -05:00
parent eae53d4787
commit 2b94849429
4 changed files with 25 additions and 23 deletions

View file

@ -316,6 +316,9 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
In addition, <tt>is</tt> compiles into <tt>===</tt>,
and <tt>aint</tt> into <tt>!==</tt>.
</p>
<p>
You can use <tt>not</tt> as an alias for <tt>!</tt>.
</p>
<p>
As in <a href="http://yaml.org/">YAML</a>, <tt>on</tt> and <tt>yes</tt>
are the same as boolean <tt>true</tt>, while <tt>off</tt> and <tt>no</tt> are boolean <tt>false</tt>.

View file

@ -99,7 +99,7 @@ while true
continue if continuing.
# Unary operators.
!!true
!true
# Lexical scoping.
a: 5

View file

@ -78,28 +78,24 @@ _.reduceRight: obj, memo, iterator, context =>
_.each(reversed, reverser)
memo.
# # Return the first value which passes a truth test.
# _.detect = function(obj, iterator, context) {
# var result;
# _.each(obj, function(value, index, list) {
# if (iterator.call(context, value, index, list)) {
# result = value;
# _.breakLoop();
# }
# });
# return result;
# };
#
# # Return all the elements that pass a truth test. Use JavaScript 1.6's
# # filter(), if it exists.
# _.select = function(obj, iterator, context) {
# if (obj && _.isFunction(obj.filter)) return obj.filter(iterator, context);
# var results = [];
# _.each(obj, function(value, index, list) {
# iterator.call(context, value, index, list) && results.push(value);
# });
# return results;
# };
# Return the first value which passes a truth test.
_.detect: obj, iterator, context =>
result: null
_.each(obj, (value, index, list =>
if iterator.call(context, value, index, list)
result: value
_.breakLoop()..))
result.
# Return all the elements that pass a truth test. Use JavaScript 1.6's
# filter(), if it exists.
_.select: obj, iterator, context =>
if obj and _.isFunction(obj.filter) then return obj.filter(iterator, context).
results: []
_.each(obj, (value, index, list =>
iterator.call(context, value, index, list) and results.push(value).))
results.
#
# # Return all the elements for which a truth test fails.
# _.reject = function(obj, iterator, context) {

View file

@ -612,6 +612,9 @@ return [document.title, "Hello JavaScript"].join(": ");
In addition, <tt>is</tt> compiles into <tt>===</tt>,
and <tt>aint</tt> into <tt>!==</tt>.
</p>
<p>
You can use <tt>not</tt> as an alias for <tt>!</tt>.
</p>
<p>
As in <a href="http://yaml.org/">YAML</a>, <tt>on</tt> and <tt>yes</tt>
are the same as boolean <tt>true</tt>, while <tt>off</tt> and <tt>no</tt> are boolean <tt>false</tt>.