Best JavaScript code snippet using pact-foundation-pact
integer.js
Source:integer.js
1// Copyright 2009 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview Defines an Integer class for representing (potentially)16 * infinite length two's-complement integer values.17 *18 * For the specific case of 64-bit integers, use goog.math.Long, which is more19 * efficient.20 *21 */22goog.provide('goog.math.Integer');23/**24 * Constructs a two's-complement integer an array containing bits of the25 * integer in 32-bit (signed) pieces, given in little-endian order (i.e.,26 * lowest-order bits in the first piece), and the sign of -1 or 0.27 *28 * See the from* functions below for other convenient ways of constructing29 * Integers.30 *31 * The internal representation of an integer is an array of 32-bit signed32 * pieces, along with a sign (0 or -1) that indicates the contents of all the33 * other 32-bit pieces out to infinity. We use 32-bit pieces because these are34 * the size of integers on which Javascript performs bit-operations. For35 * operations like addition and multiplication, we split each number into 16-bit36 * pieces, which can easily be multiplied within Javascript's floating-point37 * representation without overflow or change in sign.38 *39 * @constructor40 * @param {Array.<number>} bits Array containing the bits of the number.41 * @param {number} sign The sign of the number: -1 for negative and 0 positive.42 */43goog.math.Integer = function(bits, sign) {44 /**45 * @type {!Array.<number>}46 * @private47 */48 this.bits_ = [];49 /**50 * @type {number}51 * @private52 */53 this.sign_ = sign;54 // Copy the 32-bit signed integer values passed in. We prune out those at the55 // top that equal the sign since they are redundant.56 var top = true;57 for (var i = bits.length - 1; i >= 0; i--) {58 var val = bits[i] | 0;59 if (!top || val != sign) {60 this.bits_[i] = val;61 top = false;62 }63 }64};65// NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the66// from* methods on which they depend.67/**68 * A cache of the Integer representations of small integer values.69 * @type {!Object}70 * @private71 */72goog.math.Integer.IntCache_ = {};73/**74 * Returns an Integer representing the given (32-bit) integer value.75 * @param {number} value A 32-bit integer value.76 * @return {!goog.math.Integer} The corresponding Integer value.77 */78goog.math.Integer.fromInt = function(value) {79 if (-128 <= value && value < 128) {80 var cachedObj = goog.math.Integer.IntCache_[value];81 if (cachedObj) {82 return cachedObj;83 }84 }85 var obj = new goog.math.Integer([value | 0], value < 0 ? -1 : 0);86 if (-128 <= value && value < 128) {87 goog.math.Integer.IntCache_[value] = obj;88 }89 return obj;90};91/**92 * Returns an Integer representing the given value, provided that it is a finite93 * number. Otherwise, zero is returned.94 * @param {number} value The value in question.95 * @return {!goog.math.Integer} The corresponding Integer value.96 */97goog.math.Integer.fromNumber = function(value) {98 if (isNaN(value) || !isFinite(value)) {99 return goog.math.Integer.ZERO;100 } else if (value < 0) {101 return goog.math.Integer.fromNumber(-value).negate();102 } else {103 var bits = [];104 var pow = 1;105 for (var i = 0; value >= pow; i++) {106 bits[i] = (value / pow) | 0;107 pow *= goog.math.Integer.TWO_PWR_32_DBL_;108 }109 return new goog.math.Integer(bits, 0);110 }111};112/**113 * Returns a Integer representing the value that comes by concatenating the114 * given entries, each is assumed to be 32 signed bits, given in little-endian115 * order (lowest order bits in the lowest index), and sign-extending the highest116 * order 32-bit value.117 * @param {Array.<number>} bits The bits of the number, in 32-bit signed pieces,118 * in little-endian order.119 * @return {!goog.math.Integer} The corresponding Integer value.120 */121goog.math.Integer.fromBits = function(bits) {122 var high = bits[bits.length - 1];123 return new goog.math.Integer(bits, high & (1 << 31) ? -1 : 0);124};125/**126 * Returns an Integer representation of the given string, written using the127 * given radix.128 * @param {string} str The textual representation of the Integer.129 * @param {number=} opt_radix The radix in which the text is written.130 * @return {!goog.math.Integer} The corresponding Integer value.131 */132goog.math.Integer.fromString = function(str, opt_radix) {133 if (str.length == 0) {134 throw Error('number format error: empty string');135 }136 var radix = opt_radix || 10;137 if (radix < 2 || 36 < radix) {138 throw Error('radix out of range: ' + radix);139 }140 if (str.charAt(0) == '-') {141 return goog.math.Integer.fromString(str.substring(1), radix).negate();142 } else if (str.indexOf('-') >= 0) {143 throw Error('number format error: interior "-" character');144 }145 // Do several (8) digits each time through the loop, so as to146 // minimize the calls to the very expensive emulated div.147 var radixToPower = goog.math.Integer.fromNumber(Math.pow(radix, 8));148 var result = goog.math.Integer.ZERO;149 for (var i = 0; i < str.length; i += 8) {150 var size = Math.min(8, str.length - i);151 var value = parseInt(str.substring(i, i + size), radix);152 if (size < 8) {153 var power = goog.math.Integer.fromNumber(Math.pow(radix, size));154 result = result.multiply(power).add(goog.math.Integer.fromNumber(value));155 } else {156 result = result.multiply(radixToPower);157 result = result.add(goog.math.Integer.fromNumber(value));158 }159 }160 return result;161};162/**163 * A number used repeatedly in calculations. This must appear before the first164 * call to the from* functions below.165 * @type {number}166 * @private167 */168goog.math.Integer.TWO_PWR_32_DBL_ = (1 << 16) * (1 << 16);169/** @type {!goog.math.Integer} */170goog.math.Integer.ZERO = goog.math.Integer.fromInt(0);171/** @type {!goog.math.Integer} */172goog.math.Integer.ONE = goog.math.Integer.fromInt(1);173/**174 * @type {!goog.math.Integer}175 * @private176 */177goog.math.Integer.TWO_PWR_24_ = goog.math.Integer.fromInt(1 << 24);178/**179 * Returns the value, assuming it is a 32-bit integer.180 * @return {number} The corresponding int value.181 */182goog.math.Integer.prototype.toInt = function() {183 return this.bits_.length > 0 ? this.bits_[0] : this.sign_;184};185/** @return {number} The closest floating-point representation to this value. */186goog.math.Integer.prototype.toNumber = function() {187 if (this.isNegative()) {188 return -this.negate().toNumber();189 } else {190 var val = 0;191 var pow = 1;192 for (var i = 0; i < this.bits_.length; i++) {193 val += this.getBitsUnsigned(i) * pow;194 pow *= goog.math.Integer.TWO_PWR_32_DBL_;195 }196 return val;197 }198};199/**200 * @param {number=} opt_radix The radix in which the text should be written.201 * @return {string} The textual representation of this value.202 * @override203 */204goog.math.Integer.prototype.toString = function(opt_radix) {205 var radix = opt_radix || 10;206 if (radix < 2 || 36 < radix) {207 throw Error('radix out of range: ' + radix);208 }209 if (this.isZero()) {210 return '0';211 } else if (this.isNegative()) {212 return '-' + this.negate().toString(radix);213 }214 // Do several (6) digits each time through the loop, so as to215 // minimize the calls to the very expensive emulated div.216 var radixToPower = goog.math.Integer.fromNumber(Math.pow(radix, 6));217 var rem = this;218 var result = '';219 while (true) {220 var remDiv = rem.divide(radixToPower);221 var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();222 var digits = intval.toString(radix);223 rem = remDiv;224 if (rem.isZero()) {225 return digits + result;226 } else {227 while (digits.length < 6) {228 digits = '0' + digits;229 }230 result = '' + digits + result;231 }232 }233};234/**235 * Returns the index-th 32-bit (signed) piece of the Integer according to236 * little-endian order (i.e., index 0 contains the smallest bits).237 * @param {number} index The index in question.238 * @return {number} The requested 32-bits as a signed number.239 */240goog.math.Integer.prototype.getBits = function(index) {241 if (index < 0) {242 return 0; // Allowing this simplifies bit shifting operations below...243 } else if (index < this.bits_.length) {244 return this.bits_[index];245 } else {246 return this.sign_;247 }248};249/**250 * Returns the index-th 32-bit piece as an unsigned number.251 * @param {number} index The index in question.252 * @return {number} The requested 32-bits as an unsigned number.253 */254goog.math.Integer.prototype.getBitsUnsigned = function(index) {255 var val = this.getBits(index);256 return val >= 0 ? val : goog.math.Integer.TWO_PWR_32_DBL_ + val;257};258/** @return {number} The sign bit of this number, -1 or 0. */259goog.math.Integer.prototype.getSign = function() {260 return this.sign_;261};262/** @return {boolean} Whether this value is zero. */263goog.math.Integer.prototype.isZero = function() {264 if (this.sign_ != 0) {265 return false;266 }267 for (var i = 0; i < this.bits_.length; i++) {268 if (this.bits_[i] != 0) {269 return false;270 }271 }272 return true;273};274/** @return {boolean} Whether this value is negative. */275goog.math.Integer.prototype.isNegative = function() {276 return this.sign_ == -1;277};278/** @return {boolean} Whether this value is odd. */279goog.math.Integer.prototype.isOdd = function() {280 return (this.bits_.length == 0) && (this.sign_ == -1) ||281 (this.bits_.length > 0) && ((this.bits_[0] & 1) != 0);282};283/**284 * @param {goog.math.Integer} other Integer to compare against.285 * @return {boolean} Whether this Integer equals the other.286 */287goog.math.Integer.prototype.equals = function(other) {288 if (this.sign_ != other.sign_) {289 return false;290 }291 var len = Math.max(this.bits_.length, other.bits_.length);292 for (var i = 0; i < len; i++) {293 if (this.getBits(i) != other.getBits(i)) {294 return false;295 }296 }297 return true;298};299/**300 * @param {goog.math.Integer} other Integer to compare against.301 * @return {boolean} Whether this Integer does not equal the other.302 */303goog.math.Integer.prototype.notEquals = function(other) {304 return !this.equals(other);305};306/**307 * @param {goog.math.Integer} other Integer to compare against.308 * @return {boolean} Whether this Integer is greater than the other.309 */310goog.math.Integer.prototype.greaterThan = function(other) {311 return this.compare(other) > 0;312};313/**314 * @param {goog.math.Integer} other Integer to compare against.315 * @return {boolean} Whether this Integer is greater than or equal to the other.316 */317goog.math.Integer.prototype.greaterThanOrEqual = function(other) {318 return this.compare(other) >= 0;319};320/**321 * @param {goog.math.Integer} other Integer to compare against.322 * @return {boolean} Whether this Integer is less than the other.323 */324goog.math.Integer.prototype.lessThan = function(other) {325 return this.compare(other) < 0;326};327/**328 * @param {goog.math.Integer} other Integer to compare against.329 * @return {boolean} Whether this Integer is less than or equal to the other.330 */331goog.math.Integer.prototype.lessThanOrEqual = function(other) {332 return this.compare(other) <= 0;333};334/**335 * Compares this Integer with the given one.336 * @param {goog.math.Integer} other Integer to compare against.337 * @return {number} 0 if they are the same, 1 if the this is greater, and -1338 * if the given one is greater.339 */340goog.math.Integer.prototype.compare = function(other) {341 var diff = this.subtract(other);342 if (diff.isNegative()) {343 return -1;344 } else if (diff.isZero()) {345 return 0;346 } else {347 return +1;348 }349};350/**351 * Returns an integer with only the first numBits bits of this value, sign352 * extended from the final bit.353 * @param {number} numBits The number of bits by which to shift.354 * @return {!goog.math.Integer} The shorted integer value.355 */356goog.math.Integer.prototype.shorten = function(numBits) {357 var arr_index = (numBits - 1) >> 5;358 var bit_index = (numBits - 1) % 32;359 var bits = [];360 for (var i = 0; i < arr_index; i++) {361 bits[i] = this.getBits(i);362 }363 var sigBits = bit_index == 31 ? 0xFFFFFFFF : (1 << (bit_index + 1)) - 1;364 var val = this.getBits(arr_index) & sigBits;365 if (val & (1 << bit_index)) {366 val |= 0xFFFFFFFF - sigBits;367 bits[arr_index] = val;368 return new goog.math.Integer(bits, -1);369 } else {370 bits[arr_index] = val;371 return new goog.math.Integer(bits, 0);372 }373};374/** @return {!goog.math.Integer} The negation of this value. */375goog.math.Integer.prototype.negate = function() {376 return this.not().add(goog.math.Integer.ONE);377};378/**379 * Returns the sum of this and the given Integer.380 * @param {goog.math.Integer} other The Integer to add to this.381 * @return {!goog.math.Integer} The Integer result.382 */383goog.math.Integer.prototype.add = function(other) {384 var len = Math.max(this.bits_.length, other.bits_.length);385 var arr = [];386 var carry = 0;387 for (var i = 0; i <= len; i++) {388 var a1 = this.getBits(i) >>> 16;389 var a0 = this.getBits(i) & 0xFFFF;390 var b1 = other.getBits(i) >>> 16;391 var b0 = other.getBits(i) & 0xFFFF;392 var c0 = carry + a0 + b0;393 var c1 = (c0 >>> 16) + a1 + b1;394 carry = c1 >>> 16;395 c0 &= 0xFFFF;396 c1 &= 0xFFFF;397 arr[i] = (c1 << 16) | c0;398 }399 return goog.math.Integer.fromBits(arr);400};401/**402 * Returns the difference of this and the given Integer.403 * @param {goog.math.Integer} other The Integer to subtract from this.404 * @return {!goog.math.Integer} The Integer result.405 */406goog.math.Integer.prototype.subtract = function(other) {407 return this.add(other.negate());408};409/**410 * Returns the product of this and the given Integer.411 * @param {goog.math.Integer} other The Integer to multiply against this.412 * @return {!goog.math.Integer} The product of this and the other.413 */414goog.math.Integer.prototype.multiply = function(other) {415 if (this.isZero()) {416 return goog.math.Integer.ZERO;417 } else if (other.isZero()) {418 return goog.math.Integer.ZERO;419 }420 if (this.isNegative()) {421 if (other.isNegative()) {422 return this.negate().multiply(other.negate());423 } else {424 return this.negate().multiply(other).negate();425 }426 } else if (other.isNegative()) {427 return this.multiply(other.negate()).negate();428 }429 // If both numbers are small, use float multiplication430 if (this.lessThan(goog.math.Integer.TWO_PWR_24_) &&431 other.lessThan(goog.math.Integer.TWO_PWR_24_)) {432 return goog.math.Integer.fromNumber(this.toNumber() * other.toNumber());433 }434 // Fill in an array of 16-bit products.435 var len = this.bits_.length + other.bits_.length;436 var arr = [];437 for (var i = 0; i < 2 * len; i++) {438 arr[i] = 0;439 }440 for (var i = 0; i < this.bits_.length; i++) {441 for (var j = 0; j < other.bits_.length; j++) {442 var a1 = this.getBits(i) >>> 16;443 var a0 = this.getBits(i) & 0xFFFF;444 var b1 = other.getBits(j) >>> 16;445 var b0 = other.getBits(j) & 0xFFFF;446 arr[2 * i + 2 * j] += a0 * b0;447 goog.math.Integer.carry16_(arr, 2 * i + 2 * j);448 arr[2 * i + 2 * j + 1] += a1 * b0;449 goog.math.Integer.carry16_(arr, 2 * i + 2 * j + 1);450 arr[2 * i + 2 * j + 1] += a0 * b1;451 goog.math.Integer.carry16_(arr, 2 * i + 2 * j + 1);452 arr[2 * i + 2 * j + 2] += a1 * b1;453 goog.math.Integer.carry16_(arr, 2 * i + 2 * j + 2);454 }455 }456 // Combine the 16-bit values into 32-bit values.457 for (var i = 0; i < len; i++) {458 arr[i] = (arr[2 * i + 1] << 16) | arr[2 * i];459 }460 for (var i = len; i < 2 * len; i++) {461 arr[i] = 0;462 }463 return new goog.math.Integer(arr, 0);464};465/**466 * Carries any overflow from the given index into later entries.467 * @param {Array.<number>} bits Array of 16-bit values in little-endian order.468 * @param {number} index The index in question.469 * @private470 */471goog.math.Integer.carry16_ = function(bits, index) {472 while ((bits[index] & 0xFFFF) != bits[index]) {473 bits[index + 1] += bits[index] >>> 16;474 bits[index] &= 0xFFFF;475 }476};477/**478 * Returns this Integer divided by the given one.479 * @param {goog.math.Integer} other Th Integer to divide this by.480 * @return {!goog.math.Integer} This value divided by the given one.481 */482goog.math.Integer.prototype.divide = function(other) {483 if (other.isZero()) {484 throw Error('division by zero');485 } else if (this.isZero()) {486 return goog.math.Integer.ZERO;487 }488 if (this.isNegative()) {489 if (other.isNegative()) {490 return this.negate().divide(other.negate());491 } else {492 return this.negate().divide(other).negate();493 }494 } else if (other.isNegative()) {495 return this.divide(other.negate()).negate();496 }497 // Repeat the following until the remainder is less than other: find a498 // floating-point that approximates remainder / other *from below*, add this499 // into the result, and subtract it from the remainder. It is critical that500 // the approximate value is less than or equal to the real value so that the501 // remainder never becomes negative.502 var res = goog.math.Integer.ZERO;503 var rem = this;504 while (rem.greaterThanOrEqual(other)) {505 // Approximate the result of division. This may be a little greater or506 // smaller than the actual value.507 var approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));508 // We will tweak the approximate result by changing it in the 48-th digit or509 // the smallest non-fractional digit, whichever is larger.510 var log2 = Math.ceil(Math.log(approx) / Math.LN2);511 var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);512 // Decrease the approximation until it is smaller than the remainder. Note513 // that if it is too large, the product overflows and is negative.514 var approxRes = goog.math.Integer.fromNumber(approx);515 var approxRem = approxRes.multiply(other);516 while (approxRem.isNegative() || approxRem.greaterThan(rem)) {517 approx -= delta;518 approxRes = goog.math.Integer.fromNumber(approx);519 approxRem = approxRes.multiply(other);520 }521 // We know the answer can't be zero... and actually, zero would cause522 // infinite recursion since we would make no progress.523 if (approxRes.isZero()) {524 approxRes = goog.math.Integer.ONE;525 }526 res = res.add(approxRes);527 rem = rem.subtract(approxRem);528 }529 return res;530};531/**532 * Returns this Integer modulo the given one.533 * @param {goog.math.Integer} other The Integer by which to mod.534 * @return {!goog.math.Integer} This value modulo the given one.535 */536goog.math.Integer.prototype.modulo = function(other) {537 return this.subtract(this.divide(other).multiply(other));538};539/** @return {!goog.math.Integer} The bitwise-NOT of this value. */540goog.math.Integer.prototype.not = function() {541 var len = this.bits_.length;542 var arr = [];543 for (var i = 0; i < len; i++) {544 arr[i] = ~this.bits_[i];545 }546 return new goog.math.Integer(arr, ~this.sign_);547};548/**549 * Returns the bitwise-AND of this Integer and the given one.550 * @param {goog.math.Integer} other The Integer to AND with this.551 * @return {!goog.math.Integer} The bitwise-AND of this and the other.552 */553goog.math.Integer.prototype.and = function(other) {554 var len = Math.max(this.bits_.length, other.bits_.length);555 var arr = [];556 for (var i = 0; i < len; i++) {557 arr[i] = this.getBits(i) & other.getBits(i);558 }559 return new goog.math.Integer(arr, this.sign_ & other.sign_);560};561/**562 * Returns the bitwise-OR of this Integer and the given one.563 * @param {goog.math.Integer} other The Integer to OR with this.564 * @return {!goog.math.Integer} The bitwise-OR of this and the other.565 */566goog.math.Integer.prototype.or = function(other) {567 var len = Math.max(this.bits_.length, other.bits_.length);568 var arr = [];569 for (var i = 0; i < len; i++) {570 arr[i] = this.getBits(i) | other.getBits(i);571 }572 return new goog.math.Integer(arr, this.sign_ | other.sign_);573};574/**575 * Returns the bitwise-XOR of this Integer and the given one.576 * @param {goog.math.Integer} other The Integer to XOR with this.577 * @return {!goog.math.Integer} The bitwise-XOR of this and the other.578 */579goog.math.Integer.prototype.xor = function(other) {580 var len = Math.max(this.bits_.length, other.bits_.length);581 var arr = [];582 for (var i = 0; i < len; i++) {583 arr[i] = this.getBits(i) ^ other.getBits(i);584 }585 return new goog.math.Integer(arr, this.sign_ ^ other.sign_);586};587/**588 * Returns this value with bits shifted to the left by the given amount.589 * @param {number} numBits The number of bits by which to shift.590 * @return {!goog.math.Integer} This shifted to the left by the given amount.591 */592goog.math.Integer.prototype.shiftLeft = function(numBits) {593 var arr_delta = numBits >> 5;594 var bit_delta = numBits % 32;595 var len = this.bits_.length + arr_delta + (bit_delta > 0 ? 1 : 0);596 var arr = [];597 for (var i = 0; i < len; i++) {598 if (bit_delta > 0) {599 arr[i] = (this.getBits(i - arr_delta) << bit_delta) |600 (this.getBits(i - arr_delta - 1) >>> (32 - bit_delta));601 } else {602 arr[i] = this.getBits(i - arr_delta);603 }604 }605 return new goog.math.Integer(arr, this.sign_);606};607/**608 * Returns this value with bits shifted to the right by the given amount.609 * @param {number} numBits The number of bits by which to shift.610 * @return {!goog.math.Integer} This shifted to the right by the given amount.611 */612goog.math.Integer.prototype.shiftRight = function(numBits) {613 var arr_delta = numBits >> 5;614 var bit_delta = numBits % 32;615 var len = this.bits_.length - arr_delta;616 var arr = [];617 for (var i = 0; i < len; i++) {618 if (bit_delta > 0) {619 arr[i] = (this.getBits(i + arr_delta) >>> bit_delta) |620 (this.getBits(i + arr_delta + 1) << (32 - bit_delta));621 } else {622 arr[i] = this.getBits(i + arr_delta);623 }624 }625 return new goog.math.Integer(arr, this.sign_);...
Phaser.js
Source:Phaser.js
1/**2* @author Richard Davey <rich@photonstorm.com>3* @copyright 2016 Photon Storm Ltd.4* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}5*/6/**7* @namespace Phaser8*/9var Phaser = Phaser || { // jshint ignore:line10 /**11 * The Phaser version number.12 * @constant13 * @type {string}14 */15 VERSION: '2.6.2',16 /**17 * An array of Phaser game instances.18 * @constant19 * @type {array}20 */21 GAMES: [],22 /**23 * AUTO renderer - picks between WebGL or Canvas based on device.24 * @constant25 * @type {integer}26 */27 AUTO: 0,28 /**29 * Canvas Renderer.30 * @constant31 * @type {integer}32 */33 CANVAS: 1,34 /**35 * WebGL Renderer.36 * @constant37 * @type {integer}38 */39 WEBGL: 2,40 /**41 * Headless renderer (not visual output)42 * @constant43 * @type {integer}44 */45 HEADLESS: 3,46 /**47 * Direction constant.48 * @constant49 * @type {integer}50 */51 NONE: 0,52 /**53 * Direction constant.54 * @constant55 * @type {integer}56 */57 LEFT: 1,58 /**59 * Direction constant.60 * @constant61 * @type {integer}62 */63 RIGHT: 2,64 /**65 * Direction constant.66 * @constant67 * @type {integer}68 */69 UP: 3,70 /**71 * Direction constant.72 * @constant73 * @type {integer}74 */75 DOWN: 4,76 /**77 * Game Object type.78 * @constant79 * @type {integer}80 */81 SPRITE: 0,82 /**83 * Game Object type.84 * @constant85 * @type {integer}86 */87 BUTTON: 1,88 /**89 * Game Object type.90 * @constant91 * @type {integer}92 */93 IMAGE: 2,94 /**95 * Game Object type.96 * @constant97 * @type {integer}98 */99 GRAPHICS: 3,100 /**101 * Game Object type.102 * @constant103 * @type {integer}104 */105 TEXT: 4,106 /**107 * Game Object type.108 * @constant109 * @type {integer}110 */111 TILESPRITE: 5,112 /**113 * Game Object type.114 * @constant115 * @type {integer}116 */117 BITMAPTEXT: 6,118 /**119 * Game Object type.120 * @constant121 * @type {integer}122 */123 GROUP: 7,124 /**125 * Game Object type.126 * @constant127 * @type {integer}128 */129 RENDERTEXTURE: 8,130 /**131 * Game Object type.132 * @constant133 * @type {integer}134 */135 TILEMAP: 9,136 /**137 * Game Object type.138 * @constant139 * @type {integer}140 */141 TILEMAPLAYER: 10,142 /**143 * Game Object type.144 * @constant145 * @type {integer}146 */147 EMITTER: 11,148 /**149 * Game Object type.150 * @constant151 * @type {integer}152 */153 POLYGON: 12,154 /**155 * Game Object type.156 * @constant157 * @type {integer}158 */159 BITMAPDATA: 13,160 /**161 * Game Object type.162 * @constant163 * @type {integer}164 */165 CANVAS_FILTER: 14,166 /**167 * Game Object type.168 * @constant169 * @type {integer}170 */171 WEBGL_FILTER: 15,172 /**173 * Game Object type.174 * @constant175 * @type {integer}176 */177 ELLIPSE: 16,178 /**179 * Game Object type.180 * @constant181 * @type {integer}182 */183 SPRITEBATCH: 17,184 /**185 * Game Object type.186 * @constant187 * @type {integer}188 */189 RETROFONT: 18,190 /**191 * Game Object type.192 * @constant193 * @type {integer}194 */195 POINTER: 19,196 /**197 * Game Object type.198 * @constant199 * @type {integer}200 */201 ROPE: 20,202 /**203 * Game Object type.204 * @constant205 * @type {integer}206 */207 CIRCLE: 21,208 /**209 * Game Object type.210 * @constant211 * @type {integer}212 */213 RECTANGLE: 22,214 /**215 * Game Object type.216 * @constant217 * @type {integer}218 */219 LINE: 23,220 /**221 * Game Object type.222 * @constant223 * @type {integer}224 */225 MATRIX: 24,226 /**227 * Game Object type.228 * @constant229 * @type {integer}230 */231 POINT: 25,232 /**233 * Game Object type.234 * @constant235 * @type {integer}236 */237 ROUNDEDRECTANGLE: 26,238 /**239 * Game Object type.240 * @constant241 * @type {integer}242 */243 CREATURE: 27,244 /**245 * Game Object type.246 * @constant247 * @type {integer}248 */249 VIDEO: 28,250 /**251 * Game Object type.252 * @constant253 * @type {integer}254 */255 PENDING_ATLAS: -1,256 /**257 * A horizontal orientation258 * @constant259 * @type {integer}260 */261 HORIZONTAL: 0,262 /**263 * A vertical orientation264 * @constant265 * @type {integer}266 */267 VERTICAL: 1,268 /**269 * A landscape orientation270 * @constant271 * @type {integer}272 */273 LANDSCAPE: 0,274 /**275 * A portrait orientation276 * @constant277 * @type {integer}278 */279 PORTRAIT: 1,280 /**281 * The Angle (in degrees) a Game Object needs to be set to in order to face up.282 * @constant283 * @type {integer}284 */285 ANGLE_UP: 270,286 /**287 * The Angle (in degrees) a Game Object needs to be set to in order to face down.288 * @constant289 * @type {integer}290 */291 ANGLE_DOWN: 90,292 /**293 * The Angle (in degrees) a Game Object needs to be set to in order to face left.294 * @constant295 * @type {integer}296 */297 ANGLE_LEFT: 180,298 /**299 * The Angle (in degrees) a Game Object needs to be set to in order to face right.300 * @constant301 * @type {integer}302 */303 ANGLE_RIGHT: 0,304 /**305 * The Angle (in degrees) a Game Object needs to be set to in order to face north east.306 * @constant307 * @type {integer}308 */309 ANGLE_NORTH_EAST: 315,310 /**311 * The Angle (in degrees) a Game Object needs to be set to in order to face north west.312 * @constant313 * @type {integer}314 */315 ANGLE_NORTH_WEST: 225,316 /**317 * The Angle (in degrees) a Game Object needs to be set to in order to face south east.318 * @constant319 * @type {integer}320 */321 ANGLE_SOUTH_EAST: 45,322 /**323 * The Angle (in degrees) a Game Object needs to be set to in order to face south west.324 * @constant325 * @type {integer}326 */327 ANGLE_SOUTH_WEST: 135,328 /**329 * A constant representing a top-left alignment or position.330 * @constant331 * @type {integer}332 */333 TOP_LEFT: 0,334 /**335 * A constant representing a top-center alignment or position.336 * @constant337 * @type {integer}338 */339 TOP_CENTER: 1,340 /**341 * A constant representing a top-right alignment or position.342 * @constant343 * @type {integer}344 */345 TOP_RIGHT: 2,346 /**347 * A constant representing a left-top alignment or position.348 * @constant349 * @type {integer}350 */351 LEFT_TOP: 3,352 /**353 * A constant representing a left-center alignment or position.354 * @constant355 * @type {integer}356 */357 LEFT_CENTER: 4,358 /**359 * A constant representing a left-bottom alignment or position.360 * @constant361 * @type {integer}362 */363 LEFT_BOTTOM: 5,364 /**365 * A constant representing a center alignment or position.366 * @constant367 * @type {integer}368 */369 CENTER: 6,370 /**371 * A constant representing a right-top alignment or position.372 * @constant373 * @type {integer}374 */375 RIGHT_TOP: 7,376 /**377 * A constant representing a right-center alignment or position.378 * @constant379 * @type {integer}380 */381 RIGHT_CENTER: 8,382 /**383 * A constant representing a right-bottom alignment or position.384 * @constant385 * @type {integer}386 */387 RIGHT_BOTTOM: 9,388 /**389 * A constant representing a bottom-left alignment or position.390 * @constant391 * @type {integer}392 */393 BOTTOM_LEFT: 10,394 /**395 * A constant representing a bottom-center alignment or position.396 * @constant397 * @type {integer}398 */399 BOTTOM_CENTER: 11,400 /**401 * A constant representing a bottom-right alignment or position.402 * @constant403 * @type {integer}404 */405 BOTTOM_RIGHT: 12,406 /**407 * Various blend modes supported by Pixi.408 * 409 * IMPORTANT: The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.410 * 411 * @constant412 * @property {Number} blendModes.NORMAL413 * @property {Number} blendModes.ADD414 * @property {Number} blendModes.MULTIPLY415 * @property {Number} blendModes.SCREEN416 * @property {Number} blendModes.OVERLAY417 * @property {Number} blendModes.DARKEN418 * @property {Number} blendModes.LIGHTEN419 * @property {Number} blendModes.COLOR_DODGE420 * @property {Number} blendModes.COLOR_BURN421 * @property {Number} blendModes.HARD_LIGHT422 * @property {Number} blendModes.SOFT_LIGHT423 * @property {Number} blendModes.DIFFERENCE424 * @property {Number} blendModes.EXCLUSION425 * @property {Number} blendModes.HUE426 * @property {Number} blendModes.SATURATION427 * @property {Number} blendModes.COLOR428 * @property {Number} blendModes.LUMINOSITY429 * @static430 */431 blendModes: {432 NORMAL:0,433 ADD:1,434 MULTIPLY:2,435 SCREEN:3,436 OVERLAY:4,437 DARKEN:5,438 LIGHTEN:6,439 COLOR_DODGE:7,440 COLOR_BURN:8,441 HARD_LIGHT:9,442 SOFT_LIGHT:10,443 DIFFERENCE:11,444 EXCLUSION:12,445 HUE:13,446 SATURATION:14,447 COLOR:15,448 LUMINOSITY:16449 },450 /**451 * The scale modes that are supported by Pixi.452 *453 * The DEFAULT scale mode affects the default scaling mode of future operations.454 * It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.455 *456 * @constant457 * @property {Object} Phaser.scaleModes458 * @property {Number} scaleModes.DEFAULT=LINEAR459 * @property {Number} scaleModes.LINEAR Smooth scaling460 * @property {Number} scaleModes.NEAREST Pixelating scaling461 * @static462 */463 scaleModes: {464 DEFAULT:0,465 LINEAR:0,466 NEAREST:1467 },468 PIXI: PIXI || {}...
Using AI Code Generation
1const { Verifier } = require("@pact-foundation/pact");2const path = require("path");3const opts = {4 pactUrls: [path.resolve(process.cwd(), "pacts", "test.json")],5};6new Verifier().verifyProvider(opts).then((output) => {7 console.log("Pact Verification Complete!");8 console.log(output);9});10{11 "consumer": {12 },13 {14 "request": {15 },16 "response": {17 "headers": {18 },19 {20 },21 {22 }23 }24 }25 "metadata": {26 "pact-specification": {27 },28 "pact-jvm": {29 }30 },31 "provider": {32 }33}34 at Object.<anonymous> (C:\Users\user\Documents\test2.js:19:11)35 at Module._compile (internal/modules/cjs/loader.js:1138:30)36 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)37 at Module.load (internal/modules/cjs/loader.js:986:32)38 at Function.Module._load (internal/modules/cjs/loader.js:879:14)39 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
Using AI Code Generation
1const { Matchers } = require("@pact-foundation/pact")2const { somethingLike } = Matchers3const { Matchers } = require("@pact-foundation/pact")4const { like } = Matchers5const { Matchers } = require("@pact-foundation/pact")6const { eachLike } = Matchers7const { Matchers } = require("@pact-foundation/pact")8const { term } = Matchers9const { Matchers } = require("@pact-foundation/pact")10const { somethingLike } = Matchers11const { Matchers } = require("@pact-foundation/pact")12const { somethingLike } = Matchers13const { Matchers } = require("@pact-foundation/pact")14const { somethingLike } = Matchers15const { Matchers } = require("@pact-foundation/pact")16const { somethingLike } = Matchers17const { Matchers } = require("@pact-foundation/pact")18const { somethingLike } = Matchers19const { Matchers } = require("@pact-foundation/pact")20const { somethingLike } = Matchers21const { Matchers } = require("@pact-foundation/pact")22const { somethingLike } = Matchers23const { Matchers } = require("@pact-foundation/pact")24const { somethingLike } = Matchers25const { Matchers } = require("@pact-foundation/pact")26const { somethingLike } = Matchers27const { Matchers } = require("@pact-foundation/pact")28const { somethingLike } = Matchers
Using AI Code Generation
1const { Matchers } = require('@pact-foundation/pact');2const { Matchers } = require('@pact-foundation/pact');3at new Pact (/Users/ashutosh/Desktop/Projects/NodeJS/Pact/pact-js-consumer/node_modules/@pact-foundation/pact/src/pact.ts:53:19)4at Object.<anonymous> (/Users/ashutosh/Desktop/Projects/NodeJS/Pact/pact-js-consumer/test1.js:6:15)5at Module._compile (internal/modules/cjs/loader.js:1063:30)6at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)7at Module.load (internal/modules/cjs/loader.js:928:32)8at Function.Module._load (internal/modules/cjs/loader.js:769:14)9at Module.require (internal/modules/cjs/loader.js:952:19)10at require (internal/modules/cjs/helpers.js:88:18)11at Object.<anonymous> (/Users/ashutosh/Desktop/Projects/NodeJS/Pact/pact-js-consumer/test2.js:5:16)12at Module._compile (internal/modules/cjs/loader.js:1063:30)13at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)14at Module.load (internal/modules/cjs/loader.js:928:32)15at Function.Module._load (internal/modules/cjs/loader.js:769:14)16at Module.require (internal/modules/cjs/loader.js:952:19)17at require (internal/modules/cjs/helpers.js:88:18)18at Object.<anonymous> (/Users/ashutosh/Desktop/Projects/NodeJS/Pact/pact
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!!