Travis build: 1111

This commit is contained in:
30secondsofcode
2019-04-13 07:38:40 +00:00
parent 0a16580474
commit 910dd5c248
7 changed files with 18 additions and 19 deletions

View File

@ -4730,6 +4730,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true
@ -8834,7 +8835,7 @@ isBoolean(false); // true
### isEmpty
Returns true if the a value is an empty object, collection, map or set, has no enumerable properties or is any type that is not considered a collection.
Returns true if the a value is an empty object, collection, has no enumerable properties or is any type that is not considered a collection.
Check if the provided value is `null` or if its `length` is equal to `0`.
@ -8846,8 +8847,6 @@ const isEmpty = val => val == null || !(Object.keys(val) || val).length;
<summary>Examples</summary>
```js
isEmpty(new Map()); // true
isEmpty(new Set()); // true
isEmpty([]); // true
isEmpty({}); // true
isEmpty(''); // true

View File

@ -150,6 +150,7 @@ console<span class="token punctuation">.</span><span class="token function">log<
<span class="token keyword">const</span> lengthIs4 <span class="token operator">=</span> <span class="token function">checkProp</span><span class="token punctuation">(</span>l <span class="token operator">=></span> l <span class="token operator">===</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">);</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([]);</span> <span class="token comment">// false</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]);</span> <span class="token comment">// true</span>

View File

@ -117,10 +117,8 @@
</pre></div><div class="card code-card"><div class="corner beginner"></div><div class="section card-content"><h4 id="isboolean">isBoolean</h4><p>Checks if the given argument is a native boolean element.</p><p>Use <code>typeof</code> to check if a value is classified as a boolean primitive.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">isBoolean</span> <span class="token operator">=</span> val <span class="token operator">=></span> <span class="token keyword">typeof</span> val <span class="token operator">===</span> <span class="token string">'boolean'</span><span class="token punctuation">;</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">isBoolean</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">);</span> <span class="token comment">// false</span>
<span class="token function">isBoolean</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">);</span> <span class="token comment">// true</span>
</pre></div><div class="card code-card"><div class="corner beginner"></div><div class="section card-content"><h4 id="isempty">isEmpty</h4><p>Returns true if the a value is an empty object, collection, map or set, has no enumerable properties or is any type that is not considered a collection.</p><p>Check if the provided value is <code>null</code> or if its <code>length</code> is equal to <code>0</code>.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">isEmpty</span> <span class="token operator">=</span> val <span class="token operator">=></span> val <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token operator">|| !</span><span class="token punctuation">(</span>Object<span class="token punctuation">.</span><span class="token function">keys</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token operator">||</span> val<span class="token punctuation">).</span>length<span class="token punctuation">;</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Map</span><span class="token punctuation">());</span> <span class="token comment">// true</span>
<span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Set</span><span class="token punctuation">());</span> <span class="token comment">// true</span>
<span class="token function">isEmpty</span><span class="token punctuation">([]);</span> <span class="token comment">// true</span>
</pre></div><div class="card code-card"><div class="corner beginner"></div><div class="section card-content"><h4 id="isempty">isEmpty</h4><p>Returns true if the a value is an empty object, collection, has no enumerable properties or is any type that is not considered a collection.</p><p>Check if the provided value is <code>null</code> or if its <code>length</code> is equal to <code>0</code>.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">isEmpty</span> <span class="token operator">=</span> val <span class="token operator">=></span> val <span class="token operator">==</span> <span class="token keyword">null</span> <span class="token operator">|| !</span><span class="token punctuation">(</span>Object<span class="token punctuation">.</span><span class="token function">keys</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token operator">||</span> val<span class="token punctuation">).</span>length<span class="token punctuation">;</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">isEmpty</span><span class="token punctuation">([]);</span> <span class="token comment">// true</span>
<span class="token function">isEmpty</span><span class="token punctuation">({});</span> <span class="token comment">// true</span>
<span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">);</span> <span class="token comment">// true</span>
<span class="token function">isEmpty</span><span class="token punctuation">([</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]);</span> <span class="token comment">// false</span>

View File

@ -15,6 +15,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true