Best JavaScript code snippet using jest
watchman.js
Source:watchman.js
1'use strict';2function path() {3 const data = _interopRequireWildcard(require('path'));4 path = function () {5 return data;6 };7 return data;8}9function _fbWatchman() {10 const data = _interopRequireDefault(require('fb-watchman'));11 _fbWatchman = function () {12 return data;13 };14 return data;15}16function _constants() {17 const data = _interopRequireDefault(require('../constants'));18 _constants = function () {19 return data;20 };21 return data;22}23function fastPath() {24 const data = _interopRequireWildcard(require('../lib/fast_path'));25 fastPath = function () {26 return data;27 };28 return data;29}30function _normalizePathSep() {31 const data = _interopRequireDefault(require('../lib/normalizePathSep'));32 _normalizePathSep = function () {33 return data;34 };35 return data;36}37function _interopRequireDefault(obj) {38 return obj && obj.__esModule ? obj : {default: obj};39}40function _getRequireWildcardCache() {41 if (typeof WeakMap !== 'function') return null;42 var cache = new WeakMap();43 _getRequireWildcardCache = function () {44 return cache;45 };46 return cache;47}48function _interopRequireWildcard(obj) {49 if (obj && obj.__esModule) {50 return obj;51 }52 if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {53 return {default: obj};54 }55 var cache = _getRequireWildcardCache();56 if (cache && cache.has(obj)) {57 return cache.get(obj);58 }59 var newObj = {};60 var hasPropertyDescriptor =61 Object.defineProperty && Object.getOwnPropertyDescriptor;62 for (var key in obj) {63 if (Object.prototype.hasOwnProperty.call(obj, key)) {64 var desc = hasPropertyDescriptor65 ? Object.getOwnPropertyDescriptor(obj, key)66 : null;67 if (desc && (desc.get || desc.set)) {68 Object.defineProperty(newObj, key, desc);69 } else {70 newObj[key] = obj[key];71 }72 }73 }74 newObj.default = obj;75 if (cache) {76 cache.set(obj, newObj);77 }78 return newObj;79}80/**81 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.82 *83 * This source code is licensed under the MIT license found in the84 * LICENSE file in the root directory of this source tree.85 */86const watchmanURL = 'https://facebook.github.io/watchman/docs/troubleshooting';87function WatchmanError(error) {88 error.message =89 `Watchman error: ${error.message.trim()}. Make sure watchman ` +90 `is running for this project. See ${watchmanURL}.`;91 return error;92}93module.exports = async function watchmanCrawl(options) {94 const fields = ['name', 'exists', 'mtime_ms', 'size'];95 const {data, extensions, ignore, rootDir, roots} = options;96 const defaultWatchExpression = [97 'allof',98 ['type', 'f'],99 ['anyof', ...extensions.map(extension => ['suffix', extension])]100 ];101 const clocks = data.clocks;102 const client = new (_fbWatchman().default.Client)();103 let clientError;104 client.on('error', error => (clientError = WatchmanError(error))); // TODO: type better than `any`105 const cmd = (...args) =>106 new Promise((resolve, reject) =>107 client.command(args, (error, result) =>108 error ? reject(WatchmanError(error)) : resolve(result)109 )110 );111 if (options.computeSha1) {112 const {capabilities} = await cmd('list-capabilities');113 if (capabilities.indexOf('field-content.sha1hex') !== -1) {114 fields.push('content.sha1hex');115 }116 }117 async function getWatchmanRoots(roots) {118 const watchmanRoots = new Map();119 await Promise.all(120 roots.map(async root => {121 const response = await cmd('watch-project', root);122 const existing = watchmanRoots.get(response.watch); // A root can only be filtered if it was never seen with a123 // relative_path before.124 const canBeFiltered = !existing || existing.length > 0;125 if (canBeFiltered) {126 if (response.relative_path) {127 watchmanRoots.set(128 response.watch,129 (existing || []).concat(response.relative_path)130 );131 } else {132 // Make the filter directories an empty array to signal that this133 // root was already seen and needs to be watched for all files or134 // directories.135 watchmanRoots.set(response.watch, []);136 }137 }138 })139 );140 return watchmanRoots;141 }142 async function queryWatchmanForDirs(rootProjectDirMappings) {143 const files = new Map();144 let isFresh = false;145 await Promise.all(146 Array.from(rootProjectDirMappings).map(147 async ([root, directoryFilters]) => {148 const expression = Array.from(defaultWatchExpression);149 const glob = [];150 if (directoryFilters.length > 0) {151 expression.push([152 'anyof',153 ...directoryFilters.map(dir => ['dirname', dir])154 ]);155 for (const directory of directoryFilters) {156 for (const extension of extensions) {157 glob.push(`${directory}/**/*.${extension}`);158 }159 }160 } else {161 for (const extension of extensions) {162 glob.push(`**/*.${extension}`);163 }164 }165 const relativeRoot = fastPath().relative(rootDir, root);166 const query = clocks.has(relativeRoot) // Use the `since` generator if we have a clock available167 ? {168 expression,169 fields,170 since: clocks.get(relativeRoot)171 } // Otherwise use the `glob` filter172 : {173 expression,174 fields,175 glob,176 glob_includedotfiles: true177 };178 const response = await cmd('query', root, query);179 if ('warning' in response) {180 console.warn('watchman warning: ', response.warning);181 }182 isFresh = isFresh || response.is_fresh_instance;183 files.set(root, response);184 }185 )186 );187 return {188 files,189 isFresh190 };191 }192 let files = data.files;193 let removedFiles = new Map();194 const changedFiles = new Map();195 let watchmanFiles;196 let isFresh = false;197 try {198 const watchmanRoots = await getWatchmanRoots(roots);199 const watchmanFileResults = await queryWatchmanForDirs(watchmanRoots); // Reset the file map if watchman was restarted and sends us a list of200 // files.201 if (watchmanFileResults.isFresh) {202 files = new Map();203 removedFiles = new Map(data.files);204 isFresh = true;205 }206 watchmanFiles = watchmanFileResults.files;207 } finally {208 client.end();209 }210 if (clientError) {211 throw clientError;212 } // TODO: remove non-null213 for (const [watchRoot, response] of watchmanFiles) {214 const fsRoot = (0, _normalizePathSep().default)(watchRoot);215 const relativeFsRoot = fastPath().relative(rootDir, fsRoot);216 clocks.set(relativeFsRoot, response.clock);217 for (const fileData of response.files) {218 const filePath =219 fsRoot + path().sep + (0, _normalizePathSep().default)(fileData.name);220 const relativeFilePath = fastPath().relative(rootDir, filePath);221 const existingFileData = data.files.get(relativeFilePath); // If watchman is fresh, the removed files map starts with all files222 // and we remove them as we verify they still exist.223 if (isFresh && existingFileData && fileData.exists) {224 removedFiles.delete(relativeFilePath);225 }226 if (!fileData.exists) {227 // No need to act on files that do not exist and were not tracked.228 if (existingFileData) {229 files.delete(relativeFilePath); // If watchman is not fresh, we will know what specific files were230 // deleted since we last ran and can track only those files.231 if (!isFresh) {232 removedFiles.set(relativeFilePath, existingFileData);233 }234 }235 } else if (!ignore(filePath)) {236 const mtime =237 typeof fileData.mtime_ms === 'number'238 ? fileData.mtime_ms239 : fileData.mtime_ms.toNumber();240 const size = fileData.size;241 let sha1hex = fileData['content.sha1hex'];242 if (typeof sha1hex !== 'string' || sha1hex.length !== 40) {243 sha1hex = null;244 }245 let nextData;246 if (247 existingFileData &&248 existingFileData[_constants().default.MTIME] === mtime249 ) {250 nextData = existingFileData;251 } else if (252 existingFileData &&253 sha1hex &&254 existingFileData[_constants().default.SHA1] === sha1hex255 ) {256 nextData = [257 existingFileData[0],258 mtime,259 existingFileData[2],260 existingFileData[3],261 existingFileData[4],262 existingFileData[5]263 ];264 } else {265 // See ../constants.ts266 nextData = ['', mtime, size, 0, '', sha1hex];267 }268 files.set(relativeFilePath, nextData);269 changedFiles.set(relativeFilePath, nextData);270 }271 }272 }273 data.files = files;274 return {275 changedFiles: isFresh ? undefined : changedFiles,276 hasteMap: data,277 removedFiles278 };...
dnsanchor.js
Source:dnsanchor.js
...28 { login, apiKey },29 { timestamp, salt },30 sha1hex,31) {32 const bodyHash = sha1hex(body);33 const parts = [34 login,35 timestamp.toString(),36 salt,37 apiKey,38 requestURI,39 bodyHash,40 ];41 const hash = sha1hex(parts.join(';'));42 return [login, timestamp, salt, hash].join(';');43}44auth.test = function testAuth(sha1hex) {45 const example =46 'testuser;1012121212;dkwo28Sile4jdXkw;p3kxmRKf9dk3l6ls;/site/example/getInfo;da39a3ee5e6b4b0d3255bfef95601890afd80709';47 const expected =48 'testuser;1012121212;dkwo28Sile4jdXkw;0fa8932e122d56e2f6d1550f9aab39c4aef8bfc4';49 const [login, timestamp, salt, apiKey, url] = example.split(';');50 const actual = auth(url, '', { login, apiKey }, { timestamp, salt }, sha1hex);51 console.log({ actual, expected, OK: actual === expected });52};53/**54 * @param {{[p: string]: string | number | undefined }} params55 * @param {string=} path...
demo1.js
Source:demo1.js
1 2var express = require('express');3var app = express();4app.get('/',(req,res)=>{5 console.log(req.query);6 var signature = [];7 for (let i in req.query) {8 signature.push(req.query[i]);9 }10 signature.splice(0,2);11 signature.push('wx123');12 signature.sort()13 console.log('åå
¸æåº'+signature)14 var str = signature.join('');15 var sha1 = SHA2(str);16 console.log('å å¯sha1'+sha1)17 console.log(req.query.signature)18 if(sha1 == req.query.signature){19 console.log('1')20 res.send(req.query.echostr);21 }22 console.log(signature);23 24})25app.listen(80);26function add(x, y) { 27 return((x & 0x7FFFFFFF) + (y & 0x7FFFFFFF)) ^ (x & 0x80000000) ^ (y & 0x80000000); 28} 29function SHA1hex(num) { 30 var sHEXChars = "0123456789abcdef"; 31 var str = ""; 32 for(var j = 7; j >= 0; j--) 33 str += sHEXChars.charAt((num >> (j * 4)) & 0x0F); 34 return str; 35} 36function AlignSHA1(sIn) { 37 var nblk = ((sIn.length + 8) >> 6) + 1, 38 blks = new Array(nblk * 16); 39 for(var i = 0; i < nblk * 16; i++) blks[i] = 0; 40 for(i = 0; i < sIn.length; i++) 41 blks[i >> 2] |= sIn.charCodeAt(i) << (24 - (i & 3) * 8); 42 blks[i >> 2] |= 0x80 << (24 - (i & 3) * 8); 43 blks[nblk * 16 - 1] = sIn.length * 8; 44 return blks; 45} 46function rol(num, cnt) { 47 return(num << cnt) | (num >>> (32 - cnt)); 48} 49function ft(t, b, c, d) { 50 if(t < 20) return(b & c) | ((~b) & d); 51 if(t < 40) return b ^ c ^ d; 52 if(t < 60) return(b & c) | (b & d) | (c & d); 53 return b ^ c ^ d; 54} 55function kt(t) { 56 return(t < 20) ? 1518500249 : (t < 40) ? 1859775393 : 57 (t < 60) ? -1894007588 : -899497514; 58} 59function SHA1(sIn) { 60 var x = AlignSHA1(sIn); 61 var w = new Array(80); 62 var a = 1732584193; 63 var b = -271733879; 64 var c = -1732584194; 65 var d = 271733878; 66 var e = -1009589776; 67 for(var i = 0; i < x.length; i += 16) { 68 var olda = a; 69 var oldb = b; 70 var oldc = c; 71 var oldd = d; 72 var olde = e; 73 for(var j = 0; j < 80; j++) { 74 if(j < 16) w[j] = x[i + j]; 75 else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1); 76 t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j))); 77 e = d; 78 d = c; 79 c = rol(b, 30); 80 b = a; 81 a = t; 82 } 83 a = add(a, olda); 84 b = add(b, oldb); 85 c = add(c, oldc); 86 d = add(d, oldd); 87 e = add(e, olde); 88 } 89 SHA1Value = SHA1hex(a) + SHA1hex(b) + SHA1hex(c) + SHA1hex(d) + SHA1hex(e); 90 return SHA1Value.toUpperCase(); 91} 92function SHA2(sIn) { 93 return SHA1(sIn).toLowerCase(); ...
sha.js
Source:sha.js
1function add(x, y) {2 return((x & 0x7FFFFFFF) + (y & 0x7FFFFFFF)) ^ (x & 0x80000000) ^ (y & 0x80000000);3}4function SHA1hex(num) {5 var sHEXChars = "0123456789abcdef";6 var str = "";7 for(var j = 7; j >= 0; j--)8 str += sHEXChars.charAt((num >> (j * 4)) & 0x0F);9 return str;10}11function AlignSHA1(sIn) {12 var nblk = ((sIn.length + 8) >> 6) + 1,13 blks = new Array(nblk * 16);14 for(var i = 0; i < nblk * 16; i++) blks[i] = 0;15 for(i = 0; i < sIn.length; i++)16 blks[i >> 2] |= sIn.charCodeAt(i) << (24 - (i & 3) * 8);17 blks[i >> 2] |= 0x80 << (24 - (i & 3) * 8);18 blks[nblk * 16 - 1] = sIn.length * 8;19 return blks;20}21function rol(num, cnt) {22 return(num << cnt) | (num >>> (32 - cnt));23}24function ft(t, b, c, d) {25 if(t < 20) return(b & c) | ((~b) & d);26 if(t < 40) return b ^ c ^ d;27 if(t < 60) return(b & c) | (b & d) | (c & d);28 return b ^ c ^ d;29}30function kt(t) {31 return(t < 20) ? 1518500249 : (t < 40) ? 1859775393 :32 (t < 60) ? -1894007588 : -899497514;33}34function SHA1(sIn) {35 var x = AlignSHA1(sIn);36 var w = new Array(80);37 var a = 1732584193;38 var b = -271733879;39 var c = -1732584194;40 var d = 271733878;41 var e = -1009589776;42 for(var i = 0; i < x.length; i += 16) {43 var olda = a;44 var oldb = b;45 var oldc = c;46 var oldd = d;47 var olde = e;48 for(var j = 0; j < 80; j++) {49 if(j < 16) w[j] = x[i + j];50 else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);51 t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j)));52 e = d;53 d = c;54 c = rol(b, 30);55 b = a;56 a = t;57 }58 a = add(a, olda);59 b = add(b, oldb);60 c = add(c, oldc);61 d = add(d, oldd);62 e = add(e, olde);63 }64 SHA1Value = SHA1hex(a) + SHA1hex(b) + SHA1hex(c) + SHA1hex(d) + SHA1hex(e);65 return SHA1Value.toUpperCase();66}67function SHA2(sIn) {68 return SHA1(sIn).toLowerCase();...
hash.js
Source:hash.js
1//Refrence: https://www.jianshu.com/p/91c2fc568fc92function add(x, y) {3 return((x & 0x7FFFFFFF) + (y & 0x7FFFFFFF)) ^ (x & 0x80000000) ^ (y & 0x80000000);4}5function SHA1hex(num) {6 let sHEXChars = "0123456789abcdef";7 let str = "";8 for(let j = 7; j >= 0; j--)9 str += sHEXChars.charAt((num >> (j * 4)) & 0x0F);10 return str;11}12function AlignSHA1(sIn) {13 let nblk = ((sIn.length + 8) >> 6) + 114 let blks = new Array(nblk * 16);15 let i;16 for(let i = 0; i < nblk * 16; i++) blks[i] = 0;17 for(i = 0; i < sIn.length; i++)18 blks[i >> 2] |= sIn.charCodeAt(i) << (24 - (i & 3) * 8);19 blks[i >> 2] |= 0x80 << (24 - (i & 3) * 8);20 blks[nblk * 16 - 1] = sIn.length * 8;21 return blks;22}23function rol(num, cnt) {24 return(num << cnt) | (num >>> (32 - cnt));25}26function ft(t, b, c, d) {27 if(t < 20) return(b & c) | ((~b) & d);28 if(t < 40) return b ^ c ^ d;29 if(t < 60) return(b & c) | (b & d) | (c & d);30 return b ^ c ^ d;31}32function kt(t) {33 return(t < 20) ? 1518500249 : (t < 40) ? 1859775393 :34 (t < 60) ? -1894007588 : -899497514;35}36function SHA1(sIn) {37 let x = AlignSHA1(sIn);38 let w = new Array(80);39 let a = 1732584193;40 let b = -271733879;41 let c = -1732584194;42 let d = 271733878;43 let e = -1009589776;44 for(let i = 0; i < x.length; i += 16) {45 let olda = a;46 let oldb = b;47 let oldc = c;48 let oldd = d;49 let olde = e;50 for(let j = 0; j < 80; j++) {51 if(j < 16) w[j] = x[i + j];52 else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);53 t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j)));54 e = d;55 d = c;56 c = rol(b, 30);57 b = a;58 a = t;59 }60 a = add(a, olda);61 b = add(b, oldb);62 c = add(c, oldc);63 d = add(d, oldd);64 e = add(e, olde);65 }66 SHA1Value = SHA1hex(a) + SHA1hex(b) + SHA1hex(c) + SHA1hex(d) + SHA1hex(e);67 return SHA1Value;...
shaEncrypt.js
Source:shaEncrypt.js
1function add(x, y) {2 return ((x & 0x7FFFFFFF) + (y & 0x7FFFFFFF)) ^ (x & 0x80000000) ^ (y & 0x80000000);3}4function SHA1hex(num) {5 var sHEXChars = "0123456789abcdef";6 var str = "";7 for (var j = 7; j >= 0; j--)8 str += sHEXChars.charAt((num >> (j * 4)) & 0x0F);9 return str;10}11function AlignSHA1(sIn) {12 var nblk = ((sIn.length + 8) >> 6) + 1,13 blks = new Array(nblk * 16);14 for (var i = 0; i < nblk * 16; i++) blks[i] = 0;15 for (i = 0; i < sIn.length; i++)16 blks[i >> 2] |= sIn.charCodeAt(i) << (24 - (i & 3) * 8);17 blks[i >> 2] |= 0x80 << (24 - (i & 3) * 8);18 blks[nblk * 16 - 1] = sIn.length * 8;19 return blks;20}21function rol(num, cnt) {22 return (num << cnt) | (num >>> (32 - cnt));23}24function ft(t, b, c, d) {25 if (t < 20) return (b & c) | ((~b) & d);26 if (t < 40) return b ^ c ^ d;27 if (t < 60) return (b & c) | (b & d) | (c & d);28 return b ^ c ^ d;29}30function kt(t) {31 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :32 (t < 60) ? -1894007588 : -899497514;33}34function SHA1(sIn) {35 var x = AlignSHA1(sIn);36 var w = new Array(80);37 var a = 1732584193;38 var b = -271733879;39 var c = -1732584194;40 var d = 271733878;41 var e = -1009589776;42 for (var i = 0; i < x.length; i += 16) {43 var olda = a;44 var oldb = b;45 var oldc = c;46 var oldd = d;47 var olde = e;48 var t;49 for (var j = 0; j < 80; j++) {50 if (j < 16) w[j] = x[i + j];51 else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);52 t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j)));53 e = d;54 d = c;55 c = rol(b, 30);56 b = a;57 a = t;58 }59 a = add(a, olda);60 b = add(b, oldb);61 c = add(c, oldc);62 d = add(d, oldd);63 e = add(e, olde);64 }65 var SHA1Value = SHA1hex(a) + SHA1hex(b) + SHA1hex(c) + SHA1hex(d) + SHA1hex(e);66 return SHA1Value.toUpperCase();67}68function SHA2(sIn) {69 return SHA1(sIn).toLowerCase();70}71module.exports = {72 SHA2: SHA2...
sha1Utils.js
Source:sha1Utils.js
1// SHA12function add(x, y) {3 return((x & 0x7FFFFFFF) + (y & 0x7FFFFFFF)) ^ (x & 0x80000000) ^ (y & 0x80000000);4}5function SHA1hex(num) {6 var sHEXChars = "0123456789abcdef";7 var str = "";8 for(var j = 7; j >= 0; j--)9 str += sHEXChars.charAt((num >> (j * 4)) & 0x0F);10 return str;11}12function AlignSHA1(sIn) {13 var nblk = ((sIn.length + 8) >> 6) + 1,14 blks = new Array(nblk * 16);15 for(var i = 0; i < nblk * 16; i++) blks[i] = 0;16 for(i = 0; i < sIn.length; i++)17 blks[i >> 2] |= sIn.charCodeAt(i) << (24 - (i & 3) * 8);18 blks[i >> 2] |= 0x80 << (24 - (i & 3) * 8);19 blks[nblk * 16 - 1] = sIn.length * 8;20 return blks;21}22function rol(num, cnt) {23 return(num << cnt) | (num >>> (32 - cnt));24}25function ft(t, b, c, d) {26 if(t < 20) return(b & c) | ((~b) & d);27 if(t < 40) return b ^ c ^ d;28 if(t < 60) return(b & c) | (b & d) | (c & d);29 return b ^ c ^ d;30}31function kt(t) {32 return(t < 20) ? 1518500249 : (t < 40) ? 1859775393 :33 (t < 60) ? -1894007588 : -899497514;34}35export default function SHA1(sIn) {36 var x = AlignSHA1(sIn);37 var w = new Array(80);38 var a = 1732584193;39 var b = -271733879;40 var c = -1732584194;41 var d = 271733878;42 var e = -1009589776;43 for(var i = 0; i < x.length; i += 16) {44 var olda = a;45 var oldb = b;46 var oldc = c;47 var oldd = d;48 var olde = e;49 for(var j = 0; j < 80; j++) {50 if(j < 16) w[j] = x[i + j];51 else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);52 let t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j)));53 e = d;54 d = c;55 c = rol(b, 30);56 b = a;57 a = t;58 }59 a = add(a, olda);60 b = add(b, oldb);61 c = add(c, oldc);62 d = add(d, oldd);63 e = add(e, olde);64 }65 const SHA1Value = SHA1hex(a) + SHA1hex(b) + SHA1hex(c) + SHA1hex(d) + SHA1hex(e);66 // return SHA1Value.toUpperCase();67 return SHA1Value;...
sha1.js
Source:sha1.js
1/**2 * Created by Administrator on 2016/1/6.3 */4function add(x, y)5{6 return ((x&0x7FFFFFFF) + (y&0x7FFFFFFF)) ^ (x&0x80000000) ^ (y&0x80000000);7}8function SHA1hex(num)9{10 var sHEXChars="0123456789abcdef";11 var str="";12 for(var j=7;j>=0;j--)13 str+=sHEXChars.charAt((num>>(j*4))&0x0F);14 return str;15}16function AlignSHA1(sIn){17 var nblk=((sIn.length+8)>>6)+1, blks=new Array(nblk*16);18 for(var i=0;i<nblk*16;i++)blks[i]=0;19 for(i=0;i<sIn.length;i++)20 blks[i>>2]|=sIn.charCodeAt(i)<<(24-(i&3)*8);21 blks[i>>2]|=0x80<<(24-(i&3)*8);22 blks[nblk*16-1]=sIn.length*8;23 return blks;24}25function rol(num,cnt){26 return(num<<cnt)|(num>>>(32-cnt));27}28function ft(t,b,c,d){29 if(t<20)return(b&c)|((~b)&d);30 if(t<40)return b^c^d;31 if(t<60)return(b&c)|(b&d)|(c&d);32 return b^c^d;33}34function kt(t) {35 return(t<20)?1518500249:(t<40)?1859775393:36 (t<60)?-1894007588:-899497514;37}38function SHA1(sIn)39{40 var x=AlignSHA1(sIn);41 var w=new Array(80);42 var a=1732584193;43 var b=-271733879;44 var c=-1732584194;45 var d=271733878;46 var e=-1009589776;47 for(var i=0;i<x.length;i+=16){48 var olda=a;49 var oldb=b;50 var oldc=c;51 var oldd=d;52 var olde=e;53 for(var j=0;j<80;j++){54 if(j<16)w[j]=x[i+j];55 else w[j]=rol(w[j-3]^w[j-8]^w[j-14]^w[j-16],1);56 t=add(add(rol(a,5),ft(j,b,c,d)),add(add(e,w[j]),kt(j)));57 e=d;58 d=c;59 c=rol(b,30);60 b=a;61 a=t;62 }63 a=add(a,olda);64 b=add(b,oldb);65 c=add(c,oldc);66 d=add(d,oldd);67 e=add(e,olde);68 }69 SHA1Value=SHA1hex(a)+SHA1hex(b)+SHA1hex(c)+SHA1hex(d)+SHA1hex(e);70 return SHA1Value.toUpperCase();...
LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.
|<p>it('check_object_of_Car', () => {</p><p>
expect(newCar()).toBeInstanceOf(Car);</p><p>
});</p>|
| :- |
Get 100 minutes of automation test minutes FREE!!