-
richard.petersen authoredrichard.petersen authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
util.js 613 B
import path from 'path'
// totaly awesome hash function. Do not use this for encryption (crypto.subtle.digest etc would be overkill for this)
export function hash (array) {
const string = JSON.stringify(array)
if (!string.length) throw new Error('TypeError: Unexpected data to calculate hash from')
let hash = 0
let char
for (let i = 0; i < string.length; i++) {
char = string.charCodeAt(i)
hash = ((hash << 5) - hash) + char
hash |= 0
}
return new Uint32Array([hash]).toString()
}
export function isJSFile (name) {
const extname = path.extname(name)
return extname === '.js'
}