MCPcopy Index your code
hub / github.com/angular/angular / fingerprint

Function fingerprint

packages/compiler/src/i18n/digest.ts:208–222  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

206 * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
207 */
208export function fingerprint(str: string): bigint {
209 textEncoder ??= new TextEncoder();
210 const utf8 = textEncoder.encode(str);
211 const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);
212
213 let hi = hash32(view, utf8.length, 0);
214 let lo = hash32(view, utf8.length, 102072);
215
216 if (hi == 0 && (lo == 0 || lo == 1)) {
217 hi = hi ^ 0x130f9bef;
218 lo = lo ^ -0x6b5f56d8;
219 }
220
221 return (BigInt.asUintN(32, BigInt(hi)) << BigInt(32)) | BigInt.asUintN(32, BigInt(lo));
222}
223
224export function computeMsgId(msg: string, meaning: string = ''): string {
225 let msgFingerprint = fingerprint(msg);

Callers 1

computeMsgIdFunction · 0.85

Calls 1

hash32Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…