Best JavaScript code snippet using best
512.js
Source:512.js
...83 // 32 x 32bit words84 for (var i = 0; i < 32; i++)85 W[i] = msg[start + i];86 for (; i < W.length; i += 2) {87 var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 288 var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);89 var c1_hi = W[i - 14]; // i - 790 var c1_lo = W[i - 13];91 var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 1592 var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);93 var c3_hi = W[i - 32]; // i - 1694 var c3_lo = W[i - 31];95 W[i] = sum64_4_hi(96 c0_hi, c0_lo,97 c1_hi, c1_lo,98 c2_hi, c2_lo,99 c3_hi, c3_lo);100 W[i + 1] = sum64_4_lo(101 c0_hi, c0_lo,102 c1_hi, c1_lo,103 c2_hi, c2_lo,104 c3_hi, c3_lo);105 }106};107SHA512.prototype._update = function _update(msg, start) {108 this._prepareBlock(msg, start);109 var W = this.W;110 var ah = this.h[0];111 var al = this.h[1];112 var bh = this.h[2];113 var bl = this.h[3];114 var ch = this.h[4];115 var cl = this.h[5];116 var dh = this.h[6];117 var dl = this.h[7];118 var eh = this.h[8];119 var el = this.h[9];120 var fh = this.h[10];121 var fl = this.h[11];122 var gh = this.h[12];123 var gl = this.h[13];124 var hh = this.h[14];125 var hl = this.h[15];126 assert(this.k.length === W.length);127 for (var i = 0; i < W.length; i += 2) {128 var c0_hi = hh;129 var c0_lo = hl;130 var c1_hi = s1_512_hi(eh, el);131 var c1_lo = s1_512_lo(eh, el);132 var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);133 var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);134 var c3_hi = this.k[i];135 var c3_lo = this.k[i + 1];136 var c4_hi = W[i];137 var c4_lo = W[i + 1];138 var T1_hi = sum64_5_hi(139 c0_hi, c0_lo,140 c1_hi, c1_lo,141 c2_hi, c2_lo,142 c3_hi, c3_lo,143 c4_hi, c4_lo);144 var T1_lo = sum64_5_lo(145 c0_hi, c0_lo,146 c1_hi, c1_lo,147 c2_hi, c2_lo,148 c3_hi, c3_lo,149 c4_hi, c4_lo);150 c0_hi = s0_512_hi(ah, al);151 c0_lo = s0_512_lo(ah, al);152 c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);153 c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);154 var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);155 var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);156 hh = gh;157 hl = gl;158 gh = fh;159 gl = fl;160 fh = eh;161 fl = el;162 eh = sum64_hi(dh, dl, T1_hi, T1_lo);163 el = sum64_lo(dl, dl, T1_hi, T1_lo);164 dh = ch;165 dl = cl;166 ch = bh;167 cl = bl;168 bh = ah;169 bl = al;170 ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);171 al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);172 }173 sum64(this.h, 0, ah, al);174 sum64(this.h, 2, bh, bl);175 sum64(this.h, 4, ch, cl);176 sum64(this.h, 6, dh, dl);177 sum64(this.h, 8, eh, el);178 sum64(this.h, 10, fh, fl);179 sum64(this.h, 12, gh, gl);180 sum64(this.h, 14, hh, hl);181};182SHA512.prototype._digest = function digest(enc) {183 if (enc === 'hex')184 return utils.toHex32(this.h, 'big');185 else186 return utils.split32(this.h, 'big');187};188function ch64_hi(xh, xl, yh, yl, zh) {189 var r = (xh & yh) ^ ((~xh) & zh);190 if (r < 0)191 r += 0x100000000;192 return r;193}194function ch64_lo(xh, xl, yh, yl, zh, zl) {195 var r = (xl & yl) ^ ((~xl) & zl);196 if (r < 0)197 r += 0x100000000;198 return r;199}200function maj64_hi(xh, xl, yh, yl, zh) {201 var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);202 if (r < 0)203 r += 0x100000000;204 return r;205}206function maj64_lo(xh, xl, yh, yl, zh, zl) {207 var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);208 if (r < 0)209 r += 0x100000000;210 return r;211}212function s0_512_hi(xh, xl) {213 var c0_hi = rotr64_hi(xh, xl, 28);214 var c1_hi = rotr64_hi(xl, xh, 2); // 34215 var c2_hi = rotr64_hi(xl, xh, 7); // 39216 var r = c0_hi ^ c1_hi ^ c2_hi;217 if (r < 0)218 r += 0x100000000;219 return r;220}221function s0_512_lo(xh, xl) {222 var c0_lo = rotr64_lo(xh, xl, 28);223 var c1_lo = rotr64_lo(xl, xh, 2); // 34224 var c2_lo = rotr64_lo(xl, xh, 7); // 39225 var r = c0_lo ^ c1_lo ^ c2_lo;226 if (r < 0)227 r += 0x100000000;228 return r;229}230function s1_512_hi(xh, xl) {231 var c0_hi = rotr64_hi(xh, xl, 14);232 var c1_hi = rotr64_hi(xh, xl, 18);233 var c2_hi = rotr64_hi(xl, xh, 9); // 41234 var r = c0_hi ^ c1_hi ^ c2_hi;235 if (r < 0)236 r += 0x100000000;237 return r;238}239function s1_512_lo(xh, xl) {240 var c0_lo = rotr64_lo(xh, xl, 14);241 var c1_lo = rotr64_lo(xh, xl, 18);242 var c2_lo = rotr64_lo(xl, xh, 9); // 41243 var r = c0_lo ^ c1_lo ^ c2_lo;244 if (r < 0)245 r += 0x100000000;246 return r;247}248function g0_512_hi(xh, xl) {249 var c0_hi = rotr64_hi(xh, xl, 1);250 var c1_hi = rotr64_hi(xh, xl, 8);251 var c2_hi = shr64_hi(xh, xl, 7);252 var r = c0_hi ^ c1_hi ^ c2_hi;253 if (r < 0)254 r += 0x100000000;255 return r;256}257function g0_512_lo(xh, xl) {258 var c0_lo = rotr64_lo(xh, xl, 1);259 var c1_lo = rotr64_lo(xh, xl, 8);260 var c2_lo = shr64_lo(xh, xl, 7);261 var r = c0_lo ^ c1_lo ^ c2_lo;262 if (r < 0)263 r += 0x100000000;264 return r;265}266function g1_512_hi(xh, xl) {267 var c0_hi = rotr64_hi(xh, xl, 19);268 var c1_hi = rotr64_hi(xl, xh, 29); // 61269 var c2_hi = shr64_hi(xh, xl, 6);270 var r = c0_hi ^ c1_hi ^ c2_hi;271 if (r < 0)272 r += 0x100000000;273 return r;274}275function g1_512_lo(xh, xl) {276 var c0_lo = rotr64_lo(xh, xl, 19);277 var c1_lo = rotr64_lo(xl, xh, 29); // 61278 var c2_lo = shr64_lo(xh, xl, 6);279 var r = c0_lo ^ c1_lo ^ c2_lo;280 if (r < 0)281 r += 0x100000000;282 return r;283}
bisect.py
Source:bisect.py
1"""Bisection algorithms."""2def insort_right(a, x, lo=0, hi=None):3 """Insert item x in list a, and keep it sorted assuming a is sorted.4 If x is already in a, insert it to the right of the rightmost x.5 Optional args lo (default 0) and hi (default len(a)) bound the6 slice of a to be searched.7 """8 if lo < 0:9 raise ValueError('lo must be non-negative')10 if hi is None:11 hi = len(a)12 while lo < hi:13 mid = (lo+hi)//214 if x < a[mid]: hi = mid15 else: lo = mid+116 a.insert(lo, x)17insort = insort_right # backward compatibility18def bisect_right(a, x, lo=0, hi=None):19 """Return the index where to insert item x in list a, assuming a is sorted.20 The return value i is such that all e in a[:i] have e <= x, and all e in21 a[i:] have e > x. So if x already appears in the list, a.insert(x) will22 insert just after the rightmost x already there.23 Optional args lo (default 0) and hi (default len(a)) bound the24 slice of a to be searched.25 """26 if lo < 0:27 raise ValueError('lo must be non-negative')28 if hi is None:29 hi = len(a)30 while lo < hi:31 mid = (lo+hi)//232 if x < a[mid]: hi = mid33 else: lo = mid+134 return lo35bisect = bisect_right # backward compatibility36def insort_left(a, x, lo=0, hi=None):37 """Insert item x in list a, and keep it sorted assuming a is sorted.38 If x is already in a, insert it to the left of the leftmost x.39 Optional args lo (default 0) and hi (default len(a)) bound the40 slice of a to be searched.41 """42 if lo < 0:43 raise ValueError('lo must be non-negative')44 if hi is None:45 hi = len(a)46 while lo < hi:47 mid = (lo+hi)//248 if a[mid] < x: lo = mid+149 else: hi = mid50 a.insert(lo, x)51def bisect_left(a, x, lo=0, hi=None):52 """Return the index where to insert item x in list a, assuming a is sorted.53 The return value i is such that all e in a[:i] have e < x, and all e in54 a[i:] have e >= x. So if x already appears in the list, a.insert(x) will55 insert just before the leftmost x already there.56 Optional args lo (default 0) and hi (default len(a)) bound the57 slice of a to be searched.58 """59 if lo < 0:60 raise ValueError('lo must be non-negative')61 if hi is None:62 hi = len(a)63 while lo < hi:64 mid = (lo+hi)//265 if a[mid] < x: lo = mid+166 else: hi = mid67 return lo68# Overwrite above definitions with a fast C implementation69try:70 from _bisect import *71except ImportError:...
func2.js
Source:func2.js
1function sayHi() {2 alert("Hi");3 // давайÑе поÑÑиÑаем, ÑколÑко вÑзовов Ð¼Ñ Ñделали4 sayHi.counter++;5}6sayHi.counter = 0; // наÑалÑное знаÑение7sayHi(); // Hi8sayHi(); // Hi9alert( `ÐÑзвана ${sayHi.counter} Ñаза` );10function sayHi() {11 alert("Hi");12}13alert(sayHi.name); // sayHi14let sayHi = function() {15 alert("Hi");16};17alert(sayHi.name); // sayHi (еÑÑÑ Ð¸Ð¼Ñ!)18function f(sayHi = function() {}) {19 alert(sayHi.name); // sayHi (ÑабоÑаеÑ!)20}21f();22let user = {23 sayHi() {24 // ...25 },26 sayBye: function() {27 // ...28 }29}30alert(user.sayHi.name); // sayHi31alert(user.sayBye.name); // sayBye32function f1(a) {}33function f2(a, b) {}34function many(a, b, ...more) {}35alert(f1.length); // 136alert(f2.length); // 237alert(many.length); // 238let sayHi = function func(who) {39 if (who) {40 alert(`Hello, ${who}`);41 } else {42 func("Guest"); // иÑполÑзÑÐµÑ func, ÑÑÐ¾Ð±Ñ Ñнова вÑзваÑÑ ÑÐµÐ±Ñ Ð¶Ðµ43 }44};45sayHi(); // Hello, Guest46// Ð Ð²Ð¾Ñ Ñак - не cÑабоÑаеÑ:47func(); // ÐÑибка, func не опÑеделена48let sum = new Function('a', 'b', 'return a + b');49alert( sum(1, 2) ); // 350let str = ... код, полÑÑеннÑй Ñ ÑеÑвеÑа динамиÑеÑки ...51let func = new Function(str);52func();53function getFunc() {54 let value = "test";55 let func = new Function('alert(value)');56 return func;57}...
remove.js
Source:remove.js
1/*2Description:3Remove n exclamation marks in the sentence from left to right.4n is positive integer.5Examples6remove("Hi!",1) === "Hi"7remove("Hi!",100) === "Hi"8remove("Hi!!!",1) === "Hi!!"9remove("Hi!!!",100) === "Hi"10remove("!Hi",1) === "Hi"11remove("!Hi!",1) === "Hi!"12remove("!Hi!",100) === "Hi"13remove("!!!Hi !!hi!!! !hi",1) === "!!Hi !!hi!!! !hi"14remove("!!!Hi !!hi!!! !hi",3) === "Hi !!hi!!! !hi"15remove("!!!Hi !!hi!!! !hi",5) === "Hi hi!!! !hi"16remove("!!!Hi !!hi!!! !hi",100) === "Hi hi hi"17Note18Please don't post issue about difficulty or duplicate.19*/20function remove(s,n){21 var result = '';22 var count = n;23 for (var i = 0; i < s.length; i++){24 if (s.charAt(i) !== '!' || count <= 0){25 result += s.charAt(i);26 } else {27 count--;28 }29 }30 return result;...
Using AI Code Generation
1var BestHello = require('./BestHello');2var bh = new BestHello();3bh.hi();4var BestHello = require('./BestHello');5var bh = new BestHello();6bh.hi();7var BestHello = function(){8 this.hi = function(){9 console.log('Hi');10 }11}12module.exports = BestHello;13var BestHello = function(){14 this.hi = function(){15 console.log('Hi');16 }17}18BestHello.getInstance = function(){19 if(!this.instance){20 this.instance = new BestHello();21 }22 return this.instance;23}24module.exports = BestHello;25var BestHello = function(){26 this.hi = function(){27 console.log('Hi');28 }29}30BestHello.getInstance = function(){31 if(!
Using AI Code Generation
1var Best = require('./test1');2var b = new Best();3b.hi();4var Best = require('./test1');5var b = new Best();6b.hi();7var Best = require('./test1');8var b = new Best();9b.hi();10var Best = require('./test1');11var b = new Best();12b.hi();13var Best = require('./test1');14var b = new Best();15b.hi();16var Best = require('./test1');17var b = new Best();18b.hi();19var Best = require('./test1');20var b = new Best();21b.hi();22var Best = require('./test1');23var b = new Best();24b.hi();25var Best = require('./test1');26var b = new Best();27b.hi();28var Best = require('./test1');29var b = new Best();30b.hi();31var Best = require('./test1');32var b = new Best();33b.hi();34var Best = require('./test1');35var b = new Best();36b.hi();37var Best = require('./test1');38var b = new Best();39b.hi();40var Best = require('./test1');41var b = new Best();42b.hi();43var Best = require('./test1');44var b = new Best();45b.hi();
Using AI Code Generation
1var BestClass = require('./BestClass.js');2var bc = new BestClass();3bc.hi();4var BestClass = require('./BestClass.js');5var bc = new BestClass();6bc.hi();
Using AI Code Generation
1var best = require('./best.js');2best.hi();3var best = require('./best.js');4best.hi();5var best = require('./best.js');6best.hi();7var best = require('./best.js');8best.hi();9var best = require('./best.js');10best.hi();11var best = require('./best.js');12best.hi();13var best = require('./best.js');14best.hi();15var best = require('./best.js');16best.hi();17var best = require('./best.js');18best.hi();19var best = require('./best.js');20best.hi();21var best = require('./best.js');22best.hi();23var best = require('./best.js');24best.hi();25var best = require('./best.js');26best.hi();27var best = require('./best.js');28best.hi();29var best = require('./best.js');30best.hi();31var best = require('./best.js');32best.hi();33var best = require('./best.js');34best.hi();
Using AI Code Generation
1var Best = require('./best');2var b = new Best();3b.hi();4var Best = function() {5};6Best.prototype.hi = function() {7 console.log('Hi');8};9module.exports = Best;10var Best = require('./best');11var b = new Best();12b.hi();13var Best = function() {14};15Best.prototype.hi = function() {16 console.log('Hi');17};18module.exports = Best;19var Best = require('./best');20var b = new Best();21b.hi();22var Best = function() {23};24Best.prototype.hi = function() {25 console.log('Hi');26};27module.exports = Best;28var Best = require('./best');29var b = new Best();30b.hi();31var Best = function() {32};33Best.prototype.hi = function() {34 console.log('Hi');35};36module.exports = Best;37var Best = require('./best');38var b = new Best();39b.hi();40var Best = function() {41};42Best.prototype.hi = function() {43 console.log('Hi');44};45module.exports = Best;46var Best = require('./best');47var b = new Best();48b.hi();49var Best = function() {50};51Best.prototype.hi = function() {52 console.log('Hi');53};54module.exports = Best;55var Best = require('./best');56var b = new Best();57b.hi();58var Best = function() {59};60Best.prototype.hi = function() {61 console.log('Hi');62};63module.exports = Best;
Using AI Code Generation
1var BestClass = require('./BestClass');2var bestClass = new BestClass();3bestClass.hi();4var BestClass = function() {5};6BestClass.prototype.hi = function() {7 console.log('hi');8};9module.exports = BestClass;10The module.exports object is used to export the functionality of a module. It is also used to import the functionality of a module. The module.exports object is a special object which is included in every JS file in the Node.js application by default
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!!