Best JavaScript code snippet using stryker-parent
encrypt.ts
Source:encrypt.ts
1/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++2 + ,--. o | o +3 + | |.,---.,---.,---. | .,---.,---. +4 + | |||---'| || | | || || | +5 + `--' ``---'`---|`---' `---'`` '`---| +6 + `---' `---' +7 + +8 + Copyright (C) 2016-2019, Yakov Panov (Yakov Ling) +9 + Mail: <diegoling33@gmail.com> +10 + +11 + ÐÑо пÑогÑаммное обеÑпеÑение Ð¸Ð¼ÐµÐµÑ Ð»Ð¸ÑензиÑ, как ÑÑо Ñказано в Ñайле +12 + COPYING, коÑоÑÑй ÐÑ Ð´Ð¾Ð»Ð¶Ð½Ñ Ð±Ñли полÑÑиÑÑ Ð² ÑамкаÑ
ÑаÑпÑоÑÑÑÐ°Ð½ÐµÐ½Ð¸Ñ ÐÐ. +13 + +14 + ÐÑполÑзование, изменение, копиÑование, ÑаÑпÑоÑÑÑанение, обмен/пÑодажа +15 + могÑÑ Ð²ÑполнÑÑÑÑÑ Ð¸ÑклÑÑиÑелÑно в ÑоглаÑии Ñ ÑÑловиÑми Ñайла COPYING. +16 + +17 + Файл: encrypt.ts +18 + Файл Ñоздан: 23.11.2018 23:03:37 +19 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/20export default class Encrypt {21 /**22 * ÐлÑÑ ÑиÑÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð¾Ð±Ñего назнаÑениÑ.23 *24 * ÐлÑÑ Ð¸ÑполÑзÑеÑÑÑ ÐºÐ°Ðº ÑÑандаÑÑное знаÑение Ð´Ð»Ñ Encrypt.encodeString25 */26 public static sharedKey: string = "el292ySHa28r5edK5ey2XX2ToEn6cr22e4qyp5t";27 /**28 * ÐодиÑÑÐµÑ ÑÑÑÐ¾ÐºÑ ÐºÐ»ÑÑем или обÑим клÑÑем Encrypt.sharedKey29 *30 * @param str31 * @param decodeKey32 */33 public static encodeString(str: string, decodeKey?: string): string {34 decodeKey = decodeKey || Encrypt.sharedKey;35 let enc = "";36 for (let i = 0; i < str.length; i++) {37 const a = str.charCodeAt(i);38 const b = a ^ (decodeKey.charAt(i % decodeKey.length) as any);39 enc = enc + String.fromCharCode(b);40 }41 return Encrypt.b64EncodeUnicode(enc);42 }43 /**44 * ÐекодиÑÑÐµÑ ÑÑÑÐ¾ÐºÑ ÐºÐ»ÑÑем или обÑим клÑÑем Encrypt.sharedKey45 *46 * @param str47 * @param decodeKey48 */49 public static decodeString(str: string, decodeKey?: string): string | null {50 decodeKey = decodeKey || Encrypt.sharedKey;51 const decode = Encrypt.b64DecodeUnicode(str);52 if (decode === null) return null;53 str = decode;54 // str = Encrypt.b64DecodeUnicode(str);55 let dec = "";56 for (let i = 0; i < str.length; i++) {57 const a = str.charCodeAt(i);58 const b = a ^ (decodeKey.charAt(i % decodeKey.length) as any);59 dec = dec + String.fromCharCode(b);60 }61 return dec;62 }63 /**64 * ÐодиÑÑÐµÑ ÑÑÑÐ¾ÐºÑ Ð² base6465 * @param str66 */67 public static b64EncodeUnicode(str: string): string {68 // first we use encodeURIComponent to get percent-encoded UTF-8,69 // then we convert the percent encodings into raw bytes which70 // can be fed into btoa.71 return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,72 function toSolidBytes(match, p1) {73 // @ts-ignore74 return String.fromCharCode("0x" + p1);75 }));76 }77 /**78 * ÐекодиÑÑÐµÑ base64 ÑÑÑÐ¾ÐºÑ Ð¸Ð»Ð¸ возвÑаÑÐ°ÐµÑ null пÑи неÑдаÑе79 * @param str80 */81 public static b64DecodeUnicode(str: string): string | null {82 // Going backwards: from bytestream, to percent-encoding, to original string.83 try {84 return decodeURIComponent(atob(str).split("").map(c =>85 "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""));86 } catch (e) {87 return null;88 }89 }...
key-codes_test.js
Source:key-codes_test.js
1module('keyboard decoding');2test('ignores control keys', function() {3 var key = decodeKey({metaKey: true});4 deepEqual(key, {control: true}, 'meta key combo');5 key = decodeKey({altKey: true});6 deepEqual(key, {control: true}, 'alt key combo');7 key = decodeKey({ctrlKey: true, keyCode: 0});8 deepEqual(key, {control: true}, 'ctrl key combo');9});10test('decodes function keys', function() {11 for (var i = 1; i < 10; i++) {12 var key = decodeKey({ctrlKey: true, keyCode: 48 + i});13 deepEqual(key, {fkey: i}, 'ctrl+' + i + ' maps to f' + i);14 key = decodeKey({keyCode: 111 + i});15 deepEqual(key, {fkey: i}, 'f' + i + ' decoded properly');16 }17});18test('decodes alphanumeric', function() {19 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('').forEach(function(character) {20 var key = decodeKey({keyCode: character.charCodeAt(0)});21 deepEqual(key, {ascii: character.toLowerCase()});22 });23 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('').forEach(function(character) {24 var key = decodeKey({shiftKey: true, keyCode: character.charCodeAt(0)});25 deepEqual(key, {ascii: character});26 });27 for (var i = 0; i < 10; i++)28 deepEqual(decodeKey({keyCode: 96 + i}), {ascii: i + ''});29});30test('decodes symbols above numbers', function() {31 var syms = '!@#$%^&*()';32 var nums = '1234567890';33 nums.split('').forEach(function(character, i) {34 var key = decodeKey({shiftKey: true, keyCode: character.charCodeAt(0)});35 deepEqual(key, {ascii: syms[i]});36 });37});38test('decodes symbol keys', function() {39 // Following chromium/src/ui/events/keycodes/keyboard_code_conversion.cc40 deepEqual(decodeKey({keyCode: 0x6a}), {ascii: '*'});41 deepEqual(decodeKey({keyCode: 0x6b}), {ascii: '+'});42 deepEqual(decodeKey({keyCode: 0x6d}), {ascii: '-'});43 deepEqual(decodeKey({keyCode: 0x6e}), {ascii: '.'});44 deepEqual(decodeKey({keyCode: 0x6f}), {ascii: '/'});45 deepEqual(decodeKey({keyCode: 0x20}), {ascii: ' '});46 deepEqual(decodeKey({keyCode: 0xba}), {ascii: ';'});47 deepEqual(decodeKey({shiftKey: true, keyCode: 0xba}), {ascii: ':'});48 deepEqual(decodeKey({keyCode: 0xbb}), {ascii: '='});49 deepEqual(decodeKey({shiftKey: true, keyCode: 0xbb}), {ascii: '+'});50 deepEqual(decodeKey({keyCode: 0xbc}), {ascii: ','});51 deepEqual(decodeKey({shiftKey: true, keyCode: 0xbc}), {ascii: '<'});52 deepEqual(decodeKey({keyCode: 0xbd}), {ascii: '-'});53 deepEqual(decodeKey({shiftKey: true, keyCode: 0xbd}), {ascii: '_'});54 deepEqual(decodeKey({keyCode: 0xbe}), {ascii: '.'});55 deepEqual(decodeKey({shiftKey: true, keyCode: 0xbe}), {ascii: '>'});56 deepEqual(decodeKey({keyCode: 0xbf}), {ascii: '/'});57 deepEqual(decodeKey({shiftKey: true, keyCode: 0xbf}), {ascii: '?'});58 deepEqual(decodeKey({keyCode: 0xc0}), {ascii: '`'});59 deepEqual(decodeKey({shiftKey: true, keyCode: 0xc0}), {ascii: '~'});60 deepEqual(decodeKey({keyCode: 0xdb}), {ascii: '['});61 deepEqual(decodeKey({shiftKey: true, keyCode: 0xdb}), {ascii: '{'});62 deepEqual(decodeKey({keyCode: 0xdc}), {ascii: '\\'});63 deepEqual(decodeKey({shiftKey: true, keyCode: 0xdc}), {ascii: '|'});64 deepEqual(decodeKey({keyCode: 0xdd}), {ascii: ']'});65 deepEqual(decodeKey({shiftKey: true, keyCode: 0xdd}), {ascii: '}'});66 deepEqual(decodeKey({keyCode: 0xde}), {ascii: '\''});67 deepEqual(decodeKey({shiftKey: true, keyCode: 0xde}), {ascii: '"'});68});69test('decodes special control keys', function() {70 deepEqual(decodeKey({keyCode: 8}), {backspace: true});71 deepEqual(decodeKey({keyCode: 9}), {tab: true});72 deepEqual(decodeKey({keyCode: 13}), {enter: true});73 deepEqual(decodeKey({keyCode: 16}), {shift: true});74 deepEqual(decodeKey({keyCode: 27}), {esc: true});75 deepEqual(decodeKey({keyCode: 37}), {left: true});76 deepEqual(decodeKey({keyCode: 38}), {up: true});77 deepEqual(decodeKey({keyCode: 39}), {right: true});78 deepEqual(decodeKey({keyCode: 40}), {down: true});79 deepEqual(decodeKey({keyCode: 46}), {del: true});80});81test('ignores unknown keys', function() {82 deepEqual(decodeKey({keyCode: 0}), {unknown: true});...
2.js
Source:2.js
1 const input = document.querySelector("pre").innerHTML.split(/\r?\n/);2 input.pop();3 let result = 0;4 const easyNr = [2, 3, 4, 7];5 const easyDecode = [1, 7, 4, 8];6 input.forEach((row) => {7 const message = row.split(' | ');8 let numbers = message[1].split(' ');9 let total = [1000, 100, 10, 1];10 let i = 0;11 let code = message[0].split(' ');12 let decodeKey = new Array(7).fill([]);13 14 decodeKey = setInitialDecode(code, decodeKey);15 decodeKey = setExactCharsTwoAndFive(code, decodeKey);16 let numberThree = getNumberThree(code, decodeKey);17 numbers.forEach((n)=> {18 let number = 0;19 if (easyNr.indexOf(n.length) !== -1){20 number = easyDecode[easyNr.indexOf(n.length)];21 } else {22 /* 2, 3, 5 */23 if(n.length == 5) {24 /* 3 or 2 */25 if (n.includes(decodeKey[2])) {26 /* 3 */27 if (n.includes(decodeKey[5])) {28 number = 3;29 } else {30 number = 2;31 }32 } else {33 number = 5;34 }35 }36 /* 0, 6, 9 */37 if(n.length == 6) {38 /* 0 or 9 */39 if (n.includes(decodeKey[2]) && n.includes(decodeKey[5])) {40 /* check if inclues all chars in a three */41 let matches = 0;42 for(let letters = 0; letters < 5; letters++){43 if(n.includes(numberThree[letters])){44 matches++;45 }46 }47 if (matches === 5){48 number = 9;49 } else {50 number = 0;51 }52 } else {53 number = 6;54 }55 }56 }57 total[i] = total[i] * number;58 i++59 })60 result += total.reduce((a, b) => a + b, 0);61 })62 console.log(result, "Total result")63function setInitialDecode(code, decodeKey) {64 code.forEach((c) => {65 if(c.length === 2) {66 decodeKey[2] = decodeKey[2].concat(c.split(''));67 decodeKey[5] = decodeKey[5].concat(c.split(''));68 }69 if(c.length === 3) {70 decodeKey[0] = decodeKey[1].concat(c.split(''));71 }72 })73 decodeKey[0] = decodeKey[0].filter(x => !decodeKey[2].includes(x))[0];74 return decodeKey;75}76function setExactCharsTwoAndFive(code, decodeKey) {77 code.forEach((c)=> {78 if(c.length == 6 && decodeKey[2].length > 1) {79 /* Not both chars in a 1 */80 if (!(c.includes(decodeKey[2][0]) && c.includes(decodeKey[2][1]))) {81 const nrTwo = c.includes(decodeKey[2][0]) ? decodeKey[2][1] : decodeKey[2][0];82 const nrFive = (nrTwo == decodeKey[5][0]) ? decodeKey[2][1] : decodeKey[2][0];83 decodeKey[2] = nrTwo;84 decodeKey[5] = nrFive;85 }86 }87 });88 return decodeKey;89}90function getNumberThree(code, decodeKey) {91 let three = "";92 code.forEach((n)=> {93 if (n.length == 5) {94 /* 3 or 2 */95 if (n.includes(decodeKey[2])) {96 /* 3 */97 if (n.includes(decodeKey[5])) {98 three = n;99 }100 }101 }102 })103 return three;...
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const decodeKey = strykerParent.decodeKey;3const strykerParent = require('stryker-parent');4const encodeKey = strykerParent.encodeKey;5const { decodeKey } = require('stryker-parent');6const { encodeKey } = require('stryker-parent');7const { decodeKey, encodeKey } = require('stryker-parent');8const decodeKey = require('stryker-parent').decodeKey;9const encodeKey = require('stryker-parent').encodeKey;10const { decodeKey } = require('stryker-parent').default;11const { encodeKey } = require('stryker-parent').default;12const decodeKey = require('stryker-parent').default.decodeKey;13const encodeKey = require('stryker-parent').default.encodeKey;14const { decodeKey } = require('stryker-parent').default;15const { encodeKey } = require('stryker-parent').default;16const decodeKey = require('stryker-parent').default.decodeKey;17const encodeKey = require('stryker-parent').default.encodeKey;18const { decodeKey } = require('stryker-parent').default;19const { encodeKey } =
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const decodedKey = strykerParent.decodeKey('base64EncodedKey');3console.log(decodedKey);4const strykerParent = require('stryker-parent');5const decodedKey = strykerParent.decodeKey('base64EncodedKey');6console.log(decodedKey);7const strykerParent = require('stryker-parent');8const decodedKey = strykerParent.decodeKey('base64EncodedKey');9console.log(decodedKey);10const strykerParent = require('stryker-parent');11const decodedKey = strykerParent.decodeKey('base64EncodedKey');12console.log(decodedKey);13const strykerParent = require('stryker-parent');14const decodedKey = strykerParent.decodeKey('base64EncodedKey');15console.log(decodedKey);16const strykerParent = require('stryker-parent');17const decodedKey = strykerParent.decodeKey('base64EncodedKey');18console.log(decodedKey);19const strykerParent = require('stryker-parent');20const decodedKey = strykerParent.decodeKey('base64EncodedKey');21console.log(decodedKey);22const strykerParent = require('stryker-parent');23const decodedKey = strykerParent.decodeKey('base64EncodedKey');24console.log(decodedKey);25const strykerParent = require('stryker-parent');26const decodedKey = strykerParent.decodeKey('base64EncodedKey');27console.log(decodedKey);28const strykerParent = require('stryker-parent');
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!!