import createHash from 'create-hash' ; export function hashWithSalt ( value , salt ) { const hash = createHash ( 'sha256' ) ; hash . update ( salt ) ; hash . update ( String ( value ) ) ; return hash . digest ( 'hex' ) ; } export function hashArray ( values , salt ) { return values . map ( ( val ) => hashWithSalt ( val , salt ) ) ; } export function hashObject ( obj , salt ) ; export function hashObject ( obj , salt ) ; export function hashObject ( obj , salt ) { return Object . fromEntries ( Object . entries ( obj ) . filter ( ( [ , value ] ) => value !== undefined ) . map ( ( [ key , value ] ) => [ hashWithSalt ( key , salt ) , Array . isArray ( value ) ? hashArray ( value , salt ) : hashWithSalt ( value , salt ) , ] ) ) ; } export default hashObject ;