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:
parent
eae53d4787
commit
2b94849429
4 changed files with 25 additions and 23 deletions
|
@ -316,6 +316,9 @@ coffee-script --print app/scripts/*.cs > concatenation.js</pre>
|
||||||
In addition, <tt>is</tt> compiles into <tt>===</tt>,
|
In addition, <tt>is</tt> compiles into <tt>===</tt>,
|
||||||
and <tt>aint</tt> into <tt>!==</tt>.
|
and <tt>aint</tt> into <tt>!==</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
You can use <tt>not</tt> as an alias for <tt>!</tt>.
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
As in <a href="http://yaml.org/">YAML</a>, <tt>on</tt> and <tt>yes</tt>
|
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>.
|
are the same as boolean <tt>true</tt>, while <tt>off</tt> and <tt>no</tt> are boolean <tt>false</tt>.
|
||||||
|
|
|
@ -99,7 +99,7 @@ while true
|
||||||
continue if continuing.
|
continue if continuing.
|
||||||
|
|
||||||
# Unary operators.
|
# Unary operators.
|
||||||
!!true
|
!true
|
||||||
|
|
||||||
# Lexical scoping.
|
# Lexical scoping.
|
||||||
a: 5
|
a: 5
|
||||||
|
|
|
@ -78,28 +78,24 @@ _.reduceRight: obj, memo, iterator, context =>
|
||||||
_.each(reversed, reverser)
|
_.each(reversed, reverser)
|
||||||
memo.
|
memo.
|
||||||
|
|
||||||
# # Return the first value which passes a truth test.
|
# Return the first value which passes a truth test.
|
||||||
# _.detect = function(obj, iterator, context) {
|
_.detect: obj, iterator, context =>
|
||||||
# var result;
|
result: null
|
||||||
# _.each(obj, function(value, index, list) {
|
_.each(obj, (value, index, list =>
|
||||||
# if (iterator.call(context, value, index, list)) {
|
if iterator.call(context, value, index, list)
|
||||||
# result = value;
|
result: value
|
||||||
# _.breakLoop();
|
_.breakLoop()..))
|
||||||
# }
|
result.
|
||||||
# });
|
|
||||||
# return result;
|
# Return all the elements that pass a truth test. Use JavaScript 1.6's
|
||||||
# };
|
# filter(), if it exists.
|
||||||
#
|
_.select: obj, iterator, context =>
|
||||||
# # Return all the elements that pass a truth test. Use JavaScript 1.6's
|
if obj and _.isFunction(obj.filter) then return obj.filter(iterator, context).
|
||||||
# # filter(), if it exists.
|
results: []
|
||||||
# _.select = function(obj, iterator, context) {
|
_.each(obj, (value, index, list =>
|
||||||
# if (obj && _.isFunction(obj.filter)) return obj.filter(iterator, context);
|
iterator.call(context, value, index, list) and results.push(value).))
|
||||||
# var results = [];
|
results.
|
||||||
# _.each(obj, function(value, index, list) {
|
|
||||||
# iterator.call(context, value, index, list) && results.push(value);
|
|
||||||
# });
|
|
||||||
# return results;
|
|
||||||
# };
|
|
||||||
#
|
#
|
||||||
# # Return all the elements for which a truth test fails.
|
# # Return all the elements for which a truth test fails.
|
||||||
# _.reject = function(obj, iterator, context) {
|
# _.reject = function(obj, iterator, context) {
|
||||||
|
|
|
@ -612,6 +612,9 @@ return [document.title, "Hello JavaScript"].join(": ");
|
||||||
In addition, <tt>is</tt> compiles into <tt>===</tt>,
|
In addition, <tt>is</tt> compiles into <tt>===</tt>,
|
||||||
and <tt>aint</tt> into <tt>!==</tt>.
|
and <tt>aint</tt> into <tt>!==</tt>.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
You can use <tt>not</tt> as an alias for <tt>!</tt>.
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
As in <a href="http://yaml.org/">YAML</a>, <tt>on</tt> and <tt>yes</tt>
|
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>.
|
are the same as boolean <tt>true</tt>, while <tt>off</tt> and <tt>no</tt> are boolean <tt>false</tt>.
|
||||||
|
|
Loading…
Add table
Reference in a new issue