-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/rel/1.0' into fwdport
- Loading branch information
Showing
11 changed files
with
137 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module.exports = { | ||
db: require('./lib/db'), | ||
shuffle: require('./lib/shuffle'), | ||
errors: require('./lib/errors.js'), | ||
shuffle: require('./lib/shuffle'), | ||
stringHash: require('./lib/stringHash'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict';// eslint-disable-line strict | ||
|
||
/** | ||
* This function compute a hash from a string | ||
* https://github.com/darkskyapp/string-hash/blob/master/index.js | ||
* @param {String} str - The string to compute the hash | ||
* @return {Number} The computed hash | ||
*/ | ||
function stringHash(str) { | ||
let hash = 5381; | ||
let i = str.length; | ||
|
||
while (i) { | ||
hash = hash * 33 ^ str.charCodeAt(--i); | ||
} | ||
|
||
/* JavaScript does bitwise operations (like XOR, above) on | ||
* 32-bit signed integers. Since we want the results to be | ||
* always positive, convert the signed int to an unsigned by | ||
* doing an unsigned bitshift. | ||
*/ | ||
return hash >>> 0; | ||
} | ||
|
||
module.exports = stringHash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.