Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static decodeHashId(hashId: string): DecodedHashId {
let hashids = new Hashids("");
if (hashId.startsWith(this.hashIdReadOnlyPrefix)) {
return {
id: hashids.decode(hashId.split(this.hashIdReadOnlyPrefix)[1])[0],
readOnly: true
}
} else {
return {
id: hashids.decode(hashId)[0],
readOnly: false
}
}
}
static encodeHashId(id: number, readOnly: boolean = false): string {
let hashids = new Hashids("");
if (!readOnly) {
return hashids.encode(id);
} else {
return this.hashIdReadOnlyPrefix + hashids.encode(id);
}
}