Travis build: 337

This commit is contained in:
Travis CI
2017-12-27 08:31:05 +00:00
parent a0d3a2c14b
commit db61edf65d
3 changed files with 35 additions and 0 deletions

View File

@ -177,6 +177,7 @@
### _Uncategorized_
* [`pipeFunctions`](#pipefunctions)
* [`randomHexColor`](#randomhexcolor)
* [`sdbmHashAlgorithm`](#sdbmhashalgorithm)
## Adapter
@ -2435,6 +2436,26 @@ const randomHexColor = () => {
// randomHexColorCode() -> "#4144c6"
```
[⬆ back to top](#table-of-contents)
### sdbmHashAlgorithm
This algorithm is a simple hash-algorithm that hashes it input string `s` into a whole number.
Use `split('')` and `Array.reduce()` to create a hash of the input string, utilizing bit shifting.
``` js
const sdbm = str => {
let arr = str.split('');
return arr.reduce((hashCode, currentVal) =>
hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode
,0)
}
// console.log(sdbm("name")) // -3521204949
// console.log(sdbm("age")) // 808122783
```
[⬆ back to top](#table-of-contents)
## Credits

View File

@ -238,6 +238,7 @@
<h3>Uncategorized
</h3><a class="sublink-1" href="#pipefunctions">pipeFunctions</a>
<a class="sublink-1" href="#randomhexcolor">randomHexColor</a>
<a class="sublink-1" href="#sdbmhashalgorithm">sdbmHashAlgorithm</a>
</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height:100%;overflow-y:auto;background:#eceef2;padding:0"><a id="top">&nbsp;</a><h2 style="text-align:center">Adapter</h2>
<div class="card fluid"><div class="section double-padded"><h3 id="call">call</h3></div><div class="section double-padded">
@ -1523,6 +1524,18 @@ multiplyAndAdd5(5, 2) -&gt; 15
// randomHexColorCode() -&gt; &quot;#fd73a6&quot;
// randomHexColorCode() -&gt; &quot;#4144c6&quot;
</code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="sdbmhashalgorithm">sdbmHashAlgorithm</h3></div><div class="section double-padded">
<p>This algorithm is a simple hash-algorithm that hashes it input string <code>s</code> into a whole number.</p>
<p>Use <code>split('')</code> and <code>Array.reduce()</code> to create a hash of the input string, utilizing bit shifting.</p>
<pre><code class="language-js">const sdbm = str =&gt; {
let arr = str.split('');
return arr.reduce((hashCode, currentVal) =&gt;
hashCode = currentVal.charCodeAt(0) + (hashCode &lt;&lt; 6) + (hashCode &lt;&lt; 16) - hashCode
,0)
}
// console.log(sdbm(&quot;name&quot;)) // -3521204949
// console.log(sdbm(&quot;age&quot;)) // 808122783
</code></pre>
</div></div><br/>
<footer>
<p style="display:inline-block"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br/>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/">CC 3.0 BY</a>.<br/>Ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> is licensed by <a href="https://opensource.org/licenses/MIT">The MIT License</a><br/>Built with the <a href="https://minicss.org">mini.css framework</a>.</p>

View File

@ -107,6 +107,7 @@ round:math
runPromisesInSeries:function
sample:array
scrollToTop:browser
sdbmHashAlgorithm:uncategorized
select:object
shallowClone:object
shuffle:array