Best JavaScript code snippet using wpt
parser.js
Source:parser.js
...32var _jpeg_stream = require('./jpeg_stream');33var _jpx_stream = require('./jpx_stream');34var MAX_LENGTH_TO_CACHE = 1000;35var MAX_ADLER32_LENGTH = 5552;36function computeAdler32(bytes) {37 var bytesLength = bytes.length;38 if (bytesLength >= MAX_ADLER32_LENGTH) {39 throw new Error('computeAdler32: The input is too large.');40 }41 var a = 1,42 b = 0;43 for (var i = 0; i < bytesLength; ++i) {44 a += bytes[i] & 0xFF;45 b += a;46 }47 return b % 65521 << 16 | a % 65521;48}49var Parser = function ParserClosure() {50 function Parser(lexer, allowStreams, xref, recoveryMode) {51 this.lexer = lexer;52 this.allowStreams = allowStreams;53 this.xref = xref;54 this.recoveryMode = recoveryMode || false;55 this.imageCache = Object.create(null);56 this.refill();57 }58 Parser.prototype = {59 refill: function Parser_refill() {60 this.buf1 = this.lexer.getObj();61 this.buf2 = this.lexer.getObj();62 },63 shift: function Parser_shift() {64 if ((0, _primitives.isCmd)(this.buf2, 'ID')) {65 this.buf1 = this.buf2;66 this.buf2 = null;67 } else {68 this.buf1 = this.buf2;69 this.buf2 = this.lexer.getObj();70 }71 },72 tryShift: function Parser_tryShift() {73 try {74 this.shift();75 return true;76 } catch (e) {77 if (e instanceof _util.MissingDataException) {78 throw e;79 }80 return false;81 }82 },83 getObj: function Parser_getObj(cipherTransform) {84 var buf1 = this.buf1;85 this.shift();86 if (buf1 instanceof _primitives.Cmd) {87 switch (buf1.cmd) {88 case 'BI':89 return this.makeInlineImage(cipherTransform);90 case '[':91 var array = [];92 while (!(0, _primitives.isCmd)(this.buf1, ']') && !(0, _primitives.isEOF)(this.buf1)) {93 array.push(this.getObj(cipherTransform));94 }95 if ((0, _primitives.isEOF)(this.buf1)) {96 if (!this.recoveryMode) {97 throw new _util.FormatError('End of file inside array');98 }99 return array;100 }101 this.shift();102 return array;103 case '<<':104 var dict = new _primitives.Dict(this.xref);105 while (!(0, _primitives.isCmd)(this.buf1, '>>') && !(0, _primitives.isEOF)(this.buf1)) {106 if (!(0, _primitives.isName)(this.buf1)) {107 (0, _util.info)('Malformed dictionary: key must be a name object');108 this.shift();109 continue;110 }111 var key = this.buf1.name;112 this.shift();113 if ((0, _primitives.isEOF)(this.buf1)) {114 break;115 }116 dict.set(key, this.getObj(cipherTransform));117 }118 if ((0, _primitives.isEOF)(this.buf1)) {119 if (!this.recoveryMode) {120 throw new _util.FormatError('End of file inside dictionary');121 }122 return dict;123 }124 if ((0, _primitives.isCmd)(this.buf2, 'stream')) {125 return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;126 }127 this.shift();128 return dict;129 default:130 return buf1;131 }132 }133 if (Number.isInteger(buf1)) {134 var num = buf1;135 if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, 'R')) {136 var ref = new _primitives.Ref(num, this.buf1);137 this.shift();138 this.shift();139 return ref;140 }141 return num;142 }143 if ((0, _util.isString)(buf1)) {144 var str = buf1;145 if (cipherTransform) {146 str = cipherTransform.decryptString(str);147 }148 return str;149 }150 return buf1;151 },152 findDefaultInlineStreamEnd: function findDefaultInlineStreamEnd(stream) {153 var E = 0x45,154 I = 0x49,155 SPACE = 0x20,156 LF = 0xA,157 CR = 0xD;158 var n = 10,159 NUL = 0x0;160 var startPos = stream.pos,161 state = 0,162 ch = void 0,163 maybeEIPos = void 0;164 while ((ch = stream.getByte()) !== -1) {165 if (state === 0) {166 state = ch === E ? 1 : 0;167 } else if (state === 1) {168 state = ch === I ? 2 : 0;169 } else {170 (0, _util.assert)(state === 2);171 if (ch === SPACE || ch === LF || ch === CR) {172 maybeEIPos = stream.pos;173 var followingBytes = stream.peekBytes(n);174 for (var i = 0, ii = followingBytes.length; i < ii; i++) {175 ch = followingBytes[i];176 if (ch === NUL && followingBytes[i + 1] !== NUL) {177 continue;178 }179 if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {180 state = 0;181 break;182 }183 }184 if (state === 2) {185 break;186 }187 } else {188 state = 0;189 }190 }191 }192 if (ch === -1) {193 (0, _util.warn)('findDefaultInlineStreamEnd: ' + 'Reached the end of the stream without finding a valid EI marker');194 if (maybeEIPos) {195 (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');196 stream.skip(-(stream.pos - maybeEIPos));197 }198 }199 return stream.pos - 4 - startPos;200 },201 findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {202 var startPos = stream.pos,203 foundEOI = false,204 b,205 markerLength,206 length;207 while ((b = stream.getByte()) !== -1) {208 if (b !== 0xFF) {209 continue;210 }211 switch (stream.getByte()) {212 case 0x00:213 break;214 case 0xFF:215 stream.skip(-1);216 break;217 case 0xD9:218 foundEOI = true;219 break;220 case 0xC0:221 case 0xC1:222 case 0xC2:223 case 0xC3:224 case 0xC5:225 case 0xC6:226 case 0xC7:227 case 0xC9:228 case 0xCA:229 case 0xCB:230 case 0xCD:231 case 0xCE:232 case 0xCF:233 case 0xC4:234 case 0xCC:235 case 0xDA:236 case 0xDB:237 case 0xDC:238 case 0xDD:239 case 0xDE:240 case 0xDF:241 case 0xE0:242 case 0xE1:243 case 0xE2:244 case 0xE3:245 case 0xE4:246 case 0xE5:247 case 0xE6:248 case 0xE7:249 case 0xE8:250 case 0xE9:251 case 0xEA:252 case 0xEB:253 case 0xEC:254 case 0xED:255 case 0xEE:256 case 0xEF:257 case 0xFE:258 markerLength = stream.getUint16();259 if (markerLength > 2) {260 stream.skip(markerLength - 2);261 } else {262 stream.skip(-2);263 }264 break;265 }266 if (foundEOI) {267 break;268 }269 }270 length = stream.pos - startPos;271 if (b === -1) {272 (0, _util.warn)('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');273 stream.skip(-length);274 return this.findDefaultInlineStreamEnd(stream);275 }276 this.inlineStreamSkipEI(stream);277 return length;278 },279 findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {280 var TILDE = 0x7E,281 GT = 0x3E;282 var startPos = stream.pos,283 ch,284 length;285 while ((ch = stream.getByte()) !== -1) {286 if (ch === TILDE && stream.peekByte() === GT) {287 stream.skip();288 break;289 }290 }291 length = stream.pos - startPos;292 if (ch === -1) {293 (0, _util.warn)('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');294 stream.skip(-length);295 return this.findDefaultInlineStreamEnd(stream);296 }297 this.inlineStreamSkipEI(stream);298 return length;299 },300 findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {301 var GT = 0x3E;302 var startPos = stream.pos,303 ch,304 length;305 while ((ch = stream.getByte()) !== -1) {306 if (ch === GT) {307 break;308 }309 }310 length = stream.pos - startPos;311 if (ch === -1) {312 (0, _util.warn)('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');313 stream.skip(-length);314 return this.findDefaultInlineStreamEnd(stream);315 }316 this.inlineStreamSkipEI(stream);317 return length;318 },319 inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {320 var E = 0x45,321 I = 0x49;322 var state = 0,323 ch;324 while ((ch = stream.getByte()) !== -1) {325 if (state === 0) {326 state = ch === E ? 1 : 0;327 } else if (state === 1) {328 state = ch === I ? 2 : 0;329 } else if (state === 2) {330 break;331 }332 }333 },334 makeInlineImage: function Parser_makeInlineImage(cipherTransform) {335 var lexer = this.lexer;336 var stream = lexer.stream;337 var dict = new _primitives.Dict(this.xref),338 dictLength = void 0;339 while (!(0, _primitives.isCmd)(this.buf1, 'ID') && !(0, _primitives.isEOF)(this.buf1)) {340 if (!(0, _primitives.isName)(this.buf1)) {341 throw new _util.FormatError('Dictionary key must be a name object');342 }343 var key = this.buf1.name;344 this.shift();345 if ((0, _primitives.isEOF)(this.buf1)) {346 break;347 }348 dict.set(key, this.getObj(cipherTransform));349 }350 if (lexer.beginInlineImagePos !== -1) {351 dictLength = stream.pos - lexer.beginInlineImagePos;352 }353 var filter = dict.get('Filter', 'F'),354 filterName;355 if ((0, _primitives.isName)(filter)) {356 filterName = filter.name;357 } else if (Array.isArray(filter)) {358 var filterZero = this.xref.fetchIfRef(filter[0]);359 if ((0, _primitives.isName)(filterZero)) {360 filterName = filterZero.name;361 }362 }363 var startPos = stream.pos,364 length = void 0;365 if (filterName === 'DCTDecode' || filterName === 'DCT') {366 length = this.findDCTDecodeInlineStreamEnd(stream);367 } else if (filterName === 'ASCII85Decode' || filterName === 'A85') {368 length = this.findASCII85DecodeInlineStreamEnd(stream);369 } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {370 length = this.findASCIIHexDecodeInlineStreamEnd(stream);371 } else {372 length = this.findDefaultInlineStreamEnd(stream);373 }374 var imageStream = stream.makeSubStream(startPos, length, dict);375 var cacheKey = void 0;376 if (length < MAX_LENGTH_TO_CACHE && dictLength < MAX_ADLER32_LENGTH) {377 var imageBytes = imageStream.getBytes();378 imageStream.reset();379 var initialStreamPos = stream.pos;380 stream.pos = lexer.beginInlineImagePos;381 var dictBytes = stream.getBytes(dictLength);382 stream.pos = initialStreamPos;383 cacheKey = computeAdler32(imageBytes) + '_' + computeAdler32(dictBytes);384 var cacheEntry = this.imageCache[cacheKey];385 if (cacheEntry !== undefined) {386 this.buf2 = _primitives.Cmd.get('EI');387 this.shift();388 cacheEntry.reset();389 return cacheEntry;390 }391 }392 if (cipherTransform) {393 imageStream = cipherTransform.createStream(imageStream, length);394 }395 imageStream = this.filter(imageStream, dict, length);396 imageStream.dict = dict;397 if (cacheKey !== undefined) {...
volume.ts
Source:volume.ts
1import { ComputeAdler32 } from './utils';2import { Reader, FileReader } from './reader';3const VOLUME_MAGIC = 0xA2B924CE;4export enum VolumeVersion {5 Windows = 0,6 Mac = 17}8export interface VolumeHeader {9 rawBytes: Buffer; 10 length: number; /**< Length in bytes of the header */11 version: VolumeVersion;12 sequence: number; /**< Index of this file in the archive. Incremented every single time a new file is created whether it be a volume, slice, etc. These provide a total ordering of alla files in an archive */13 14 // NOTE: I don't call these identifiers, because TI has separate 16-byte UUIDs stored in the files to be the identifiers15 archiveKey: Buffer; /**< Random 4byte identifier common to all files in this volume */16 sliceKey: Buffer; /**< Random 4bytes to identify this slice */17 volumeKey: Buffer; /**< Random 4bytes to identify this volume */18 checkSumValid: boolean; /**< Whether or the checksum of the header is valid */19 20 blockSize: number;21}22type VolumeGenerator = (fileName: string, reader: Reader, header: VolumeHeader) => Promise<Volume>;23const VolumeImpls: { [v: number]: VolumeGenerator } = {};24export default abstract class Volume {25 /**26 * Given a .tib file, this will open it and load basic information on it27 */28 public static async Open(fileName: string) {29 let reader = await FileReader.Create(fileName);30 let header: VolumeHeader;31 try {32 header = await this.LoadHeader(reader);33 }34 catch(e) {35 // TODO: It is annoying that this is redundant with the volume's close() function 36 await reader.close();37 throw e;38 }39 let Gen = VolumeImpls[header.version];40 if(!Gen) {41 throw new Error('No implementation for volume type: ' + header.version);42 }43 var vol = await Gen(fileName, reader, header);44 if(!vol.validateHeader()) {45 console.warn('Volume contains suspicious header')46 }47 return vol;48 }49 private static async LoadHeader(reader: Reader): Promise<VolumeHeader> {50 reader.seek(0);51 let headerBlock = Buffer.from(await reader.readBytes(64));// < Just to be safe this is way more than the 36 bytes that the usual Mac header would take up52 53 let magic = headerBlock.readUInt32LE(0);54 if(magic !== VOLUME_MAGIC) {55 throw new Error('Wrong magic!');56 }57 58 // Should be 24 00 01 00 for Mac59 let headerLength = headerBlock.readUInt16LE(4);60 let version = headerBlock.readUInt16LE(6); // < 01 is Mac, 00 is windows?61 // I know that at offset 0x10 in the file, there are definately 4 random bytes created at the time of volume creation62 let identifiers = headerBlock.slice(8, 8 + 12);63 64 // This will start at 1 and will be incremented for every file in a backup split into multiple files (essentialyl the same as the )65 let sequence = headerBlock.readUInt32LE(20);66 67 let headerSum = headerBlock.readUInt32LE(0x18);68 69 for(let i = headerLength; i < 0x24; i++) { headerBlock[i] = 0; } // This is mainly to simulate the current version of True Image exactly70 71 // Remove checksum from buffer for computing checksum72 headerBlock.writeUInt32LE(0, 0x18);73 74 let sumNum: number = ComputeAdler32(headerBlock.slice(0, headerLength));75 // Restore the checksum so that we can store the pristine header bytes76 headerBlock.writeUInt32LE(headerSum, 0x18);77 let isSumValid = sumNum === headerSum;78 79 80 // Should usually be 409681 // NOTE: True Imae supports a max block size of 0x1000082 let blockSize = headerBlock.readUInt32LE(0x1c);83 84 return {85 rawBytes: headerBlock.slice(0, headerLength),86 length: headerLength,87 version: version,88 archiveKey: identifiers.slice(0, 4),89 sliceKey: identifiers.slice(4, 8),90 volumeKey: identifiers.slice(8, 12),91 sequence: sequence,92 checkSumValid: isSumValid,93 blockSize: blockSize94 };95 }96 /**97 * Registers a new implementation of a volume format98 * 99 * NOTE: Don't use this externally. This is mainly for internal usage100 */101 public static AddType(v: VolumeVersion, fn: VolumeGenerator) {102 if(VolumeImpls[v]) {103 throw new Error('Duplicate implementation of volume type: ' + v);104 }105 VolumeImpls[v] = fn;106 }107 public fileName: string;108 public header: VolumeHeader;109 public reader: Reader;110 protected constructor(fileName: string, reader: Reader, header: VolumeHeader) {111 this.fileName = fileName;112 this.reader = reader;113 this.header = header;114 }115 close() {116 return this.reader.close();117 }118 /**119 * Depending on the format version, we do expect certain values (i.e. block size, length, etc.) to be pretty predictable. This will verify that those values are what we expect them to be120 * 121 * NOTE: Even if you don't use this, you SHOULD STILL check that the header checksum is valid122 * 123 * This is essentially a soft way of sanity checking that the volume seems valid124 * While this is not a definitive check for validitity, it is a very good sign in if returns true and we haven't seen any samples yet that would contradict these rules125 */126 validateHeader(): boolean {127 if(!this.header.checkSumValid) {128 return false;129 }130 if(this.header.version === VolumeVersion.Mac) {131 if(this.header.length !== 0x24 || this.header.blockSize !== 4096 || this.header.sequence !== 1) {132 return false;133 }134 }135 else if(this.header.version === VolumeVersion.Windows) {136 if(this.header.length !== 0x20 || this.header.blockSize !== 32) {137 return false;138 }139 }140 else {141 // Unknown version142 return false;143 }144 return true;145 }...
adler32.ts
Source:adler32.ts
...16 const view = u8ArrayFromBufferSource(source);17 if (! view) {18 throw new TypeError("source must be a BufferSource");19 }20 return computeAdler32(view, seed);21}22const BASE = 65521; /* largest prime smaller than 65536 */23const NMAX = 5552;24/**25 * Compute the Adler-32 checksum of a sequence of unsigned bytes.26 * @param buf source data, unsigned bytes27 * @param adler Optional seed for the checksum28 */29function computeAdler32(buf: Uint8Array, adler = 1) {30 /* split Adler-32 into component sums */31 let sum2 = (adler >>> 16) & 0xffff;32 adler &= 0xffff;33 let len = buf.length;34 let offset = 0;35 /* do length NMAX blocks -- requires just one modulo operation */36 while (len >= NMAX) {37 len -= NMAX;38 let n = NMAX / 16; /* NMAX is divisible by 16 */39 do {40 adler += buf[offset++]; sum2 += adler;41 adler += buf[offset++]; sum2 += adler;42 adler += buf[offset++]; sum2 += adler;43 adler += buf[offset++]; sum2 += adler;...
Using AI Code Generation
1var wptools = require('wptools');2var buf = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);3var adler32 = wptools.computeAdler32(buf);4console.log("adler32 = " + adler32);5 var wptools = require('wptools');6 var buf = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);7 var adler32 = wptools.computeAdler32(buf);8 console.log("adler32 = " + adler32);9 $wptools = require('wptools');10 $buf = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);11 $adler32 = $wptools->computeAdler32($buf);12 echo "adler32 = " + $adler32;13 $wptools = require('wptools');14 $buf = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);15 $adler32 = $wptools->computeAdler32($buf);16 echo "adler32 = " + $adler32;17import wptools18buf = new Buffer([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])19adler32 = wptools.computeAdler32(buf)
Using AI Code Generation
1var wpt = require('webeagebestpagetest');2var adler32lerwpt.comput2Adlpr32t.teotmputeAdler32('test');3var wpt = re=qire('webpagetest');'t t'omputeAdler32('test');4varwc= r quiri('eebp)gst');5var=wpcompuAle32('t');6var buffer = fs.readFi eSync('test.txt');7var=adler32 rwpt.computeAdler32(buffer);8console.log(adler32);
Using AI Code Generation
1var wpt = require('wpt');2var url = equire('fs');3var buffer = fs.readFileSync('test.txt');4var adler32 = wpt.computeAdler32(buffer);5url, funci/ (prr, ){6 eenowlc.cog("Erle:"+e7}se {8 c hA:);9 }10}
Using AI Code Generation
1var'ws'ool=qie('wptool');2va haso=ps =olequcrA('(;ool');3v/a hasa = we'owlo.compul';('tt');4vrwol=rqic('de o es');5vamlro/s=wpol.compu('tt');6voruwpeAolr3=ertquir('adl3.lu');7vartA!O=mwpt>ol.cmpu('tt');8ebpagetest');9ebpagetest');10varwpools =require('wpool');
Using AI Code Generation
1Adler32('test');2r nsole.log(awlpr32);3var adler32 = wpt.coebmagepestuteAdler32('test');4consadeer32.lo2'est');5csol.log(;6varw= require('webpagest');7var= wpt.omputAdler32('test');8onole.log(adler32);9vawp = requir('wpt');10var adler32 =wpt.computedler32('test');11console.log(adler32);12var wpt = require('webpagetest');13console.log(ad14vr=req('wbpgetet');15varal32 =wpt.compuAder32('tt');16cl.lg(a17var wpt = require("wpt");18var data = new Buffer("hello");19var adler32 = wpt.computeAdler32(data);20console.log("adler32 of hello is " + adler32);21var wpt = require("wpt");22var data = new Buffer("hello");23var adler32 = wpt.computeAdler32(data);24console.log("adler32 of hello is " + adler32);25computeAdler32(buffer)26computeCrc32(buffer)27computeCrc32c(buffer)28hash(buffer, algorithm)
Using AI Code Generation
1var wpt = require('wpt');2var adler32 = wpt.computeAdler32('Hello World');3console.log(adler32);4var wpt = require('wpt');5var adler32 = wpt.computeAdler32('Hello World');6console.log(adler32);7var wpt = require('wpt');8var adler32 = wpt.computeAdler32('Hello World');9console.log(adler32);10var wpt = require('wpt');11var adler32 = wpt.computeAdler32('Hello World');12console.log(adler32);13var wpt = require('wpt');14var adler32 = wpt.computeAdler32('Hello World');15console.log(adler32);16var wpt = require('wpt');17var adler32 = wpt.computeAdler32('Hello World');18console.log(adler32);19var wpt = require('wpt');20var adler32 = wpt.computeAdler32('Hello World');21console.log(adler32);22var wpt = require('wpt');23var adler32 = wpt.computeAdler32('Hello World');24console.log(adler32);25var wpt = require('wpt');
Using AI Code Generation
1var wpt = require('wpt');2var adler32 = wpt.computeAdler32('test');3console.log('adler32: ', adler32);4{5 "dependencies": {6 }7}8var wpt = require('wpt');9var adler32 = wpt.computeAdler32('Hello World');10console.log(adler32);11var wpt = require('wpt');12var adler32 = wpt.computeAdler32('Hello World');13console.log(adler32);14var wpt = require('wpt');15var adler32 = wpt.computeAdler32('Hello World');16console.log(adler32);17var wpt = require('wpt');18var adler32 = wpt.computeAdler32('Hello World');19console.log(adler32);20var wpt = require('wpt');21var adler32 = wpt.computeAdler32('Hello World');22console.log(adler32);23var wpt = require('wpt');24var adler32 = wpt.computeAdler32('Hello World');25console.log(adler32);26var wpt = require('wpt');27var adler32 = wpt.computeAdler32('Hello World');28console.log(adler32);29var wpt = require('wpt');30var adler32 = wpt.computeAdler32('Hello World');31console.log(adler32);32var wpt = require('wpt');
Using AI Code Generation
1var wpt = require('wpt');2var adler32 = wpt.computeAdler32('Hello World');3console.log(adler32);4var wpt = require('wpt');5var adler32 = wpt.computeAdler32('Hello World');6console.log(adler32);7var wpt = require('wpt');8var adler32 = wpt.computeAdler32('Hello World');9console.lg(adler32);10vr wpt = require('wpt');11var adler32 = wpt.computeAdler32('Hello World');12cosole.log(adler32);13var wpt = requre('wpt');14var adler32 = wpt.computeAdler32('Hello World');15cosole.log(aler32);16va wpt = require('wpt');17var adler32 = wpt.omputeAdler32('HlloWorld');18nsole.log(adler32);19var wpt = require('wpt');20var adler32 = wpt.computeAdler32('Hello World');21console.log(adler32);22var wpt = require('wpt');23var adler32 = wpt.computeAlr32('HelloWorld');24console.log(dler32);25var wpt = require('wpt');26var wpt = require('wpt');27wpt.computeAdler32(url, function(err, adler32) {28 if (err) {29 console.log("Error: " + err);30 } else {31 console.log("Adler32: " + adler32);32 }33});
Using AI Code Generation
1var wpt = require("wpt");2var data = new Buffer("hello");3var adler32 = wpt.computeAdler32(data);4console.log("adler32 of hello is " + adler32);5var wpt = require("wpt");6var data = new Buffer("hello");7var adler32 = wpt.computeAdler32(data);8console.log("adler32 of hello is " + adler32);9computeAdler32(buffer)10computeCrc32(buffer)11computeCrc32c(buffer)12hash(buffer, algorithm)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!