Travis build: 337
This commit is contained in:
21
README.md
21
README.md
@ -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
|
||||
|
||||
@ -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"> </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) -> 15
|
||||
// randomHexColorCode() -> "#fd73a6"
|
||||
// randomHexColorCode() -> "#4144c6"
|
||||
</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 => {
|
||||
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
|
||||
</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>
|
||||
|
||||
@ -107,6 +107,7 @@ round:math
|
||||
runPromisesInSeries:function
|
||||
sample:array
|
||||
scrollToTop:browser
|
||||
sdbmHashAlgorithm:uncategorized
|
||||
select:object
|
||||
shallowClone:object
|
||||
shuffle:array
|
||||
|
||||
Reference in New Issue
Block a user