UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

30 lines (29 loc) 953 B
import { hashCode } from "./index.js"; export default function idMaker(args, id = '', len = 5000) { const stack = [args]; while (stack.length) { const obj = stack.pop(); for (const [key, val] of Object.entries(obj)) { if (id.length > len) { return hashCode(id); } else { if (typeof val === 'object' && val !== null) { stack.push(val); } else { if (key === 'locationType' && val === 'FileHandleLocation') { id += `${key}-BlobLocation`; } else if (key === 'handleId') { id += `blobId-fh-blob-${val}`; } else { id += `${key}-${val}`; } } } } } return `adp-${hashCode(id)}`; }