Best JavaScript code snippet using mountebank
nobushi.js
Source:nobushi.js
...72 _curry._curried = true;73 return _curry;74 })(f._length != null ? f._length : f.length);75 };76 nbs['&&'] = curry(function(x, y) {77 return x && y;78 });79 nbs['||'] = curry(function(x, y) {80 return x || y;81 });82 nbs['!'] = nbs.not = curry(function(x) {83 return !x;84 });85 nbs['=='] = nbs['==='] = curry(function(x, y) {86 return x === y;87 });88 nbs['/='] = nbs['!='] = nbs['!=='] = curry(function(x, y) {89 return x !== y;90 });91 nbs['<'] = curry(function(x, y) {92 return x < y;93 });94 nbs['>='] = curry(function(x, y) {95 return x >= y;96 });97 nbs['>'] = curry(function(x, y) {98 return x > y;99 });100 nbs['<='] = curry(function(x, y) {101 return x <= y;102 });103 nbs.max = curry(function(x, y) {104 if (x < y) {105 return y;106 } else {107 return x;108 }109 });110 nbs.min = curry(function(x, y) {111 if (x < y) {112 return x;113 } else {114 return y;115 }116 });117 nbs.succ = function(x) {118 return x + 1;119 };120 nbs.pred = function(x) {121 return x - 1;122 };123 nbs.enumFromTo = curry(function(n, m) {124 var _i, _results;125 return (function() {126 _results = [];127 for (var _i = n; n <= m ? _i <= m : _i >= m; n <= m ? _i++ : _i--){ _results.push(_i); }128 return _results;129 }).apply(this);130 });131 nbs.enumFromThenTo = curry(function(n0, n1, m) {132 var x, _i, _ref, _results;133 _results = [];134 for (x = _i = n0, _ref = n1 - n0; _ref > 0 ? _i <= m : _i >= m; x = _i += _ref) {135 _results.push(x);136 }137 return _results;138 });139 nbs['+'] = curry(function(x, y) {140 return x + y;141 });142 nbs['-'] = curry(function(x, y) {143 return x - y;144 });145 nbs['*'] = curry(function(x, y) {146 return x * y;147 });148 nbs.negate = curry(function(x) {149 return -x;150 });151 nbs.abs = curry(function(x) {152 if (x < 0) {153 return -x;154 } else {155 return x;156 }157 });158 nbs.signum = curry(function(x) {159 switch (false) {160 case !(x < 0):161 return -1;162 case !(0 < x):163 return 1;164 default:165 return 0;166 }167 });168 nbs.quot = curry(function(x, y) {169 return (nbs.quotRem(x, y))[0];170 });171 nbs.rem = curry(function(x, y) {172 return (nbs.quotRem(x, y))[1];173 });174 nbs.div = curry(function(x, y) {175 return (nbs.divMod(x, y))[0];176 });177 nbs.mod = nbs['%'] = curry(function(x, y) {178 return (nbs.divMod(x, y))[1];179 });180 nbs.quotRem = curry(function(x, y) {181 return (function(quot) {182 return [quot, x - quot * y];183 })(nbs.truncate(x / y));184 });185 nbs.divMod = curry(function(x, y) {186 return (function(div) {187 return [div, x - div * y];188 })(nbs.floor(x / y));189 });190 nbs['/'] = curry(function(x, y) {191 return x / y;192 });193 nbs.recip = nbs(1)['/'];194 nbs.truncate = curry(function(x) {195 return parseInt(x, 10);196 });197 nbs.round = curry(Math.round);198 nbs.ceiling = curry(Math.ceil);199 nbs.floor = curry(Math.floor);200 nbs.even = curry(function(x) {201 return x % 2 === 0;202 });203 nbs.odd = curry(function(x) {204 return x % 2 === 1;205 });206 nbs.gcd = curry(function(x, y) {207 var _gcd;208 _gcd = function(a, b) {209 if (b === 0) {210 return a;211 } else {212 return _gcd(b, nbs(a).rem(b));213 }214 };215 return _gcd(nbs.abs(x), nbs.abs(y));216 });217 nbs.lcm = curry(function(x, y) {218 if (x === 0 || y === 0) {219 return 0;220 } else {221 return nbs.abs(nbs(x).quot(nbs.gcd(x, y)) * y);222 }223 });224 nbs['^'] = curry(function(x0, y0) {225 var f, g;226 f = function(x, y) {227 switch (false) {228 case !nbs.even(y):229 return f(x * x, nbs(y).quot(2));230 case y !== 1:231 return x;232 default:233 return g(x * x, nbs(y - 1).quot(2), x);234 }235 };236 g = function(x, y, z) {237 switch (false) {238 case !nbs.even(y):239 return g(x * x, nbs(y).quot(2), z);240 case y !== 1:241 return x * z;242 default:243 return g(x * x, nbs(y - 1).quot(2), x * z);244 }245 };246 switch (false) {247 case !(y0 < 0):248 return nbs.error('Negative exponent');249 case y0 !== 0:250 return 1;251 default:252 return f(x0, y0);253 }254 });255 nbs['^^'] = curry(function(x, n) {256 if (0 <= n) {257 return nbs(x)['^'](n);258 } else {259 return nbs.recip(nbs(x)['^'](-n));260 }261 });262 nbs.id = curry(function(x) {263 return x;264 });265 nbs.$const = nbs.$const = curry(function(x) {266 return function() {267 return x;268 };269 });270 nbs.flip = curry(function(f) {271 return curry((function(x, y) {272 return f(y, x);273 }));274 });275 nbs.until = curry(function(p, f, x) {276 while (!p(x)) {277 x = f(x);278 }279 return x;280 });281 nbs.error = curry(function(message) {282 throw new Error(message);283 });284 nbs.map = curry(function(f, xs) {285 var x, _i, _len, _results;286 _results = [];287 for (_i = 0, _len = xs.length; _i < _len; _i++) {288 x = xs[_i];289 _results.push(f(x));290 }291 return _results;292 });293 nbs['++'] = curry(function(xs, ys) {294 return xs.concat(ys);295 });296 nbs.filter = curry(function(p, xs) {297 var x, _i, _len, _results;298 _results = [];299 for (_i = 0, _len = xs.length; _i < _len; _i++) {300 x = xs[_i];301 if (p(x)) {302 _results.push(x);303 }304 }305 return _results;306 });307 nbs.head = curry(function(xs) {308 if (nbs.$null(xs)) {309 nbs.error('nbs.head: empty list');310 }311 return xs[0];312 });313 nbs.last = curry(function(xs) {314 if (nbs.$null(xs)) {315 nbs.error('nbs.last: empty list');316 }317 return xs[xs.length - 1];318 });319 nbs.tail = curry(function(xs) {320 if (nbs.$null(xs)) {321 nbs.error('nbs.tail: empty list');322 }323 return xs.slice(1);324 });325 nbs.init = curry(function(xs) {326 if (nbs.$null(xs)) {327 nbs.error('nbs.init: empty list');328 }329 return xs.slice(0, -1);330 });331 nbs.$null = curry(function(xs) {332 return xs.length <= 0;333 });334 nbs.$length = curry(function(xs) {335 return xs.length;336 });337 nbs['!!'] = curry(function(xs, n) {338 switch (false) {339 case !(n < 0):340 return nbs.error('nbs.!!: negative index');341 case !(xs.length <= n):342 return nbs.error('nbs.!!: index too large');343 default:344 return xs[n];345 }346 });347 nbs.reverse = curry(function(xs) {348 if (typeof xs === 'string') {349 return xs.split('').reverse().join('');350 } else {351 return xs.reverse();352 }353 });354 nbs.foldl = curry(function(f, z, xs) {355 var x, _i, _len;356 for (_i = 0, _len = xs.length; _i < _len; _i++) {357 x = xs[_i];358 z = f(z, x);359 }360 return z;361 });362 nbs.foldl1 = curry(function(f, xs) {363 if (nbs.$null(xs)) {364 nbs.error('nbs.foldl1: empty list');365 }366 return nbs.foldl(f, nbs.head(xs), nbs.tail(xs));367 });368 nbs.foldr = curry(function(f, z, xs) {369 var x, _i, _len, _ref;370 _ref = xs.reverse();371 for (_i = 0, _len = _ref.length; _i < _len; _i++) {372 x = _ref[_i];373 z = f(x, z);374 }375 return z;376 });377 nbs.foldr1 = curry(function(f, xs) {378 if (nbs.$null(xs)) {379 nbs.error('nbs.foldr1: empty list');380 }381 return nbs.foldr(f, nbs.last(xs), nbs.init(xs));382 });383 nbs.and = curry(function(xs) {384 return nbs.all(nbs.id, xs);385 });386 nbs.or = curry(function(xs) {387 return nbs.any(nbs.id, xs);388 });389 nbs.any = curry(function(p, xs) {390 var x, _i, _len;391 for (_i = 0, _len = xs.length; _i < _len; _i++) {392 x = xs[_i];393 if (p(x)) {394 return true;395 }396 }397 return false;398 });399 nbs.all = curry(function(p, xs) {400 var x, _i, _len;401 for (_i = 0, _len = xs.length; _i < _len; _i++) {402 x = xs[_i];403 if (!p(x)) {404 return false;405 }406 }407 return true;408 });409 nbs.sum = curry(function(xs) {410 return nbs.foldl(nbs['+'], 0, xs);411 });412 nbs.product = curry(function(xs) {413 return nbs.foldl(nbs['*'], 1, xs);414 });415 nbs.concat = curry(function(xs) {416 var x;417 x = nbs.head(xs);418 return x.concat.apply(x, nbs.tail(xs));419 });420 nbs.concatMap = curry(function(f, xs) {421 return nbs.concat(nbs.map(f, xs));422 });423 nbs.maximum = curry(function(xs) {424 if (nbs.$null(xs)) {425 nbs.error('nbs.maximum: empty list');426 }427 return nbs.foldl1(nbs.max, xs);428 });429 nbs.minimum = curry(function(xs) {430 if (nbs.$null(xs)) {431 nbs.error('nbs.minimum: empty list');432 }433 return nbs.foldl1(nbs.min, xs);434 });435 nbs.scanl = curry(function(f, z, xs) {436 var x, ys, _i, _len;437 ys = [z];438 for (_i = 0, _len = xs.length; _i < _len; _i++) {439 x = xs[_i];440 ys.push(z = f(z, x));441 }442 return ys;443 });444 nbs.scanl1 = curry(function(f, xs) {445 if (nbs.$null(xs)) {446 nbs.error('nbs.scanl1: empty list');447 }448 return nbs.scanl(f, nbs.head(xs), nbs.tail(xs));449 });450 nbs.scanr = curry(function(f, z, xs) {451 var x, ys, _i, _len, _ref;452 ys = [z];453 _ref = xs.reverse();454 for (_i = 0, _len = _ref.length; _i < _len; _i++) {455 x = _ref[_i];456 ys.unshift(z = f(x, z));457 }458 return ys;459 });460 nbs.scanr1 = curry(function(f, xs) {461 if (nbs.$null(xs)) {462 nbs.error('nbs.scanr1: empty list');463 }464 return nbs.scanr(f, nbs.last(xs), nbs.init(xs));465 });466 nbs.replicate = curry(function(n, x) {467 var _results;468 if (typeof x === 'string' && x.length === 1) {469 return ((function() {470 var _results;471 _results = [];472 while (0 < n--) {473 _results.push(x);474 }475 return _results;476 })()).join('');477 } else {478 _results = [];479 while (0 < n--) {480 _results.push(x);481 }482 return _results;483 }484 });485 nbs.take = curry(function(n, xs) {486 return xs.slice(0, nbs.max(0, n));487 });488 nbs.drop = curry(function(n, xs) {489 return xs.slice(nbs.max(0, n));490 });491 nbs.splitAt = curry(function(n, xs) {492 return [nbs.take(n, xs), nbs.drop(n, xs)];493 });494 nbs.takeWhile = curry(function(p, xs) {495 var x, ys, _i, _len;496 ys = [];497 for (_i = 0, _len = xs.length; _i < _len; _i++) {498 x = xs[_i];499 if (!p(x)) {500 break;501 }502 ys.push(x);503 }504 return ys;505 });506 nbs.dropWhile = curry(function(p, xs) {507 while (!nbs.$null(xs)) {508 if (!p(nbs.head(xs))) {509 break;510 }511 xs = nbs.tail(xs);512 }513 return xs;514 });515 nbs.span = curry(function(p, xs) {516 var ys, z, zs;517 ys = [];518 zs = xs;519 while (!nbs.$null(zs)) {520 z = nbs.head(zs);521 if (!p(z)) {522 break;523 }524 ys.push(z);525 zs = nbs.tail(zs);526 }527 return [ys, zs];528 });529 nbs.$break = curry(function(p, xs) {530 return nbs.span((function(x) {531 return !p(x);532 }), xs);533 });534 nbs.elem = curry(function(x, xs) {535 var i, _i, _len;536 for (_i = 0, _len = xs.length; _i < _len; _i++) {537 i = xs[_i];538 if (x === i) {539 return true;540 }541 }542 return false;543 });544 nbs.notElem = curry(function(x, xs) {545 return !nbs(x).elem(xs);546 });547 nbs.zip = function(xs, ys) {548 return nbs.zipWith((function(x, y) {549 return [x, y];550 }), xs, ys);551 };552 nbs.zip3 = function(xs, ys, zs) {553 return nbs.zipWith3((function(x, y, z) {554 return [x, y, z];555 }), xs, ys, zs);556 };557 nbs.zipWith = curry(function(f, xs, ys) {558 var i, length, _i, _results;559 length = nbs.min(xs.length, ys.length);560 _results = [];561 for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {562 _results.push(f(xs[i], ys[i]));563 }564 return _results;565 });566 nbs.zipWith3 = curry(function(f, xs, ys, zs) {567 var i, length, _i, _results;568 length = nbs.minimum(nbs.map(nbs.$length, [xs, ys, zs]));569 _results = [];570 for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {571 _results.push(f(xs[i], ys[i], zs[i]));572 }573 return _results;574 });575 nbs.unzip = curry(function(ts) {576 var t, xs, ys, _i, _len;577 xs = [];578 ys = [];579 for (_i = 0, _len = ts.length; _i < _len; _i++) {580 t = ts[_i];581 xs.push(t[0]);582 ys.push(t[1]);583 }584 return [xs, ys];585 });586 nbs.unzip3 = curry(function(ts) {587 var t, xs, ys, zs, _i, _len;588 xs = [];589 ys = [];590 zs = [];591 for (_i = 0, _len = ts.length; _i < _len; _i++) {592 t = ts[_i];593 xs.push(t[0]);594 ys.push(t[1]);595 zs.push(t[2]);596 }597 return [xs, ys, zs];598 });599 nbs.lines = curry(function(s) {600 return s.replace(/(\r\n|\r)/g, '\n').split('\n');601 });602 nbs.words = curry(function(s) {603 return s.replace(/\s+/g, ' ').split(' ');604 });605 nbs.unlines = curry(function(xs) {606 return xs.join('\n');607 });608 nbs.unwords = curry(function(xs) {609 return xs.join(' ');610 });611 if (typeof define === 'function' && define.amd) {612 define([], function() {613 return nbs;614 });615 } else if (typeof module === 'object') {616 module.exports = nbs;617 } else {618 root.nbs = nbs;619 }...
array.js
Source:array.js
...174 })175 }, {})176}177module.exports = {178 append: curry(2, append),179 concat,180 concatMap: curry(2, concatMap),181 countBy: curry(2, countBy),182 drop: curry(2, drop),183 dropWhile: curry(2, dropWhile),184 every: curry(2, every),185 filter: curry(2, filter),186 find: curry(2, find),187 findIndex: curry(2, findIndex),188 get: curry(2, get),189 gets: curry(2, gets),190 groupBy: curry(2, groupBy),191 head,192 includes: curry(2, includes),193 indexOf: curry(2, indexOf),194 init,195 isEmpty,196 last,197 length,198 map: curry(2, map),199 max,200 maxBy: curry(2, maxBy),201 min,202 minBy: curry(2, minBy),203 partition: curry(2, partition),204 prepend: curry(2, prepend),205 range: curry(2, range),206 reduce: curry(3, reduce),207 reject: curry(2, reject),208 reverse,209 scan: curry(3, scan),210 slice: curry(3, slice),211 some: curry(2, some),212 sort: curry(2, sort),213 sortBy: curry(2, sortBy),214 sortWith: curry(2, sortWith),215 span: curry(2, span),216 tail,217 take: curry(2, take),218 takeWhile: curry(2, takeWhile),219 unique,220 uniqueBy: curry(2, uniqueBy),221 zip: curry(2, zip)...
index.js
Source:index.js
...137function subtract (a, b) {138 return b - a139}140module.exports = {141 add: curry(2, add),142 always: curry(2, always),143 and: curry(2, and),144 ap: curry(2, ap),145 apply: curry(2, apply),146 ascend: curry(2, ascend),147 ascendBy: curry(3, ascendBy),148 between: curry(3, between),149 both: curry(3, both),150 branch: curry(4, branch),151 clamp: curry(3, clamp),152 complement: curry(2, complement),153 compose: curry(3, compose),154 curry,155 dec,156 descend: curry(2, descend),157 descendBy: curry(3, descendBy),158 divide: curry(2, divide),159 either: curry(3, either),160 equal: curry(2, equal),161 equalBy: curry(3, equalBy),162 flip: curry(3, flip),163 gt: curry(2, gt),164 gte: curry(2, gte),165 id,166 inc,167 isEven,168 isOdd,169 lt: curry(2, lt),170 lte: curry(2, lte),171 match: curry(2, match),172 max: curry(2, max),173 min: curry(2, min),174 mod: curry(2, mod),175 multiply: curry(2, multiply),176 negate,177 not,178 on: curry(4, on),179 or: curry(2, or),180 pipe: curry(2, pipe),181 pow: curry(2, pow),182 rem: curry(2, rem),183 subtract: curry(2, subtract),184 unless: curry(3, unless),185 when: curry(3, when)...
Using AI Code Generation
1var mb = require('mountebank');2var imposter = { port: 3000, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] };3mb.create(imposter).then(function () {4 console.log('Imposter created');5});6var mb = require('mountebank');7mb.create({ port: 3000, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] })8 .then(function () {9 console.log('Imposter created');10 });11var mb = require('mountebank');12mb.create({ port: 3000, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] }, function (error) {13 if (error) {14 console.error('Error creating imposter', error);15 }16 else {17 console.log('Imposter created');18 }19});20var mb = require('mountebank');21mb.create([22 { port: 3000, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] },23 { port: 3001, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] }24]).then(function () {25 console.log('Imposters created');26});27var mb = require('mountebank');28mb.create([29 { port: 3000, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] },30 { port: 3001, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello, World!' } }] }] }31], function (error) {32 if (error) {33 console.error('Error creating imposters', error);34 }35 else {36 console.log('Imposters created');37 }38});39var mb = require('mountebank');40mb.create([41 {
Using AI Code Generation
1var mb = require('mountebank');2var fs = require('fs');3var path = require('path');4var imposter = {5 {6 {7 equals: {8 }9 }10 {11 is: {12 headers: {13 },14 body: fs.readFileSync(path.resolve(__dirname, 'response.json'), 'utf-8')15 }16 }17 }18};19mb.create(imposter, function (error, imposter) {20 if (error) {21 console.log(error);22 }23 else {24 console.log(imposter);25 }26});27{28 "data": {29 }30}31var mb = require('mountebank');32var fs = require('fs');33var path = require('path');34var imposter = {35 {36 {37 equals: {38 }39 }40 {41 is: {42 headers: {43 },44 body: fs.readFileSync(path.resolve(__dirname, 'response.json'), 'utf-8')45 }46 }47 }48};49mb.create(imposter, function (error, imposter) {50 if (error) {51 console.log(error);52 }53 else {54 console.log(imposter);55 }56});57{58 "data": {59 }60}
Using AI Code Generation
1const imposter = require('mountebank').create();2const port = 2525;3const stub = {4 {5 equals: {6 }7 }8 {9 is: {10 }11 }12};13 .then(function (imposter) {14 return imposter.addStub(stub);15 })16 .then(function (imposter) {17 return imposter.toJSON();18 })19 .then(function (json) {20 console.log('JSON', json);21 })22 .catch(function (error) {23 console.error(error);24 });25const mb = require('mountebank');26const port = 2525;27const stub = {28 {29 equals: {30 }31 }32 {33 is: {34 }35 }36};37mb.create(port)38 .then(function (imposter) {39 return imposter.addStub(stub);40 })41 .then(function (imposter) {42 return imposter.toJSON();43 })44 .then(function (json) {45 console.log('JSON', json);46 })47 .catch(function (error) {48 console.error(error);49 });50{51 "scripts": {52 },53 "dependencies": {54 }55}56{57 "dependencies": {
Using AI Code Generation
1var mb = require('mountebank');2mb.create(2525, function (error, imposter) {3 imposter.addStub({4 {5 is: {6 }7 }8 }, function (error, stub) {9 console.log("Stub created");10 });11});12mb.create(2526, function (error, imposter) {13 imposter.addStub({14 {15 is: {16 }17 }18 }, function (error, stub) {19 console.log("Stub created");20 });21});22mb.create(2527, function (error, imposter) {23 imposter.addStub({24 {25 is: {26 }27 }28 }, function (error, stub) {29 console.log("Stub created");30 });31});32mb.create(2528, function (error, imposter) {33 imposter.addStub({34 {35 is: {36 }37 }38 }, function (error, stub) {39 console.log("Stub created");40 });41});42mb.create(2529, function (error, imposter) {43 imposter.addStub({44 {45 is: {46 }47 }48 }, function (error, stub) {49 console.log("Stub created");50 });51});52mb.create(2530, function (error, imposter) {53 imposter.addStub({54 {55 is: {56 }57 }58 }, function (error, stub) {59 console.log("Stub created");
Using AI Code Generation
1const mb = require('mountebank');2mb.create({3}, function (error, server) {4 server.post('/test', {5 {6 {7 equals: {8 }9 }10 {11 is: {12 }13 }14 }15 });16});17mb.create({18}, function (error, server) {19 server.post('/test', {20 {21 {22 equals: {23 }24 }25 {26 is: {27 }28 }29 }30 });31});32mb.create({33}, function (error, server) {34 server.post('/test', {35 {36 {37 equals: {38 }39 }40 {41 is: {42 }43 }44 }45 });46});47mb.create({
Using AI Code Generation
1var mb = require('mountebank');2mb.create({port:2525}, function(error, mbServer) {3 if (error) {4 console.log("error: ", error);5 } else {6 console.log("mbServer: ", mbServer);7 }8});9var impostor = mbServer.createImposter({protocol: 'http', port: 3000}, function(error, impostor) {10 if (error) {11 console.log("error: ", error);12 } else {13 console.log("impostor: ", impostor);14 }15});16var stub = impostor.addStub({17 predicates: [{equals: {path: '/test'}}],18 responses: [{is: {body: 'TEST'}}]19}, function(error, stub) {20 if (error) {21 console.log("error: ", error);22 } else {23 console.log("stub: ", stub);24 }25});26var request = require('request');27 if (error) {28 console.log("error: ", error);29 } else {30 console.log("body: ", body);31 }32});33stub.delete(function(error) {34 if (error) {35 console.log("error: ", error);36 } else {37 console.log("stub deleted");38 }39});40impostor.delete(function(error) {41 if (error) {42 console.log("error: ", error);43 } else {44 console.log("impostor deleted");45 }46});47mbServer.delete(function(error) {48 if (error) {49 console.log("error: ", error);50 } else {51 console.log("mountebank instance deleted");52 }53});
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!!