@taichunmin/crc
Version:
A cross platform alternative for calculating Cyclic Redundancy Checks (CRC) values.
2 lines (1 loc) • 1.35 kB
JavaScript
;function E(t){let x=typeof t;return t!=null&&(x==="object"||x==="function")}function e(t,x,n){if(!E(t)||!Array.isArray(x)||x.length<1)return t;let A=t;for(let r of x.slice(0,-1))E(A[r])||(A[r]={}),A=A[r];return A[x.at(-1)]=n,t}var o=new Uint8Array(1),l=new Uint16Array(1),g=new Uint32Array(1);var y=new Uint8Array([0,47,94,113,188,147,226,205,87,120,9,38,235,196,181,154,174,129,240,223,18,61,76,99,249,214,167,136,69,106,27,52,115,92,45,2,207,224,145,190,36,11,122,85,152,183,198,233,221,242,131,172,97,78,63,16,138,165,212,251,54,25,104,71,230,201,184,151,90,117,4,43,177,158,239,192,13,34,83,124,72,103,22,57,244,219,170,133,31,48,65,110,163,140,253,210,149,186,203,228,41,6,119,88,194,237,156,179,126,81,32,15,59,20,101,74,135,168,217,246,108,67,50,29,208,255,142,161,227,204,189,146,95,112,1,46,180,155,234,197,8,39,86,121,77,98,19,60,241,222,175,128,26,53,68,107,166,137,248,215,144,191,206,225,44,3,114,93,199,232,153,182,123,84,37,10,62,17,96,79,130,173,220,243,105,70,55,24,213,250,139,164,5,42,91,116,185,150,231,200,82,125,12,35,238,193,176,159,171,132,245,218,23,56,73,102,252,211,162,141,64,111,30,49,118,89,40,7,202,229,148,187,33,14,127,80,157,178,195,236,216,247,134,169,100,75,58,21,143,160,209,254,51,28,109,66]),C=255;function B(t=new Uint8Array,x=0){o[0]=x^C;for(let n of t)o[0]=y[o[0]^n];return o[0]^C}module.exports=B;