Best JavaScript code snippet using wpt
test.js
Source:test.js
1/*2 * Copyright (c) 2012 chick307 <chick307@gmail.com>3 *4 * Licensed under the MIT License.5 * http://opensource.org/licenses/mit-license6 */7describe('adler32cs', function() {8 var adler32cs = typeof window === 'object' ?9 window.adler32cs : require('.');10 var _Uint8Array = typeof Uint8Array === 'function' ? Uint8Array : Object;11 var data = [12 {13 binaryString: '\x00',14 utf8String: '\u0000',15 buffer: new _Uint8Array([0]).buffer,16 adler32: 6553717 },18 {19 utf8String: 'ããããã',20 buffer: new _Uint8Array([21 227, 129, 130, 227, 129, 132, 227, 129,22 134, 227, 129, 136, 227, 129, 13823 ]).buffer,24 adler32: 131203317125 },26 {27 binaryString: 'abc',28 utf8String: 'abc',29 adler32: 3860099930 }31 ];32 data.forEach(function(d) {33 if (d.binaryString != null) {34 var name = 'from(' + JSON.stringify(d.binaryString) +35 ') needs to be ' + d.adler32 + '.';36 it(name, function() {37 var checksum = adler32cs.from(d.binaryString);38 equals(checksum, d.adler32);39 });40 }41 });42 data.forEach(function(d) {43 if (d.utf8String != null) {44 var name = 'fromUtf8(' + JSON.stringify(d.utf8String) +45 ') needs to be ' + d.adler32 + '.';46 it(name, function() {47 var checksum = adler32cs.fromUtf8(d.utf8String);48 equals(checksum, d.adler32);49 });50 }51 });52 if (!!adler32cs.fromBuffer) {53 data.forEach(function(d) {54 if (d.buffer != null) {55 var name = 'fromBuffer(buffer of ' +56 JSON.stringify(d.binaryString || d.utf8String) +57 ') needs to be ' + d.adler32 + '.';58 it(name, function() {59 var checksum = adler32cs.fromBuffer(d.buffer);60 equals(checksum, d.adler32);61 });62 }63 });64 }65 it('Adler32() throws TypeError', function() {66 throws(function() {67 adler32cs.Adler32();68 }, TypeError);69 });70 it('Adler32.from() throws TypeError', function() {71 throws(function() {72 adler32cs.Adler32.from();73 }, TypeError);74 });75 it('Adler32.fromUtf8() throws TypeError', function() {76 throws(function() {77 adler32cs.Adler32.fromUtf8();78 }, TypeError);79 });80 it('Adler32.fromBuffer() throws TypeError', function() {81 throws(function() {82 adler32cs.Adler32.fromBuffer();83 }, TypeError);84 });85 data.forEach(function(d) {86 if (d.binaryString != null) {87 var name = 'new Adler32.from(' + JSON.stringify(d.binaryString) +88 ').checksum needs to be ' + d.adler32 + '.';89 it(name, function() {90 var c = new adler32cs.Adler32.from(d.binaryString);91 equals(c.checksum, d.adler32);92 });93 }94 });95 data.forEach(function(d) {96 if (d.utf8String != null) {97 var name = 'new Adler32.fromUtf8(' + JSON.stringify(d.utf8String) +98 ').checksum needs to be ' + d.adler32 + '.';99 it(name, function() {100 var c = new adler32cs.Adler32.fromUtf8(d.utf8String);101 equals(c.checksum, d.adler32);102 });103 }104 });105 if (!!adler32cs.fromBuffer) {106 data.forEach(function(d) {107 if (d.buffer != null) {108 var name = 'new Adler32.fromBuffer(buffer of ' +109 JSON.stringify(d.binaryString || d.utf8String) +110 ').checksum needs to be ' + d.adler32 + '.';111 it(name, function() {112 var c = new adler32cs.Adler32.fromBuffer(d.buffer);113 equals(c.checksum, d.adler32);114 });115 }116 });117 }118 data.forEach(function(d) {119 if (d.binaryString != null) {120 var name = 'new Adler32().update(' + JSON.stringify(d.binaryString) +121 ') needs to be ' + d.adler32 + '.';122 it(name, function() {123 var c = new adler32cs.Adler32();124 for (var i = 0; i < d.binaryString.length; i++)125 c.update(d.binaryString.charAt(i));126 equals(c.checksum, d.adler32);127 });128 }129 });130 data.forEach(function(d) {131 if (d.utf8String != null) {132 var name = 'new Adler32().updateUtf8(' +133 JSON.stringify(d.utf8String) +134 ') needs to be ' + d.adler32 + '.';135 it(name, function() {136 var c = new adler32cs.Adler32();137 for (var i = 0; i < d.utf8String.length; i++)138 c.updateUtf8(d.utf8String.charAt(i));139 equals(c.checksum, d.adler32);140 });141 }142 });143 if (!!adler32cs.fromBuffer) {144 data.forEach(function(d) {145 if (d.buffer != null) {146 var name = 'new Adler32().updateBuffer(buffer of ' +147 JSON.stringify(d.binaryString || d.utf8String) +148 ') needs to be ' + d.adler32 + '.';149 it(name, function() {150 var c = new adler32cs.Adler32();151 var checksum = c.updateBuffer(d.buffer);152 equals(checksum, d.adler32);153 equals(c.checksum, d.adler32);154 });155 }156 });157 }158 function equals(actual, expected) {159 if (actual !== expected) {160 var error = new Error(161 'Expected ' + expected + ' but was ' + actual + '.');162 error.name = 'AssertionError';163 throw error;164 }165 }166 function throws(func, ErrorType) {167 var error = null;168 try {169 func();170 } catch (err) {171 error = err;172 }173 if (error === null) {174 var e = new Error(175 func + 'needs to throw ' + (ErrorType || 'a error.'));176 e.name = 'AssertionError';177 throw e;178 } else if (ErrorType != null && !(error instanceof ErrorType)) {179 var e = new Error(func + 'needs to throw ' + ErrorType.name);180 e.name = 'AssertionError';181 throw e;182 }183 }...
adler32.js
Source:adler32.js
1/* adler32.js (C) 2014 SheetJS -- http://sheetjs.com */2/* vim: set ts=2: */3var ADLER32 = {};4(function(ADLER32) {5ADLER32.version = '0.2.0';6/* consult README.md for the magic number */7/* charCodeAt is the best approach for binary strings */8var use_buffer = typeof Buffer !== 'undefined';9function adler32_bstr(bstr) {10 if(bstr.length > 32768) if(use_buffer) return adler32_buf(Buffer(bstr));11 var a = 1, b = 0, L = bstr.length, M;12 for(var i = 0; i < L;) {13 M = Math.min(L-i, 3850)+i;14 for(;i<M;i++) {15 a += bstr.charCodeAt(i);16 b += a;17 }18 a = (15*(a>>>16)+(a&65535))19 b = (15*(b>>>16)+(b&65535))20 }21 return ((b%65521) << 16) | (a%65521);22}23function adler32_buf(buf) {24 var a = 1, b = 0, L = buf.length, M;25 for(var i = 0; i < L;) {26 M = Math.min(L-i, 3850)+i;27 for(;i<M;i++) {28 a += buf[i];29 b += a;30 }31 a = (15*(a>>>16)+(a&65535))32 b = (15*(b>>>16)+(b&65535))33 }34 return ((b%65521) << 16) | (a%65521);35}36/* much much faster to intertwine utf8 and adler */37function adler32_str(str) {38 var a = 1, b = 0, L = str.length, M, c, d;39 for(var i = 0; i < L;) {40 M = Math.min(L-i, 3850);41 while(M>0) {42 c = str.charCodeAt(i++);43 if(c < 0x80) { a += c; b += a; --M; }44 else if(c < 0x800) {45 a += 192|((c>>6)&31); b += a; --M;46 a += 128|(c&63); b += a; --M;47 } else if(c >= 0xD800 && c < 0xE000) {48 c = (c&1023)+64; d = str.charCodeAt(i++) & 1023;49 a += 240|((c>>8)&7); b += a; --M;50 a += 128|((c>>2)&63); b += a; --M;51 a += 128|((d>>6)&15)|(c&3); b += a; --M;52 a += 128|(d&63); b += a; --M;53 } else {54 a += 224|((c>>12)&15); b += a; --M;55 a += 128|((c>>6)&63); b += a; --M;56 a += 128|(c&63); b += a; --M;57 }58 }59 a %= 65521;60 b %= 65521;61 }62 return (b << 16) | a;63}64ADLER32.bstr = adler32_bstr;65ADLER32.buf = adler32_buf;66ADLER32.str = adler32_str;...
adler32-test.js
Source:adler32-test.js
...11'use strict';12var adler32 = require('adler32');13describe('adler32', () => {14 it('generates differing checksums', () => {15 expect(adler32('foo')).not.toBe(adler32('bar'));16 });17 it('generates consistent checksums', () => {18 expect(adler32('linux')).toBe(adler32('linux'));19 });20 it('is case sensitive', () => {21 expect(adler32('a')).not.toBe(adler32('A'));22 });23 it("doesn't barf on large inputs", () => {24 var str = '';25 for (var i = 0; i < 100000; i++) {26 str += 'This will be repeated to be very large indeed. ';27 }28 expect(adler32(str)).toBe(692898118);29 });30 it("doesn't barf on international inputs", () => {31 var str = 'Linux æ¯ä¸åçæ£æä½ç³»çµ±!';32 expect(adler32(str)).toBe(-1183804097);33 });...
adler32_8c.js
Source:adler32_8c.js
1var adler32_8c =2[3 [ "BASE", "adler32_8c.html#a79bcfb6bde984f42d1124b068a509af7", null ],4 [ "DO1", "adler32_8c.html#a465ff70ce96dfc2e84b0e87548b4ecb4", null ],5 [ "DO16", "adler32_8c.html#adf99cee0040f9a87b194293cb1152034", null ],6 [ "DO2", "adler32_8c.html#a3d7044f8ea7e75164fe5108048fd87eb", null ],7 [ "DO4", "adler32_8c.html#aef9bafc8b3d89e98b6e26320f99b9e31", null ],8 [ "DO8", "adler32_8c.html#a9aafc447614bf5c4dc0d484aba9edb89", null ],9 [ "local", "adler32_8c.html#a08023ea6765c99d60a6a3840cd07156e", null ],10 [ "MOD", "adler32_8c.html#aa1e26f19f1e6cf348e41511e7db90881", null ],11 [ "MOD4", "adler32_8c.html#ad7b4cfdfbc3e12bf00d27e3375d196d4", null ],12 [ "NMAX", "adler32_8c.html#a5de5d183f9a6a8d53316f743e1ca6dc2", null ],13 [ "adler32", "adler32_8c.html#a86607743a4b76949b24cf5cc2f01a40d", null ],14 [ "adler32_combine", "adler32_8c.html#af4a8b45f615e831c56b08da530870e59", null ],15 [ "adler32_combine64", "adler32_8c.html#a02d5e6475de540c47e56fe0c37178c22", null ],16 [ "adler32_combine_", "adler32_8c.html#adca6931a2239061c7a6d2c0a05600a05", null ]...
Using AI Code Generation
1var wptools = require('wptools');2var checksum = wptools.adler32('Hello World');3console.log(checksum);4echo adler32('Hello World');5var wptools = require('wptools');6var checksum = wptools.adler32('Hello World');7console.log(checksum);8var wptools = require('wptools');9var checksum = wptools.adler32('Hello World');10console.log(checksum);11var wptools = require('wptools');12var checksum = wptools.adler32('Hello World');13console.log(checksum);14var wptools = require('wptools');15var checksum = wptools.adler32('Hello World');16console.log(checksum);17var wptools = require('wptools');18var checksum = wptools.adler32('Hello World');19console.log(checksum);20var wptools = require('wptools');21var checksum = wptools.adler32('Hello World');22console.log(checksum);23var wptools = require('wptools');24var checksum = wptools.adler32('Hello World');25console.log(checksum);
Using AI Code Generation
1var wpt = require('wpt');2var adler32 = wpt.adler32;3var checksum = adler32('Hello World!');4console.log(checksum);5var wpt = require('wpt');6var adler32 = wpt.adler32;7var checksum = adler32('Hello World!');8console.log(checksum);9var wpt = require('wpt');10var adler32 = wpt.adler32;11var checksum = adler32('Hello World!');12console.log(checksum);13var wpt = require('wpt');14var adler32 = wpt.adler32;15var checksum = adler32('Hello World!');16console.log(checksum);17var wpt = require('wpt');18var adler32 = wpt.adler32;19var checksum = adler32('Hello World!');20console.log(checksum);21var wpt = require('wpt');22var adler32 = wpt.adler32;23var checksum = adler32('Hello World!');24console.log(checksum);25var wpt = require('wpt');26var adler32 = wpt.adler32;27var checksum = adler32('Hello World!');28console.log(checksum);29var wpt = require('wpt');30var adler32 = wpt.adler32;31var checksum = adler32('Hello World!');32console.log(checksum);33var wpt = require('wpt');34var adler32 = wpt.adler32;35var checksum = adler32('Hello World!');36console.log(checksum);37var wpt = require('wpt');
Using AI Code Generation
1var wptools = require('wptools');2var adler32 = wptools.adler32;3var str = 'Hello world!';4var checksum = adler32(str);5console.log(checksum);6var wptools = require('wptools');7var crc32 = wptools.crc32;8var str = 'Hello world!';9var checksum = crc32(str);10console.log(checksum);11var wptools = require('wptools');12var crc32 = wptools.crc32;13var str = 'Hello world!';14var checksum = crc32(str);15console.log(checksum);16var wptools = require('wptools');17var crc32 = wptools.crc32;18var str = 'Hello world!';19var checksum = crc32(str);20console.log(checksum);21var wptools = require('wptools');22var crc32 = wptools.crc32;23var str = 'Hello world!';24var checksum = crc32(str);25console.log(checksum);26var wptools = require('wptools');27var crc32 = wptools.crc32;28var str = 'Hello world!';29var checksum = crc32(str);30console.log(checksum);31var wptools = require('wptools');32var crc32 = wptools.crc32;33var str = 'Hello world!';34var checksum = crc32(str);35console.log(checksum);
Using AI Code Generation
1var wptools = require('wptools');2wptools.adler32('This is a test', function (err, data) {3 console.log(data);4});5{ adler32: '0x1e6c1a6f' }6The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:7The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:8The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:9The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:10The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:11The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:12The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:13The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:14The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:15The adler32() method returns a JSON object with the adler32 hash of the string passed as argument. The adler32() method takes two arguments:16The adler32()
Using AI Code Generation
1var wptools = require('wptools');2var checksum = wptools.adler32('test');3console.log(checksum);4var wptools = require('wptools');5var checksum = wptools.adler32('test', 1);6console.log(checksum);7var wptools = require('wptools');8var checksum = wptools.adler32('test', 2);9console.log(checksum);10var wptools = require('wptools');11var checksum = wptools.adler32('test', 3);12console.log(checksum);13var wptools = require('wptools');14var checksum = wptools.adler32('test', 4);15console.log(checksum);16var wptools = require('wptools');17var checksum = wptools.adler32('test', 5);18console.log(checksum);19var wptools = require('wptools');20var checksum = wptools.adler32('test', 6);21console.log(checksum);22var wptools = require('wptools');23var checksum = wptools.adler32('test', 7);24console.log(checksum);25var wptools = require('wptools');
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!!