Skip to content

Commit beb2b37

Browse files
wip(tools): refactor hash() function
1 parent 340c5ec commit beb2b37

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/tools.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ export function formatErrorStartEnd(message : string, path : string, source : st
8888
/**
8989
* @internal
9090
*/
91-
export function hash(...valueList : string[]) : string {
92-
const hashInstance = new SparkMD5();
93-
valueList.forEach(val => hashInstance.append(val ? val : ""))
94-
return hashInstance.end().slice(0, 8);
91+
export function hash(...valueList : string[]) : string {
92+
93+
return valueList.reduce((hashInstance, val) => hashInstance.append(val ? val : ""), new SparkMD5()).end().slice(0, 8);
9594
}
9695

9796

0 commit comments

Comments
 (0)