From 88ca152be79b78f6e94bdd2d89c10d45310bbea8 Mon Sep 17 00:00:00 2001 From: Max Franz Date: Thu, 7 Dec 2017 16:55:17 -0500 Subject: [PATCH] Add the ability to hash lists of strings #2027 --- src/util/hash.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/util/hash.js b/src/util/hash.js index 59a43a85d9..fac8faf4c2 100644 --- a/src/util/hash.js +++ b/src/util/hash.js @@ -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 };