lodash-contrib
Version:
The brass buckles on lodash's utility belt
282 lines (196 loc) • 8.72 kB
HTML
<html>
<head>
<title>_.util.existential.js.md</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="_.array.builders.js.html">
_.array.builders.js.md
</a>
<a class="source" href="_.array.selectors.js.html">
_.array.selectors.js.md
</a>
<a class="source" href="_.collections.walk.js.html">
_.collections.walk.js.md
</a>
<a class="source" href="_.function.arity.js.html">
_.function.arity.js.md
</a>
<a class="source" href="_.function.combinators.js.html">
_.function.combinators.js.md
</a>
<a class="source" href="_.function.iterators.js.html">
_.function.iterators.js.md
</a>
<a class="source" href="_.function.predicates.js.html">
_.function.predicates.js.md
</a>
<a class="source" href="_.object.builders.js.html">
_.object.builders.js.md
</a>
<a class="source" href="_.object.selectors.js.html">
_.object.selectors.js.md
</a>
<a class="source" href="_.util.existential.js.html">
_.util.existential.js.md
</a>
<a class="source" href="_.util.operators.js.html">
_.util.operators.js.md
</a>
<a class="source" href="_.util.strings.js.html">
_.util.strings.js.md
</a>
<a class="source" href="_.util.trampolines.js.html">
_.util.trampolines.js.md
</a>
<a class="source" href="index.html">
index.md
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>_.util.existential.js.md</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
<h3 id="util-existential">util.existential</h3>
<blockquote>
<p>Functions which deal with whether a value “exists.”</p>
</blockquote>
<hr>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<h4 id="exists">exists</h4>
<p><strong>Signature:</strong> <code>_.exists(value:Any)</code></p>
<p>Checks whether or not the value is “existy.” Both <code>null</code> and <code>undefined</code> are
considered non-existy values. All other values are existy.</p>
<pre><code class="lang-javascript">_.exists(<span class="hljs-literal">null</span>);
<span class="hljs-comment">// => false</span>
_.exists(<span class="hljs-literal">undefined</span>);
<span class="hljs-comment">// => false</span>
_.exists({});
<span class="hljs-comment">// = > true</span>
_.exists(<span class="hljs-string">"Sparta"</span>);
<span class="hljs-comment">// => true</span>
</code></pre>
<hr>
</div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<h4 id="falsey">falsey</h4>
<p><strong>Signature:</strong> <code>_.falsey(value:Any)</code></p>
<p>Checks whether the value is falsey. A falsey value is one which coerces to
<code>false</code> in a boolean context.</p>
<pre><code class="lang-javascript">_.falsey(<span class="hljs-number">0</span>);
<span class="hljs-comment">// => true</span>
_.falsey(<span class="hljs-string">""</span>);
<span class="hljs-comment">// => true</span>
_.falsey({});
<span class="hljs-comment">// => false</span>
_.falsey(<span class="hljs-string">"Corinth"</span>);
<span class="hljs-comment">// => false</span>
</code></pre>
<hr>
</div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<h4 id="firstexisting">firstExisting</h4>
<p><strong>Signature:</strong> <code>_.firstExisting(value:Any[, value:Any...])</code></p>
<p>Returns the first existy argument from the argument list.</p>
<pre><code class="lang-javascript">_.firstExisting(<span class="hljs-string">"Socrates"</span>, <span class="hljs-string">"Plato"</span>);
<span class="hljs-comment">// => "Socrates"</span>
_.firstExisting(<span class="hljs-literal">null</span>, <span class="hljs-literal">undefined</span>, <span class="hljs-string">"Heraclitus"</span>);
<span class="hljs-comment">// => "Heraclitus"</span>
</code></pre>
<hr>
</div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<h4 id="not">not</h4>
<p><strong>Signature:</strong> <code>_.not(value:Any)</code></p>
<p>Returns a boolean which is the opposite of the truthiness of the original value.</p>
<pre><code class="lang-javascript">_.not(<span class="hljs-number">0</span>);
<span class="hljs-comment">// => true</span>
_.not(<span class="hljs-number">1</span>);
<span class="hljs-comment">// => false</span>
_.not(<span class="hljs-literal">true</span>);
<span class="hljs-comment">// => false</span>
_.not(<span class="hljs-literal">false</span>);
<span class="hljs-comment">// => true</span>
_.not({});
<span class="hljs-comment">// => false</span>
_.not(<span class="hljs-literal">null</span>);
<span class="hljs-comment">// => true</span>
</code></pre>
<hr>
</div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">¶</a>
</div>
<h4 id="truthy">truthy</h4>
<p><strong>Signature:</strong> <code>_.truthy(value:Any)</code></p>
<p>Checks whether the value is truthy. A truthy value is one which coerces to
<code>true</code> in a boolean context.</p>
<pre><code class="lang-javascript">_.truthy({});
<span class="hljs-comment">// => true</span>
_.truthy(<span class="hljs-string">"Athens"</span>);
<span class="hljs-comment">// => true</span>
_.truthy(<span class="hljs-number">0</span>);
<span class="hljs-comment">// => false</span>
_.truthy(<span class="hljs-string">""</span>);
<span class="hljs-comment">// => false</span>
</code></pre>
<hr>
</div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">¶</a>
</div>
</div>
</li>
</ul>
</div>
</body>
</html>