How to use baseKeys method in ladle

Best JavaScript code snippet using ladle

aflprep_test-webcrypto-derivebits-pbkdf2.js

Source:aflprep_test-webcrypto-derivebits-pbkdf2.js Github

copy

Full Screen

1'use strict';2if (!common.hasCrypto) {3 common.skip('missing crypto');4}5if (process.config.variables.arm_version === '7') {6 common.skip('Too slow for armv7 bots');7}8const assert = require('assert');9const { subtle } = require('crypto').webcrypto;10function getDeriveKeyInfo(name, length, hash, ...usages) {11 return [{ name, length, hash }, usages];12}13const kDerivedKeyTypes = [14 ['AES-CBC', 128, undefined, 'encrypt', 'decrypt'],15 ['AES-CBC', 256, undefined, 'encrypt', 'decrypt'],16 ['AES-CTR', 128, undefined, 'encrypt', 'decrypt'],17 ['AES-CTR', 256, undefined, 'encrypt', 'decrypt'],18 ['AES-GCM', 128, undefined, 'encrypt', 'decrypt'],19 ['AES-GCM', 256, undefined, 'encrypt', 'decrypt'],20 ['AES-KW', 128, undefined, 'wrapKey', 'unwrapKey'],21 ['AES-KW', 256, undefined, 'wrapKey', 'unwrapKey'],22 ['HMAC', 256, 'SHA-1', 'sign', 'verify'],23 ['HMAC', 256, 'SHA-256', 'sign', 'verify'],24 ['HMAC', 256, 'SHA-384', 'sign', 'verify'],25 ['HMAC', 256, 'SHA-512', 'sign', 'verify'],26];27const kPasswords = {28 short: '5040737377307264',29 long: '55736572732073686f756c64207069636b206c6f6' +30 'e6720706173737068726173657320286e6f742075' +31 '73652073686f72742070617373776f7264732921',32};33const kSalts = {34 short: '4e61436c',35 long: '536f6469756d2043686c6f7269646520636f6d706f756e64',36 empty: ''37};38const kDerivations = {39 short: {40 short: {41 'SHA-384': {42 '1': '80cd0f15364366a72551c37975f7b637ba89' +43 'c29b4639ec720f69a70dbbed515c',44 '1000': 'aaec5a976d4d35cb2024486fc9f9bb9aa' +45 '3eae7cef2bce62664b5b3751cf50ff1',46 '100000': '6f5ea3c6c6f5e4833467b47c3a671e6' +47 '5714e87071bd1e36d716f846b5cd28980'48 },49 'SHA-512': {50 '1': '69f4d5cef5c7d8ba938e880388c8f63b6b2' +51 '448b2626d1343fc5cb68bbd7f27b2',52 '1000': '865c5945e11f5bf3ddf002e7cb1748f6' +53 '224d2671e806dad4aaf090a04367da29',54 '100000': '483ba7f2e2fe382cf61d20b29812e2' +55 'd49610a60041ae40ecf9fc7ef138e93876'56 },57 'SHA-1': {58 '1': '4624dbd21373ee5659c125b184eedaa26a3' +59 '3b77ca11314b9f0c9dae1e44e9b04',60 '1000': '5388ea5e62e1b557981abe5ce4132127' +61 '58aa6a9d2c5bf08c019d459dba666b90',62 '100000': 'f58f435fbc5c05865c914fd972108a' +63 '09457d5f9a48f14e75e4cc02d98983038a'64 },65 'SHA-256': {66 '1': 'c6bc55a404adcea36a1ab56798085e0aaf6' +67 '97f6bb2c16a5072f838f17dfe6cb6',68 '1000': '4e6ca57957439be3a75370424225e221' +69 '1d55f05af00561df3f3efee9116bc34c',70 '100000': 'ab25796598e74b29c324f5ba4d90ea' +71 '7dc89fc6891041b4d56c94156505f722c0'72 }73 },74 long: {75 'SHA-384': {76 '1': '6807346cc53eded1cb964a72628589a6bd4' +77 '8355990bfdfe7465109710207059d',78 '1000': 'a310ef3c6b3a95e6d8ca6644e3dcfd88' +79 '222a59fe8e00c52d6a12631d82c1d24b',80 '100000': '2c8c6674c879cf1850bc9b7fbdcc6e' +81 'a7abb0a1522196a866875305dea57486f3'82 },83 'SHA-512': {84 '1': '5777027aff4051fb9b43c1f1ef0463bd677' +85 '51175d428a13da3da845a591332cd',86 '1000': '9c17fe96895eadbfd1cc095fc1bb834f' +87 '28e5ccc9ec96ca814cff941a4bf40727',88 '100000': 'b479c9715c421638dce0a705fc0b7b' +89 'a7d56fa3063188063580e070dff1db497c'90 },91 'SHA-1': {92 '1': '576f7c165825bef9ef14b4bc2c82469d1e4' +93 '08ff8e7ba306694797f9e45b766ed',94 '1000': '89d3b27b5f6e8af015f2f87cf368a143' +95 '8a206c4ecf5fe681fc3bf94c56213ef6',96 '100000': '1e39e8bf6676fcd3156655457afa14' +97 'bee771dbcbfcd07241c7cee209a7cb1fe9'98 },99 'SHA-256': {100 '1': '12b90f594f0908cf912d655c948f9c2a1ea' +101 'b855765bc12785ef18aa02b8e7edc',102 '1000': 'b1a7b7dc20df174a4a0e410dbfaf03b4' +103 'c375c450a89d7a9ed349b4e52e64dfd8',104 '100000': 'd4594d8a1b59520a48878922a65d66' +105 '3d28f6a5fa49e931d300d8f9baf93d0aeb'106 }107 },108 empty: {109 'SHA-384': {110 '1': '4f1089c01e438bde649a379fa418fbc3b85' +111 '6258772dfe911806f9bd0809fbc7e',112 '1000': 'aeb5f97d6627eebcde6b139a00895500' +113 '30f7401c67e01c057a3338175e3f3a17',114 '100000': 'd7687df6c781dc88d64ef9cbaf95d3' +115 'd5d1155f66b230239e6e81c1550c8840cf'116 },117 'SHA-512': {118 '1': '8f7b7d459c752f64bf12be625b65d496ac2' +119 '4ea36516b168e16fb026845b4e82e',120 '1000': 'b5ac720b7abe0832fc51a31b1ec5673b' +121 'eb1e41840adfd3d606e8638f4006eb48',122 '100000': 'ba1a0f36bad771526564051eb9ca20' +123 '7da19b62e53762349976a9a3d1b0ef7e20'124 },125 'SHA-1': {126 '1': 'c0cffb0ce5db351faa24dad5902583cfc30' +127 'a9f54d9aa6991fe821d03122127e9',128 '1000': '736f3c3d6ebcc2a7b970403e2696c0eb' +129 '4cd1770f55f196fc7089e666c11f77da',130 '100000': '1c5095ac9a7bd410ef0f72c993eca9' +131 '1bb0e571e9b2fbab704f8c131191fad16c'132 },133 'SHA-256': {134 '1': '019e54ab42f00485d3aa1b26fcde21ae5f5' +135 '2cb0f0960ffc9767f25c65e2db2f9',136 '1000': 'b9d2f2217b4ee5a8bf0345f36b2c9887' +137 '33f503a975dfeac7b7135f54a5f29971',138 '100000': 'a7a2869829797807b3e576c17878b4' +139 '66449e89e60447d541775a96eb7c1a5ded'140 }141 }142 },143 long: {144 short: {145 'SHA-384': {146 '1': '5ede8836fdabeec5d3733b434abac443d41' +147 '5193b599e0926193b000f406a5a7d',148 '1000': 'faa442fbabf4058cc65368b53d7ec511' +149 '3c09ea7e5e3743312f4bebedd980ba37',150 '100000': 'f62ae6c7871b181aa71232f5eb8837' +151 '2498ef32ac0a7d715119e8f052eb102d29'152 },153 'SHA-512': {154 '1': '3e9c12b3f6dfb6441594ec7063fca962ffd' +155 'a10b6cf30b898a31ef9f1306b1119',156 '1000': 'f0928f50a155f26a8c9c1bc7f3b5cb53' +157 '1c53a8f51040c9ce5fc79d430ff0c0f4',158 '100000': '974acfbb0f0f20c81ec92829f38c3d' +159 'af086a7df58b912b856d1f5ecc9355ef1b'160 },161 'SHA-1': {162 '1': '8ae72f94e6fcd54fcbfca66200a211a51b2' +163 'f846787d20b6808bedf156ce46ca0',164 '1000': '53b42161134e15c871abd71aba1390d0' +165 '1f4c6a940caaf5c179258d8f1b1d680b',166 '100000': 'a7fda4c79dd3ba1a875f65e9248b21' +167 '0899ca0814ae38995d8ce5a53560cbac31'168 },169 'SHA-256': {170 '1': 'ffa1e9a727a92c27ae6f74b1c7978f9e1af' +171 '860e106376340ac43d969d136405b',172 '1000': 'eeeb7714420a00b18acec2b5979d1da6' +173 '1373202b7f8ba71b086293aab859e0a0',174 '100000': 'deac70cbe3f1720e353b4e8016ddb5' +175 '9475efb70b6a2385e735d2d6ea6d624a4d'176 }177 },178 long: {179 'SHA-384': {180 '1': 'cf55422cef6e1bc49e6d082b2273d480e8f' +181 '2e8822dadd1469c2a32d9657d12f1',182 '1000': '35658551f0ec13398a7b45e0261cfd65' +183 '4c1e52411e6e457dee68f4aeabe925a7',184 '100000': '1abab5f1e461df378b88c0a22be76e' +185 'f2f1627df74ac7cbfb84bdccb354bc8889'186 },187 'SHA-512': {188 '1': 'de4afbc0add3e4d32f4bc6e122a88ae44a2' +189 'b3ccf0148e7762bac05c43e94ef7f',190 '1000': '43e12024c4d354727f7e58842ccb6033' +191 'a161d60dc5ae516f076e4a58a1880d38',192 '100000': 'f9a92384a4eadfc3560649b37fb676' +193 'e83c453cbbd99f80bba6f0a10ebd150b52'194 },195 'SHA-1': {196 '1': '1d104ea5d235006a12a80f71b80ee528048' +197 'b64cc1a7a0f30f7df4ba26b8320c7',198 '1000': '6e90c86ee07b873e965071025673ff05' +199 '429f678c30f91b37e1e2da512036d320',200 '100000': '141030763bf983c8564d5d4c935fe3' +201 'ca3549608159ac1934c1599040668c2363'202 },203 'SHA-256': {204 '1': 'fd5caeb8b3abe589bc159c4e51f800570e7' +205 '4f64397a6c5ee131dfed93f0511aa',206 '1000': '3fd587c94ba946b8b9dccddd2a5b74f6' +207 '778d4f61e691f83ac47a2fa9580bfdf8',208 '100000': '11992d8b813311244c544b62292945' +209 'e208d403cebd6b9552a1a562065d9958ea'210 }211 },212 empty: {213 'SHA-384': {214 '1': '49ab3f9f882fdb9e528b4d9f1b3e8c71d26' +215 '39abf1701d56eb99bd51201e420ff',216 '1000': 'f9ca148b0c041890bff8831db6174719' +217 '7e94ce68f190edf269694b4d644861ca',218 '100000': '1749dfcd77e5258519ea2231ba2cd6' +219 '543b073339ac9b1545bb643153faf6d17b'220 },221 'SHA-512': {222 '1': 'd1bfa1a6b8a977839f8c3f9d52dd02104e2' +223 '029c0eb2a6208cc408816e7768a8c',224 '1000': '457a7955ebecec71a51efb6237e5b1d6' +225 '2f4deab5c93d7b3d11d1e70faffa417e',226 '100000': 'e805ac9cc1d8412c42446d237d1b50' +227 '4f9540b362bd1b75e451531e853e24753d'228 },229 'SHA-1': {230 '1': 'a46a62986d9c3909f41014dd72cfe34a261' +231 '247854d7312cf4fbead60b9b69edd',232 '1000': 'e7375de5036766c40cb85f43b53fce4f' +233 'fa402ab6be3571007ef5d55453fd7f0a',234 '100000': '7a403d9a13aed8164e9c072c545462' +235 '251fd942f1736a6bf03ce1c88330048e04'236 },237 'SHA-256': {238 '1': '4f510c5181ac5c2c5fd4bd141f9712495be' +239 'ca279624742b4d6d30d08b96c0a69',240 '1000': '7e66c84bea888f92c348d9145585186c' +241 'ae472b12fba7f0ad28179575c1aa815a',242 '100000': '5f1a6ac4a56d9796a7309a78daaaf9' +243 '18badaf5ed1eecc3f0b8a3a44c3d38d654'244 }245 }246 },247};248async function setupBaseKeys() {249 const promises = [];250 const baseKeys = {};251 const noBits = {};252 const noKey = {};253 let wrongKey = null;254 Object.keys(kPasswords).forEach((size) => {255 promises.push(256 subtle.importKey(257 'raw',258 Buffer.from(kPasswords[size], 'hex'),259 { name: 'PBKDF2' },260 false,261 ['deriveKey', 'deriveBits'])262 .then((key) => baseKeys[size] = key));263 promises.push(264 subtle.importKey(265 'raw',266 kPasswords[size],267 { name: 'PBKDF2' },268 false,269 ['deriveBits'])270 .then((key) => noKey[size] = key));271 promises.push(272 subtle.importKey(273 'raw',274 kPasswords[size],275 { name: 'PBKDF2' },276 false,277 ['deriveKey'])278 .then((key) => noBits[size] = key));279 });280 promises.push(281 subtle.generateKey(282 { name: 'ECDH', namedCurve: 'P-521' },283 false,284 ['deriveKey', 'deriveBits'])285 .then((key) => wrongKey = key.privateKey));286 await Promise.all(promises);287 return { baseKeys, noBits, noKey, wrongKey };288}289async function testDeriveBits(290 baseKeys,291 size,292 saltSize,293 hash,294 iterations) {295 const algorithm = {296 name: 'PBKDF2',297 salt: Buffer.from(kSalts[saltSize], 'hex'),298 hash,299 iterations300 };301 const bits = await subtle.deriveBits(algorithm, baseKeys[size], 256);302 assert(bits instanceof ArrayBuffer);303 assert.strictEqual(304 Buffer.from(bits).toString('hex'),305 kDerivations[size][saltSize][hash][iterations]);306}307async function testDeriveBitsBadLengths(308 baseKeys,309 size,310 saltSize,311 hash,312 iterations) {313 const algorithm = {314 name: 'PBKDF2',315 salt: Buffer.from(kSalts[saltSize], 'hex'),316 iterations,317 hash318 };319 return Promise.all([320 assert.rejects(321 subtle.deriveBits(algorithm, baseKeys[size], 0), {322 }),323 assert.rejects(324 subtle.deriveBits(algorithm, baseKeys[size], null), {325 code: 'ERR_INVALID_ARG_TYPE'326 }),327 assert.rejects(328 subtle.deriveBits(algorithm, baseKeys[size], 15), {329 }),330 ]);331}332async function testDeriveBitsBadHash(333 baseKeys,334 size,335 saltSize,336 hash,337 iterations) {338 const salt = Buffer.from(kSalts[saltSize], 'hex');339 const algorithm = { name: 'HKDF', salt, iterations };340 return Promise.all([341 assert.rejects(342 subtle.deriveBits(343 {344 ...algorithm,345 hash: hash.substring(0, 3) + hash.substring(4)346 }, baseKeys[size], 256), {347 }),348 assert.rejects(349 subtle.deriveBits(350 {351 ...algorithm,352 hash: 'HKDF'353 },354 baseKeys[size], 256), {355 }),356 ]);357}358async function testDeriveBitsBadUsage(359 noBits,360 size,361 saltSize,362 hash,363 iterations) {364 const algorithm = {365 name: 'PBKDF2',366 salt: Buffer.from(kSalts[saltSize], 'hex'),367 iterations,368 hash369 };370 return assert.rejects(371 subtle.deriveBits(algorithm, noBits[size], 256), {372 });373}374async function testDeriveKey(375 baseKeys,376 size,377 saltSize,378 hash,379 iterations,380 keyType,381 usages) {382 const algorithm = {383 name: 'PBKDF2',384 salt: Buffer.from(kSalts[saltSize], 'hex'),385 hash,386 iterations387 };388 const key = await subtle.deriveKey(389 algorithm,390 baseKeys[size],391 keyType,392 true,393 usages);394 const bits = await subtle.exportKey('raw', key);395 assert.strictEqual(396 Buffer.from(bits).toString('hex'),397 kDerivations[size][saltSize][hash][iterations]398}399async function testDeriveKeyBadHash(400 baseKeys,401 size,402 saltSize,403 hash,404 iterations,405 keyType,406 usages) {407 const salt = Buffer.from(kSalts[saltSize], 'hex');408 const algorithm = { name: 'PBKDF2', salt, iterations };409 return Promise.all([410 assert.rejects(411 subtle.deriveKey(412 {413 ...algorithm,414 hash: hash.substring(0, 3) + hash.substring(4)415 },416 baseKeys[size],417 keyType,418 true,419 usages),420 assert.rejects(421 subtle.deriveKey(422 {423 ...algorithm,424 hash: 'HKDF'425 },426 baseKeys[size],427 keyType,428 true,429 usages),430 ]);431}432async function testDeriveKeyBadUsage(433 noKey,434 size,435 saltSize,436 hash,437 iterations,438 keyType,439 usages) {440 const algorithm = {441 name: 'PBKDF2',442 salt: Buffer.from(kSalts[saltSize], 'hex'),443 iterations,444 hash445 };446 return assert.rejects(447 subtle.deriveKey(algorithm, noKey[size], keyType, true, usages), {448 });449}450async function testWrongKeyType(451 wrongKey,452 saltSize,453 hash,454 iterations,455 keyType,456 usages457) {458 const algorithm = {459 name: 'PBKDF2',460 salt: Buffer.from(kSalts[saltSize], 'hex'),461 iterations,462 hash463 };464 return assert.rejects(465 subtle.deriveKey(algorithm, wrongKey, keyType, true, usages), {466 });467}468(async function() {469 const {470 baseKeys,471 noBits,472 noKey,473 wrongKey474 } = await setupBaseKeys();475 const variations = [];476 Object.keys(kDerivations).forEach((size) => {477 Object.keys(kDerivations[size]).forEach((saltSize) => {478 Object.keys(kDerivations[size][saltSize]).forEach((hash) => {479 Object.keys(kDerivations[size][saltSize][hash])480 .forEach((iterations) => {481 const args = [baseKeys, size, saltSize, hash, iterations | 0];482 variations.push(testDeriveBits(...args));483 variations.push(testDeriveBitsBadLengths(...args));484 variations.push(testDeriveBitsBadHash(...args));485 variations.push(486 testDeriveBitsBadUsage(487 noBits,488 size,489 saltSize,490 hash,491 iterations | 0));492 kDerivedKeyTypes.forEach((keyType) => {493 const keyArgs = getDeriveKeyInfo(...keyType);494 variations.push(testDeriveKey(...args, ...keyArgs));495 variations.push(testDeriveKeyBadHash(...args, ...keyArgs));496 variations.push(497 testDeriveKeyBadUsage(498 noKey,499 size,500 saltSize,501 hash,502 iterations | 0,503 ...keyArgs));504 variations.push(505 testWrongKeyType(506 wrongKey,507 saltSize,508 hash,509 iterations,510 ...keyArgs));511 });512 });513 });514 });515 });516 await Promise.all(variations);...

Full Screen

Full Screen

local.redis.keys.spec2.js

Source:local.redis.keys.spec2.js Github

copy

Full Screen

1(function () {2 var keysValsObj = {3 'number': 23,4 'number1': 1,5 'number2': '0',6 'string': 'abcd',7 'null': null,8 'undefined': undefined,9 'really-big-number': Number.MAX_VALUE + Number.MAX_VALUE10 },11 baseKeys = Object.keys(keysValsObj),12 keys = [],13 key,14 i,15 amount,16 array = [],17 keysThatThrow = [],18 keysThatDontThrow = [];19 describe('Decr Commands - ', function () {20 describe('decr', function() {21 it('decrements a key\'s value by 1', function () {22 keys = []; // This actually mutates from test to test, so we reset23 // it at every function scope.24 for (i = 0; i < baseKeys.length; i++) {25 keys.push(baseKeys[i]);26 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);27 }28 //Attempt to increment29 for(i = 0; i < keys.length; i++) {30 // Javascript does late binding, we must call a lambda to bind at the point31 // of iteration.32 (function (key) {33 // We provide closure so that the inner (throwing) function knows about 'key'34 var f = (function (k) { var key = k; return function () { storage.decr(key); }; })(key);35 // There are a few special cases that we explicitly handle.36 switch(key) {37 case 'string':38 case 'undefined':39 case 'null':40 case 'really-big-number':41 expect(f).toThrow();42 break;43 default:44 storage.decr(key);45 expect(storage.get(key)).toBe(parseInt(keysValsObj[key] - 1, 10));46 break;47 }48 })(keys[i]);49 }50 });51 it('sets the value of a non-existent key to -1', function () {52 //Attempt to increment with no value set in storage.53 storage.decr('foo');54 storage.decr('bar');55 expect(storage.get('foo')).toBe(parseInt(-1, 10));56 expect(storage.get('bar')).toBe(parseInt(-1, 10));57 });58 });59 describe('decrby', function() {60 it('decrements a key\'s value by \'amount\', and sets it to -1 if it does not exist', function () {61 keys = [];62 for (i = 0; i < baseKeys.length; i++) {63 keys.push(baseKeys[i]);64 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);65 }66 amount = Math.ceil(Math.random() * 100);67 for(i = 0; i < keys.length; i++) {68 (function (key, a) {69 var f = (function (k) { var key = k, amount = a; return function () { storage.decrby(key, amount); }; })(key, amount);70 switch(key) {71 case 'string':72 case 'undefined':73 case 'null':74 case 'really-big-number':75 expect(f).toThrow();76 break;77 default:78 storage.decrby(key, amount);79 expect(storage.get(key)).toBe(parseInt(keysValsObj[key] - amount, 10));80 break;81 }82 })(keys[i], amount);83 }84 });85 it('is -\'amount\' if the key does not exist', function () {86 keys = [];87 for (i = 0; i < baseKeys.length; i++) {88 keys.push(baseKeys[i]);89 }90 amount = Math.ceil(Math.random() * 100);91 // Attempt to increment with no value set in storage.92 for(i = 0; i < keys.length; i++) {93 storage.decrby(keys[i], amount);94 expect(storage.get(keys[i])).toBe(parseInt(-amount, 10));95 }96 });97 });98 describe('mdecr', function() {99 var f = function (k) { var keys = k; return function () { storage.mdecr(keys); }; };100 it('decrements a set of keys by 1', function () {101 keysThatThrow = [];102 keysThatDontThrow = [];103 for (i = 0; i < baseKeys.length; i++) {104 keys.push(baseKeys[i]);105 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);106 switch(baseKeys[i]) {107 case 'number':108 case 'number1':109 case 'number2':110 keysThatDontThrow.push(baseKeys[i]);111 break;112 default:113 keysThatThrow.push(baseKeys[i]);114 break;115 }116 }117 expect(f(keysThatThrow)).toThrow();118 expect(f(keysThatDontThrow)).not.toThrow();119 // Check that keys that do not throw have the proper values120 for (i in keysThatDontThrow) {121 key = keysThatDontThrow[i];122 expect(storage.get(key)).toBe(parseInt(keysValsObj[key], 10) - 1);123 }124 });125 it('sets a key\'s value to -1 if it does not exist in the key set', function () {126 keys = [];127 for (i = 0; i < baseKeys.length; i++) {128 keys.push(baseKeys[i]);129 }130 // We do not expect keys to throw on increment, if the keys do not exist in localStorage131 // (provided these are valid keys).132 expect(f(keys)).not.toThrow();133 // Check that keys that do not throw have the proper values134 for (i in keys) {135 key = keys[i];136 expect(storage.get(key)).toBe(-1);137 }138 });139 });140 describe('mdecrby', function() {141 var f = function (k) { var keys = k; return function () { storage.mdecrby(keys); }; };142 it('decrements a set of keys by their respective amounts', function () {143 keysThatThrow = [];144 keysThatDontThrow = [];145 amount = Math.ceil(Math.random() * 100);146 for (i = 0; i < baseKeys.length; i++) {147 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);148 switch(baseKeys[i]) {149 case 'number':150 case 'number1':151 case 'number2':152 keysThatDontThrow.push(baseKeys[i]);153 keysThatDontThrow.push(amount);154 break;155 default:156 keysThatThrow.push(baseKeys[i]);157 keysThatThrow.push(amount);158 break;159 }160 }161 expect(f(keysThatThrow)).toThrow();162 expect(f(keysThatDontThrow)).not.toThrow();163 for (i = 0; i < keysThatDontThrow.length; i += 2) {164 key = keysThatDontThrow[i];165 amount = keysThatDontThrow[i + 1];166 expect(storage.get(key)).toBe(parseInt(keysValsObj[key], 10) - amount);167 }168 });169 it('sets a key\'s value to its respective amount if it does not exist in the key set', function () {170 keys = [];171 amount = Math.ceil(Math.random() * 100);172 for (i = 0; i < baseKeys.length; i++) {173 keys.push(baseKeys[i]);174 keys.push(amount);175 }176 expect(f(keys)).not.toThrow();177 for (i = 0; i < keys.length; i += 2) {178 key = keys[i];179 amount = keys[i + 1];180 expect(storage.get(key)).toBe(-amount);181 }182 });183 });184 });185 describe('Incr Commands - ', function () {186 describe('incr', function() {187 it('increments a key\'s value by 1', function () {188 keys = []; // This actually mutates from test to test, so we reset189 // it at every function scope.190 for (i = 0; i < baseKeys.length; i++) {191 keys.push(baseKeys[i]);192 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);193 }194 //Attempt to increment195 for(i = 0; i < keys.length; i++) {196 // Javascript does late binding, we must call a lambda to bind at the point197 // of iteration.198 (function (key) {199 // We provide closure so that the inner (throwing) function knows about 'key'200 var f = (function (k) { var key = k; return function () { storage.incr(key); }; })(key);201 // There are a few special cases that we explicitly handle.202 switch(key) {203 case 'string':204 case 'undefined':205 case 'null':206 case 'really-big-number':207 expect(f).toThrow();208 break;209 default:210 storage.incr(key);211 expect(storage.get(key)).toBe(parseInt(keysValsObj[key] + 1, 10));212 break;213 }214 })(keys[i]);215 }216 });217 it('sets the value of a non-existent key to 1', function () {218 //Attempt to increment with no value set in storage.219 storage.incr('foo');220 storage.incr('bar');221 expect(storage.get('foo')).toBe(parseInt(1, 10));222 expect(storage.get('bar')).toBe(parseInt(1, 10));223 });224 });225 describe('incrby', function() {226 it('increments a key\'s value by \'amount\', and sets it to 1 if it does not exist', function () {227 keys = [];228 for (i = 0; i < baseKeys.length; i++) {229 keys.push(baseKeys[i]);230 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);231 }232 amount = Math.ceil(Math.random() * 100);233 for(i = 0; i < keys.length; i++) {234 (function (key, a) {235 var f = (function (k) { var key = k, amount = a; return function () { storage.incrby(key, amount); }; })(key, amount);236 switch(key) {237 case 'string':238 case 'undefined':239 case 'null':240 case 'really-big-number':241 expect(f).toThrow();242 break;243 default:244 storage.incrby(key, amount);245 expect(storage.get(key)).toBe(parseInt(keysValsObj[key] + amount, 10));246 break;247 }248 })(keys[i], amount);249 }250 });251 it('is \'amount\' if the key does not exist', function () {252 keys = [];253 for (i = 0; i < baseKeys.length; i++) {254 keys.push(baseKeys[i]);255 }256 amount = Math.ceil(Math.random() * 100);257 // Attempt to increment with no value set in storage.258 for(i = 0; i < keys.length; i++) {259 storage.incrby(keys[i], amount);260 expect(storage.get(keys[i])).toBe(parseInt(amount, 10));261 }262 });263 });264 describe('mincr', function() {265 var f = function (k) { var keys = k; return function () { storage.mincr(keys); }; };266 it('increments a set of keys by 1', function () {267 keysThatThrow = [];268 keysThatDontThrow = [];269 for (i = 0; i < baseKeys.length; i++) {270 keys.push(baseKeys[i]);271 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);272 switch(baseKeys[i]) {273 case 'number':274 case 'number1':275 case 'number2':276 keysThatDontThrow.push(baseKeys[i]);277 break;278 default:279 keysThatThrow.push(baseKeys[i]);280 break;281 }282 }283 expect(f(keysThatThrow)).toThrow();284 expect(f(keysThatDontThrow)).not.toThrow();285 // Check that keys that do not throw have the proper values286 for (i in keysThatDontThrow) {287 key = keysThatDontThrow[i];288 expect(storage.get(key)).toBe(parseInt(keysValsObj[key], 10) + 1);289 }290 });291 it('sets a key\'s value to 1 if it does not exist in the key set', function () {292 keys = [];293 for (i = 0; i < baseKeys.length; i++) {294 keys.push(baseKeys[i]);295 }296 // We do not expect keys to throw on increment, if the keys do not exist in localStorage297 // (provided these are valid keys).298 expect(f(keys)).not.toThrow();299 // Check that keys that do not throw have the proper values300 for (i in keys) {301 key = keys[i];302 expect(storage.get(key)).toBe(1);303 }304 });305 });306 describe('mincrby', function() {307 var f = function (k) { var keys = k; return function () { storage.mincrby(keys); }; };308 it('increments a set of keys by their respective amounts', function () {309 keysThatThrow = [];310 keysThatDontThrow = [];311 amount = Math.ceil(Math.random() * 100);312 for (i = 0; i < baseKeys.length; i++) {313 storage.set(baseKeys[i], keysValsObj[baseKeys[i]]);314 switch(baseKeys[i]) {315 case 'number':316 case 'number1':317 case 'number2':318 keysThatDontThrow.push(baseKeys[i]);319 keysThatDontThrow.push(amount);320 break;321 default:322 keysThatThrow.push(baseKeys[i]);323 keysThatThrow.push(amount);324 break;325 }326 }327 expect(f(keysThatThrow)).toThrow();328 expect(f(keysThatDontThrow)).not.toThrow();329 for (i = 0; i < keysThatDontThrow.length; i += 2) {330 key = keysThatDontThrow[i];331 amount = keysThatDontThrow[i + 1];332 expect(storage.get(key)).toBe(parseInt(keysValsObj[key], 10) + amount);333 }334 });335 it('sets a key\'s value to its respective amount if it does not exist in the key set', function () {336 keys = [];337 amount = Math.ceil(Math.random() * 100);338 for (i = 0; i < baseKeys.length; i++) {339 keys.push(baseKeys[i]);340 keys.push(amount);341 }342 expect(f(keys)).not.toThrow();343 for (i = 0; i < keys.length; i += 2) {344 key = keys[i];345 amount = keys[i + 1];346 expect(storage.get(key)).toBe(amount);347 }348 });349 });350 });...

Full Screen

Full Screen

aflprep_test-webcrypto-derivebits-hkdf.js

Source:aflprep_test-webcrypto-derivebits-hkdf.js Github

copy

Full Screen

1'use strict';2if (!common.hasCrypto)3 common.skip('missing crypto');4const assert = require('assert');5const { subtle } = require('crypto').webcrypto;6function getDeriveKeyInfo(name, length, hash, ...usages) {7 return [{ name, length, hash }, usages];8}9const kDerivedKeyTypes = [10 ['AES-CBC', 128, undefined, 'encrypt', 'decrypt'],11 ['AES-CBC', 256, undefined, 'encrypt', 'decrypt'],12 ['AES-CTR', 128, undefined, 'encrypt', 'decrypt'],13 ['AES-CTR', 256, undefined, 'encrypt', 'decrypt'],14 ['AES-GCM', 128, undefined, 'encrypt', 'decrypt'],15 ['AES-GCM', 256, undefined, 'encrypt', 'decrypt'],16 ['AES-KW', 128, undefined, 'wrapKey', 'unwrapKey'],17 ['AES-KW', 256, undefined, 'wrapKey', 'unwrapKey'],18 ['HMAC', 256, 'SHA-1', 'sign', 'verify'],19 ['HMAC', 256, 'SHA-256', 'sign', 'verify'],20 ['HMAC', 256, 'SHA-384', 'sign', 'verify'],21 ['HMAC', 256, 'SHA-512', 'sign', 'verify'],22];23const kDerivedKeys = {24 short: '5040737377307264',25 long: '55736572732073686f756c64207069636b206c6f6e6720706173737068726' +26 '173657320286e6f74207573652073686f72742070617373776f7264732921',27};28const kSalts = {29 normal: '536f6469756d2043686c6f7269646520636f6d706f756e64',30 empty: ''31};32const kInfos = {33 normal: '484b444620657874726120696e666f',34 empty: ''35};36const kDerivations = {37 short: {38 normal: {39 'SHA-384': {40 normal: '19ba74368e6b993390f27fe9a7d02bc3' +41 '38173f72be71a19fc744fcdb3fd4b84b',42 empty: '97601f4e0c53a5d3f3a2810099bc6820' +43 'ec50083434769b59fc24a417a9543734'44 },45 'SHA-512': {46 normal: '4bbd6db2435fb696157f6089c977c3c7' +47 '3f3eac5ef3dd6baae604cb53bfbb153e',48 empty: '2f3157e7fe0c10b01298c8f0886a90ed' +49 'cf80abdef5dbc1df2b1482532b52b934'50 },51 'SHA-1': {52 normal: '05ad22ed2138c9600e4d9e2725ded301' +53 'f5d287fbfb5702f999bc6536d3edef98',54 empty: 'd51b6fb7e599ca30c5ee264593e4b85f' +55 '2220c7c3ab003157bff8cb4f369c7560'56 },57 'SHA-256': {58 normal: '2af5901e28849c28443857386aa1ac3b' +59 'b127e92631c1c051482d6690941772b4',60 empty: '9e4b719033742101e90f1ad61e2ff3b4' +61 '256863667296d74389f1f02af2c4e6a6'62 }63 },64 empty: {65 'SHA-384': {66 normal: 'fb482ff22c4f8d466c4dfe6e29f2cc2e' +67 'cdabf5884328fbf08a738fd945f166cb',68 empty: '1e023c17b340533ceaef39230cb8b3bb' +69 'dbf663a13d6075d0dd326c049478fba5'70 },71 'SHA-512': {72 normal: 'f17b5bdcd8d7d3d4601036a19436317d' +73 '1644f9a4e0956efc0e372b83acdacfdb',74 empty: 'c7b474942f31f83faf5d14731802b1bd' +75 '49478549cb3a8f3dbfedc4d3209cf5b6'76 },77 'SHA-1': {78 normal: 'c126f1e6f25a9de42cf7d427059a52ed' +79 '9601f29a5815cbfbc64bc7f668c6a341',80 empty: '3215c3f08de70549b051b7033745a818' +81 '4f8cbaa6b1735330d2bcb6b16f4642ef'82 },83 'SHA-256': {84 normal: '733c8b6bcfac875c7f08982a6e3ffb56' +85 '0acea6f165476eb83460b9353ed41dfe',86 empty: 'c8e12774135305c9147f2cc4766e5ead' +87 '25d8f457b9a1953d52677361ced558fb'88 }89 }90 },91 long: {92 normal: {93 'SHA-384': {94 normal: 'f91571b521f7eef13e573aa46378659e' +95 'f3b7f36ffdd1bb055db2cd77d260c467',96 empty: '68af1c2cf6b9370d2054344798bdbb18' +97 '47ccf407b7652b793dd136d4640e0348'98 },99 'SHA-512': {100 normal: '710aae2fdf889e45fe0fb995b2c26b33' +101 'eb988650ec0faef167028a7a6ccb3638',102 empty: 'e5de568081c71e562750829871c34275' +103 '8104765ed6f306f0613c9d4bb336f2aa'104 },105 'SHA-1': {106 normal: '7f957edcbce3cb0b70566e1eb60efd1e' +107 '405a13304c661d3663778109bf06899c',108 empty: '3062f3cf1a730b9cef51f02c1dfac85e' +109 'd91e4b0065eb50ca9fd8b0107e728733'110 },111 'SHA-256': {112 normal: '31b7d68530a863e717c081ca6917b686' +113 '50b3dd9a29f30606e2cad199bec14d13',114 empty: 'e579d1f9e7f08e6f990ffcfcce1ed201' +115 'c5e37e62cdf606f0ba4aca80427fbc44'116 }117 },118 empty: {119 'SHA-384': {120 normal: '619eb6f9287395bbd5ed6a67c968465a' +121 'd82b6c559f3c38b604bbb08f58320b03',122 empty: 'ff447b423d83fe76836c32337228b56b' +123 '5bd9bf68d58e7dca4b7cca842a45e11a'124 },125 'SHA-512': {126 normal: '133e8a7f7ff433690cc88432c2a338c2' +127 '77e5c13756ff878f46753fe6a564e3e5',128 empty: 'de54f7eec80c9cc66d349fc987f80d46' +129 '1db2ef4ff4e18505d28bd80cb42c7d76'130 },131 'SHA-1': {132 normal: 'adb93cdbce79b7d51159b6c0131a2b62' +133 'f23828d26acd685e34c06535e6f77496',134 empty: '47710d2a7507e05a1ddcc87a7c2f9061' +135 '77a266efb9e622510cccb3713cd08d58'136 },137 'SHA-256': {138 normal: 'a401d7c9158a29e5c7193ab9730f0748' +139 '851cc5baadb42cad024b6290fe213436',140 empty: 'b4f7e7557674d501cbfbc0148ad800c0' +141 '750189fe295a2aca5e1bf4122c85edf9'142 }143 }144 },145};146async function setupBaseKeys() {147 const promises = [];148 const baseKeys = {};149 const noBits = {};150 const noKey = {};151 let wrongKey = null;152 Object.keys(kDerivedKeys).forEach((size) => {153 const keyData = Buffer.from(kDerivedKeys[size], 'hex');154 promises.push(155 subtle.importKey(156 'raw',157 keyData,158 { name: 'HKDF' },159 false,160 ['deriveKey', 'deriveBits'])161 .then(162 (baseKey) => baseKeys[size] = baseKey,163 (err) => assert.ifError(err)));164 promises.push(165 subtle.importKey(166 'raw',167 keyData,168 { name: 'HKDF' },169 false, ['deriveBits'])170 .then(171 (baseKey) => noKey[size] = baseKey,172 (err) => assert.ifError(err)));173 promises.push(174 subtle.importKey(175 'raw',176 keyData,177 { name: 'HKDF' },178 false, ['deriveKey'])179 .then(180 (baseKey) => noBits[size] = baseKey,181 (err) => assert.ifError(err)));182 });183 promises.push(184 subtle.generateKey(185 {186 name: 'ECDH',187 namedCurve: 'P-521'188 },189 false,190 ['deriveKey', 'deriveBits'])191 .then(192 (baseKey) => wrongKey = baseKey.privateKey,193 (err) => assert.ifError(err)));194 await Promise.all(promises);195 return {196 baseKeys,197 noBits,198 noKey,199 wrongKey200 };201}202async function testDeriveBits(203 baseKeys,204 size,205 saltSize,206 hash,207 infoSize) {208 const algorithm = {209 name: 'HKDF',210 salt: Buffer.from(kSalts[saltSize], 'hex'),211 info: Buffer.from(kInfos[infoSize], 'hex'),212 hash213 };214 const bits = await subtle.deriveBits(215 algorithm,216 baseKeys[size],217 256);218 assert(bits instanceof ArrayBuffer);219 assert.strictEqual(220 Buffer.from(bits).toString('hex'),221 kDerivations[size][saltSize][hash][infoSize]);222}223async function testDeriveBitsBadLengths(224 baseKeys,225 size,226 saltSize,227 hash,228 infoSize) {229 const algorithm = {230 name: 'HKDF',231 salt: Buffer.from(kSalts[saltSize], 'hex'),232 info: Buffer.from(kInfos[infoSize], 'hex'),233 hash234 };235 return Promise.all([236 assert.rejects(237 subtle.deriveBits(algorithm, baseKeys[size], 0), {238 }),239 assert.rejects(240 subtle.deriveBits(algorithm, baseKeys[size], null), {241 code: 'ERR_INVALID_ARG_TYPE'242 }),243 assert.rejects(244 subtle.deriveBits(algorithm, baseKeys[size], 15), {245 }),246 ]);247}248async function testDeriveBitsBadHash(249 baseKeys,250 size,251 saltSize,252 hash,253 infoSize) {254 const salt = Buffer.from(kSalts[saltSize], 'hex');255 const info = Buffer.from(kInfos[infoSize], 'hex');256 const algorithm = { name: 'HKDF', salt, info };257 return Promise.all([258 assert.rejects(259 subtle.deriveBits(260 {261 ...algorithm,262 hash: hash.substring(0, 3) + hash.substring(4)263 }, baseKeys[size], 256), {264 }),265 assert.rejects(266 subtle.deriveBits(267 {268 ...algorithm,269 hash: 'PBKDF2'270 },271 baseKeys[size], 256), {272 }),273 ]);274}275async function testDeriveBitsBadUsage(276 noBits,277 size,278 saltSize,279 hash,280 infoSize) {281 const algorithm = {282 name: 'HKDF',283 salt: Buffer.from(kSalts[saltSize], 'hex'),284 info: Buffer.from(kInfos[infoSize], 'hex'),285 hash286 };287 return assert.rejects(288 subtle.deriveBits(algorithm, noBits[size], 256), {289 });290}291async function testDeriveBitsMissingSalt(292 baseKeys,293 size,294 saltSize,295 hash,296 infoSize) {297 const algorithm = {298 name: 'HKDF',299 info: Buffer.from(kInfos[infoSize], 'hex'),300 hash301 };302 return assert.rejects(303 subtle.deriveBits(algorithm, baseKeys[size], 0), {304 code: 'ERR_INVALID_ARG_TYPE'305 });306}307async function testDeriveBitsMissingInfo(308 baseKeys,309 size,310 saltSize,311 hash,312 infoSize) {313 const algorithm = {314 name: 'HKDF',315 salt: Buffer.from(kSalts[infoSize], 'hex'),316 hash317 };318 return assert.rejects(319 subtle.deriveBits(algorithm, baseKeys[size], 0), {320 code: 'ERR_INVALID_ARG_TYPE'321 });322}323async function testBitsWrongKeyType(324 wrongKey,325 saltSize,326 hash,327 infoSize) {328 const algorithm = {329 name: 'HKDF',330 salt: Buffer.from(kSalts[saltSize], 'hex'),331 info: Buffer.from(kInfos[infoSize], 'hex'),332 hash333 };334 return assert.rejects(335 subtle.deriveBits(algorithm, wrongKey, 256), {336 });337}338async function testDeriveKey(339 baseKeys,340 size,341 saltSize,342 hash,343 infoSize,344 keyType,345 usages) {346 const algorithm = {347 name: 'HKDF',348 salt: Buffer.from(kSalts[saltSize], 'hex'),349 info: Buffer.from(kInfos[infoSize], 'hex'),350 hash351 };352 const key = await subtle.deriveKey(353 algorithm,354 baseKeys[size],355 keyType,356 true,357 usages);358 const bits = await subtle.exportKey('raw', key);359 assert.strictEqual(360 Buffer.from(bits).toString('hex'),361}362async function testDeriveKeyBadHash(363 baseKeys,364 size,365 saltSize,366 hash,367 infoSize,368 keyType,369 usages) {370 const salt = Buffer.from(kSalts[saltSize], 'hex');371 const info = Buffer.from(kInfos[infoSize], 'hex');372 const algorithm = { name: 'HKDF', salt, info };373 return Promise.all([374 assert.rejects(375 subtle.deriveKey(376 {377 ...algorithm,378 hash: hash.substring(0, 3) + hash.substring(4)379 },380 baseKeys[size],381 keyType,382 true,383 usages),384 assert.rejects(385 subtle.deriveKey(386 {387 ...algorithm,388 hash: 'PBKDF2'389 },390 baseKeys[size],391 keyType,392 true,393 usages),394 ]);395}396async function testDeriveKeyBadUsage(397 noKey,398 size,399 saltSize,400 hash,401 infoSize,402 keyType,403 usages) {404 const algorithm = {405 name: 'HKDF',406 salt: Buffer.from(kSalts[saltSize], 'hex'),407 info: Buffer.from(kInfos[infoSize], 'hex'),408 hash409 };410 return assert.rejects(411 subtle.deriveKey(algorithm, noKey[size], keyType, true, usages), {412 });413}414async function testWrongKeyType(415 wrongKey,416 saltSize,417 hash,418 infoSize,419 keyType,420 usages421) {422 const algorithm = {423 name: 'HKDF',424 salt: Buffer.from(kSalts[saltSize], 'hex'),425 info: Buffer.from(kInfos[infoSize], 'hex'),426 hash427 };428 return assert.rejects(429 subtle.deriveKey(algorithm, wrongKey, keyType, true, usages), {430 });431}432(async function() {433 const {434 baseKeys,435 noBits,436 noKey,437 wrongKey,438 } = await setupBaseKeys();439 const variations = [];440 Object.keys(kDerivations).forEach((size) => {441 Object.keys(kDerivations[size]).forEach((saltSize) => {442 Object.keys(kDerivations[size][saltSize]).forEach((hash) => {443 Object.keys(kDerivations[size][saltSize][hash]).forEach(444 async (infoSize) => {445 const args = [baseKeys, size, saltSize, hash, infoSize];446 variations.push(testDeriveBits(...args));447 variations.push(testDeriveBitsBadLengths(...args));448 variations.push(testDeriveBitsMissingSalt(...args));449 variations.push(testDeriveBitsMissingInfo(...args));450 variations.push(testDeriveBitsBadHash(...args));451 variations.push(452 testDeriveBitsBadUsage(453 noBits,454 size,455 saltSize,456 hash,457 infoSize));458 variations.push(459 testBitsWrongKeyType(460 wrongKey,461 saltSize,462 hash,463 infoSize));464 kDerivedKeyTypes.forEach((keyType) => {465 const keyArgs = getDeriveKeyInfo(...keyType);466 variations.push(testDeriveKey(...args, ...keyArgs));467 variations.push(testDeriveKeyBadHash(...args, ...keyArgs));468 variations.push(testDeriveKeyBadUsage(469 noKey, size, saltSize, hash, infoSize, ...keyArgs));470 variations.push(471 testWrongKeyType(472 wrongKey,473 saltSize,474 hash,475 infoSize,476 ...keyArgs));477 });478 });479 });480 });481 });482 await Promise.all(variations);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var obj = {a: 1, b: 2, c: 3};3console.log(ladle.baseKeys(obj));4var ladle = require('ladle');5var obj = {a: 1, b: 2, c: 3};6console.log(ladle.baseKeysIn(obj));7var ladle = require('ladle');8var obj = {a: 1, b: 2, c: 3};9console.log(ladle.baseMap(obj));10var ladle = require('ladle');11var obj = {a: 1, b: 2, c: 3};12console.log(ladle.baseMatches(obj));13var ladle = require('ladle');14var obj = {a: 1, b: 2, c: 3};15console.log(ladle.baseMatchesProperty(obj));16var ladle = require('ladle');17var obj = {a: 1, b: 2, c: 3};18console.log(ladle.baseMerge(obj));19var ladle = require('ladle');20var obj = {a: 1, b: 2, c: 3};21console.log(ladle.baseMergeDeep(obj));22var ladle = require('ladle');23var obj = {a: 1, b: 2, c: 3};24console.log(ladle.baseNth(obj));

Full Screen

Using AI Code Generation

copy

Full Screen

1const ladle = require('ladle');2const baseKeys = ladle.baseKeys;3const base = {a: 1, b: 2, c: 3};4const keys = baseKeys(base);5const ladle = require('ladle');6const baseValues = ladle.baseValues;7const base = {a: 1, b: 2, c: 3};8const values = baseValues(base);9const ladle = require('ladle');10const basePairs = ladle.basePairs;11const base = {a: 1, b: 2, c: 3};12const pairs = basePairs(base);13const ladle = require('ladle');14const baseForOwn = ladle.baseForOwn;15const base = {a: 1, b: 2, c: 3};16const iteratee = function(value, key, base) {17 console.log(value, key, base);18};19baseForOwn(base, iteratee);20const ladle = require('ladle');21const baseForOwnRight = ladle.baseForOwnRight;22const base = {a: 1, b: 2, c: 3};23const iteratee = function(value, key, base) {24 console.log(value, key, base);25};26baseForOwnRight(base, iteratee);27const ladle = require('ladle');28const baseForOwnDeep = ladle.baseForOwnDeep;29const base = {a: 1, b: 2, c: 3};30const iteratee = function(value, key, base) {31 console.log(value, key, base);32};33baseForOwnDeep(base, iteratee);34const ladle = require('ladle');35const baseForOwnDeepRight = ladle.baseForOwnDeepRight;

Full Screen

Using AI Code Generation

copy

Full Screen

1const ladle = require('ladle');2const baseKeys = ladle.baseKeys;3const data = {4 a: {5 },6 e: {7 g: {8 }9 }10};11const baseKeys = baseKeys(data);12const ladle = require('ladle');13const baseKeysDeep = ladle.baseKeysDeep;14const data = {15 a: {16 },17 e: {18 g: {19 }20 }21};22const baseKeysDeep = baseKeysDeep(data);23const ladle = require('ladle');24const baseValues = ladle.baseValues;25const data = {26 a: {27 },28 e: {29 g: {30 }31 }32};33const baseValues = baseValues(data);34const ladle = require('ladle');35const baseValuesDeep = ladle.baseValuesDeep;36const data = {37 a: {38 },

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var l = ladle.createClient({3});4l.baseKeys(function(err, keys) {5 if (err) {6 console.log(err);7 }8 else {9 console.log(keys);10 }11});12var ladle = require('ladle');13var l = ladle.createClient({14});15l.baseKeys(function(err, keys) {16 if (err) {17 console.log(err);18 }19 else {20 console.log(keys);21 }22});23var ladle = require('ladle');24var l = ladle.createClient({25});26l.baseKeys(function(err, keys) {27 if (err) {28 console.log(err);29 }30 else {31 console.log(keys);32 }33});34var ladle = require('ladle');35var l = ladle.createClient({36});37l.baseKeys(function(err, keys) {38 if (err) {39 console.log(err);40 }41 else {42 console.log(keys);43 }44});45var ladle = require('ladle');46var l = ladle.createClient({47});48l.baseKeys(function(err, keys) {49 if (err) {50 console.log(err);51 }52 else {53 console.log(keys);54 }55});56var ladle = require('ladle');57var l = ladle.createClient({58});59l.baseKeys(function(err, keys) {60 if (err) {61 console.log(err);62 }63 else {64 console.log(keys);65 }66});67var ladle = require('ladle');68var l = ladle.createClient({69});70l.baseKeys(function(err, keys) {71 if (err) {72 console.log(err);73 }74 else {75 console.log(keys);76 }77});78var ladle = require('ladle');79var l = ladle.createClient({80});

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var ladleObj = new ladle();3var obj = { 'a': 1, 'b': 2 };4var baseKeys = ladleObj.baseKeys(obj);5console.log(baseKeys);6var ladle = require('ladle');7var ladleObj = new ladle();8var obj = { 'a': 1, 'b': 2 };9var baseValues = ladleObj.baseValues(obj);10console.log(baseValues);11var ladle = require('ladle');12var ladleObj = new ladle();13var obj = { 'a': 1, 'b': 2 };14var basePairs = ladleObj.basePairs(obj);15console.log(basePairs);16var ladle = require('ladle');17var ladleObj = new ladle();18var obj = { 'a': 1, 'b': 2, 'c': 1 };

Full Screen

Using AI Code Generation

copy

Full Screen

1var ladle = require('ladle');2var l = new ladle.Ladle();3var obj = {a:1, b:2, c:3};4var keys = l.baseKeys(obj);5console.log(keys);6var ladle = require('ladle');7var l = new ladle.Ladle();8var obj = {a:1, b:2, c:3};9var keys = l.baseKeysIn(obj);10console.log(keys);11var ladle = require('ladle');12var l = new ladle.Ladle();13var last = l.baseLast([1, 2, 3]);14console.log(last);15var ladle = require('ladle');16var l = new ladle.Ladle();17var index = l.baseLastIndexOf([1, 2, 3, 1, 2, 3], 2);18console.log(index);19var ladle = require('ladle');20var l = new ladle.Ladle();21var obj = {a:1, b:2, c:3};22var map = l.baseMap(obj);23console.log(map);

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ladle automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful