mtcute/packages/tl-utils/src/ctor-id.ts

14 lines
346 B
TypeScript
Raw Normal View History

import CRC32 from 'crc-32'
import { writeTlEntryToString } from './stringify.js'
import { TlEntry } from './types.js'
2022-08-29 14:33:11 +03:00
/**
* Computes the constructor id for a given TL entry.
*
* @param entry TL entry
*/
export function computeConstructorIdFromEntry(entry: TlEntry): number {
return CRC32.str(writeTlEntryToString(entry, true)) >>> 0
}