How to use the hashids.default function in hashids

To help you get started, we’ve selected a few hashids examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dessalines / simple-vote / ui / src / app / shared / tools.class.ts View on Github external
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
			}
		}
	}
github dessalines / simple-vote / ui / src / app / shared / tools.class.ts View on Github external
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);
		}

	}

hashids

Generate YouTube-like ids from numbers. Use Hashids when you do not want to expose your database ids to the user.

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis

Popular hashids functions