MCPcopy Index your code
hub / github.com/hoothin/UserScripts / crc32str

Function crc32str

Picviewer CE+/Picviewer CE+.user.js:530–540  ·  view source on GitHub ↗

* Compute the crc32 of a string. * This is almost the same as the function crc32, but for strings. Using the * same function for the two use cases leads to horrible performances. * @param {Number} crc the starting value of the crc. * @param {String} str the string to use. * @param {Number} len

(crc, str, len, pos)

Source from the content-addressed store, hash-verified

528 * @return {Number} the computed crc32.
529 */
530function crc32str(crc, str, len, pos) {
531 var t = crcTable, end = pos + len;
532
533 crc = crc ^ (-1);
534
535 for (var i = pos; i < end; i++ ) {
536 crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];
537 }
538
539 return (crc ^ (-1)); // >>> 0;
540}
541
542module.exports = function crc32wrapper(input, crc) {
543 if (typeof input === "undefined" || !input.length) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected