Skip to content

Commit

Permalink
Add the ability to hash lists of strings #2027
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkfranz committed Dec 8, 2017
1 parent cdf508d commit 88ca152
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/util/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,24 @@ let hashString = function( str, seed ){
return hashIterableInts( iterator, seed );
};

module.exports = { hashIterableInts, hashString };
let hashStrings = function(){
return hashStringsArray( arguments );
};

let hashStringsArray = function( strs ){
let hash;

for( let i = 0; i < strs.length; i++ ){
let str = strs[i];

if( i === 0 ){
hash = hashString( str );
} else {
hash = hashString( str, hash );
}
}

return hash;
};

module.exports = { hashIterableInts, hashString, hashStrings, hashStringsArray };

0 comments on commit 88ca152

Please sign in to comment.