How to use memorytype method in wpt

Best JavaScript code snippet using wpt

memory.ts

Source:memory.ts Github

copy

Full Screen

1import { Options } from './options'2/**3 * Information about an address range; min and max are inclusive true addresses.4 */5export interface Range {6 min: number7 max: number8}9/**10 * Information about the banks of a true address.11 */12export interface Bank {13 eBank?: number14 fBank?: number15 sBank?: number16}17/**18 * The various types of memory areas.19 * The nomenclature varies between documents and the choices here arbitrarily follow Ref SYM, IIB-3.20 */21export enum MemoryType {22 Hardware,23 Special_Erasable,24 Unswitched_Banked_Erasable,25 Switched_Erasable,26 Fixed_Fixed,27 Variable_Fixed,28 Nonexistent29}30/**31 * A memory range with its type.32 */33export interface MemoryRange extends Range {34 type: MemoryType35}36const BLOCK1_TRUE_ADDRESS_RANGES: MemoryRange[] = [37 // Hardware, cannot reserve38 { min: 0x0000, max: 0x0007, type: MemoryType.Hardware },39 // Special erasable, cannot reserve40 { min: 0x0008, max: 0x002F, type: MemoryType.Special_Erasable },41 // Erasable bank 0, unswitched42 { min: 0x0030, max: 0x00FF, type: MemoryType.Unswitched_Banked_Erasable },43 // Erasable banks 1-3, unswitched44 { min: 0x0100, max: 0x01FF, type: MemoryType.Unswitched_Banked_Erasable },45 { min: 0x0200, max: 0x02FF, type: MemoryType.Unswitched_Banked_Erasable },46 { min: 0x0300, max: 0x03FF, type: MemoryType.Unswitched_Banked_Erasable },47 // Fixed banks 01-02, fixed-fixed48 { min: 0x0400, max: 0x07FF, type: MemoryType.Fixed_Fixed },49 { min: 0x0800, max: 0x0BFF, type: MemoryType.Fixed_Fixed },50 // Fixed banks 03-14, variable-fixed51 { min: 0x0C00, max: 0x0FFF, type: MemoryType.Variable_Fixed },52 { min: 0x1000, max: 0x13FF, type: MemoryType.Variable_Fixed },53 { min: 0x1400, max: 0x17FF, type: MemoryType.Variable_Fixed },54 { min: 0x1800, max: 0x1BFF, type: MemoryType.Variable_Fixed },55 { min: 0x1C00, max: 0x1FFF, type: MemoryType.Variable_Fixed },56 { min: 0x2000, max: 0x23FF, type: MemoryType.Variable_Fixed },57 { min: 0x2400, max: 0x27FF, type: MemoryType.Variable_Fixed },58 { min: 0x2800, max: 0x2BFF, type: MemoryType.Variable_Fixed },59 { min: 0x2C00, max: 0x2FFF, type: MemoryType.Variable_Fixed },60 { min: 0x3000, max: 0x33FF, type: MemoryType.Variable_Fixed },61 // Nonexistent banks 15-2062 { min: 0x3400, max: 0x37FF, type: MemoryType.Nonexistent },63 { min: 0x3800, max: 0x3BFF, type: MemoryType.Nonexistent },64 { min: 0x3C00, max: 0x3FFF, type: MemoryType.Nonexistent },65 { min: 0x4000, max: 0x43FF, type: MemoryType.Nonexistent },66 // Fixed banks 21-3467 { min: 0x4400, max: 0x47FF, type: MemoryType.Variable_Fixed },68 { min: 0x4800, max: 0x4BFF, type: MemoryType.Variable_Fixed },69 { min: 0x4C00, max: 0x4FFF, type: MemoryType.Variable_Fixed },70 { min: 0x5000, max: 0x53FF, type: MemoryType.Variable_Fixed },71 { min: 0x5400, max: 0x57FF, type: MemoryType.Variable_Fixed },72 { min: 0x5800, max: 0x5BFF, type: MemoryType.Variable_Fixed },73 { min: 0x5C00, max: 0x5FFF, type: MemoryType.Variable_Fixed },74 { min: 0x6000, max: 0x63FF, type: MemoryType.Variable_Fixed },75 { min: 0x6400, max: 0x67FF, type: MemoryType.Variable_Fixed },76 { min: 0x6800, max: 0x6BFF, type: MemoryType.Variable_Fixed },77 { min: 0x6C00, max: 0x6FFF, type: MemoryType.Variable_Fixed },78 { min: 0x7000, max: 0x73FF, type: MemoryType.Variable_Fixed }79]80const BLOCK2_TRUE_ADDRESS_RANGES: MemoryRange[] = [81 // Hardware, cannot reserve82 { min: 0x0000, max: 0x0007, type: MemoryType.Hardware },83 // Special erasable, cannot reserve84 { min: 0x0008, max: 0x002F, type: MemoryType.Special_Erasable },85 // Erasable bank 0, unswitched86 { min: 0x0030, max: 0x00FF, type: MemoryType.Unswitched_Banked_Erasable },87 // Erasable banks 1-2, unswitched88 { min: 0x0100, max: 0x01FF, type: MemoryType.Unswitched_Banked_Erasable },89 { min: 0x0200, max: 0x02FF, type: MemoryType.Unswitched_Banked_Erasable },90 // Erasable banks 3-7, switched91 { min: 0x0300, max: 0x03FF, type: MemoryType.Switched_Erasable },92 { min: 0x0400, max: 0x04FF, type: MemoryType.Switched_Erasable },93 { min: 0x0500, max: 0x05FF, type: MemoryType.Switched_Erasable },94 { min: 0x0600, max: 0x06FF, type: MemoryType.Switched_Erasable },95 { min: 0x0700, max: 0x07FF, type: MemoryType.Switched_Erasable },96 // Fixed banks 02-03, fixed-fixed97 { min: 0x0800, max: 0x0BFF, type: MemoryType.Fixed_Fixed },98 { min: 0x0C00, max: 0x0FFF, type: MemoryType.Fixed_Fixed },99 // Fixed banks 00-01, variable-fixed100 { min: 0x1000, max: 0x13FF, type: MemoryType.Variable_Fixed },101 { min: 0x1400, max: 0x17FF, type: MemoryType.Variable_Fixed },102 // Nonexistent, not bank numbered103 { min: 0x1800, max: 0x1FFF, type: MemoryType.Nonexistent },104 // Fixed banks 04-27, variable-fixed105 { min: 0x2000, max: 0x23FF, type: MemoryType.Variable_Fixed },106 { min: 0x2400, max: 0x27FF, type: MemoryType.Variable_Fixed },107 { min: 0x2800, max: 0x2BFF, type: MemoryType.Variable_Fixed },108 { min: 0x2C00, max: 0x2FFF, type: MemoryType.Variable_Fixed },109 { min: 0x3000, max: 0x33FF, type: MemoryType.Variable_Fixed },110 { min: 0x3400, max: 0x37FF, type: MemoryType.Variable_Fixed },111 { min: 0x3800, max: 0x3BFF, type: MemoryType.Variable_Fixed },112 { min: 0x3C00, max: 0x3FFF, type: MemoryType.Variable_Fixed },113 { min: 0x4000, max: 0x43FF, type: MemoryType.Variable_Fixed },114 { min: 0x4400, max: 0x47FF, type: MemoryType.Variable_Fixed },115 { min: 0x4800, max: 0x4BFF, type: MemoryType.Variable_Fixed },116 { min: 0x4C00, max: 0x4FFF, type: MemoryType.Variable_Fixed },117 { min: 0x5000, max: 0x53FF, type: MemoryType.Variable_Fixed },118 { min: 0x5400, max: 0x57FF, type: MemoryType.Variable_Fixed },119 { min: 0x5800, max: 0x5BFF, type: MemoryType.Variable_Fixed },120 { min: 0x5C00, max: 0x5FFF, type: MemoryType.Variable_Fixed },121 { min: 0x6000, max: 0x63FF, type: MemoryType.Variable_Fixed },122 { min: 0x6400, max: 0x67FF, type: MemoryType.Variable_Fixed },123 { min: 0x6800, max: 0x6BFF, type: MemoryType.Variable_Fixed },124 { min: 0x6C00, max: 0x6FFF, type: MemoryType.Variable_Fixed },125 // Fixed banks 30-37, Superbank S3126 { min: 0x7000, max: 0x73FF, type: MemoryType.Variable_Fixed },127 { min: 0x7400, max: 0x77FF, type: MemoryType.Variable_Fixed },128 { min: 0x7800, max: 0x7BFF, type: MemoryType.Variable_Fixed },129 { min: 0x7C00, max: 0x7FFF, type: MemoryType.Variable_Fixed },130 { min: 0x8000, max: 0x83FF, type: MemoryType.Variable_Fixed },131 { min: 0x8400, max: 0x87FF, type: MemoryType.Variable_Fixed },132 { min: 0x8800, max: 0x8BFF, type: MemoryType.Variable_Fixed },133 { min: 0x8C00, max: 0x8FFF, type: MemoryType.Variable_Fixed },134 // Fixed banks 40-43, Superbank S4135 { min: 0x9000, max: 0x93FF, type: MemoryType.Variable_Fixed },136 { min: 0x9400, max: 0x97FF, type: MemoryType.Variable_Fixed },137 { min: 0x9800, max: 0x9BFF, type: MemoryType.Variable_Fixed },138 { min: 0x9C00, max: 0x9FFF, type: MemoryType.Variable_Fixed },139 // Nonexistent, not bank numbered140 { min: 0xA000, max: 0xCFFF, type: MemoryType.Nonexistent },141 // Fixed banks 60-67, Superbank S5?142 { min: 0xD000, max: 0xD3FF, type: MemoryType.Variable_Fixed },143 { min: 0xD400, max: 0xD7FF, type: MemoryType.Variable_Fixed },144 { min: 0xD800, max: 0xDBFF, type: MemoryType.Variable_Fixed },145 { min: 0xDC00, max: 0xDFFF, type: MemoryType.Variable_Fixed },146 { min: 0xE000, max: 0xE3FF, type: MemoryType.Variable_Fixed },147 { min: 0xE400, max: 0xE7FF, type: MemoryType.Variable_Fixed },148 { min: 0xE800, max: 0xEBFF, type: MemoryType.Variable_Fixed },149 { min: 0xEC00, max: 0xEFFF, type: MemoryType.Variable_Fixed }150]151const BLOCK2_FIXED_BANKS_START_INDEX = 10152const BLOCK2_NONEXISTENT_BANK_02_INDEX = 14153const BLOCK2_FIXED_BANK_04_INDEX = 15154const BLOCK2_S3_START_INDEX = 35155export function createMemory (options: Options): Memory {156 if (options.source.isBlock1()) {157 return new Block1Memory()158 }159 let banks: number160 let nonexistentHighMem: Range | undefined161 let moduleOffset: number162 if (options.source.isAgc()) {163 banks = 43164 nonexistentHighMem = { min: 0xF000, max: 0xFFFF }165 moduleOffset = 1166 } else {167 banks = 35168 nonexistentHighMem = { min: 0xA000, max: 0xEFFF }169 moduleOffset = 0170 }171 return new Block2Memory(banks, nonexistentHighMem, moduleOffset)172}173export abstract class Memory {174 private readonly erasableBanksCount: number175 private readonly fixedMemoryStartAddress: number176 private readonly maxMemory: number177 constructor (178 private readonly ranges: MemoryRange[],179 private readonly fixedBanks: MemoryRange[],180 private readonly firstFixedBank: number,181 private readonly nonExistent: MemoryRange[]182 ) {183 this.erasableBanksCount = ranges.reduce((total: number, range: MemoryRange) => {184 return this.isErasable(range.type) ? total + 1 : total185 }, 0)186 this.fixedMemoryStartAddress = ranges.find(range => this.isFixed(range.type))?.min ?? 0187 this.maxMemory = ranges[ranges.length - 1].max188 }189 /**190 * Returns the maximum memory cell, which may not be available for use, as a true address191 *192 * @returns the maximum memory cell, which may not be available for use, as a true address193 */194 maxAddress (): number {195 return this.maxMemory196 }197 /**198 * Returns the memory area ranges for this memory.199 *200 * @returns the ranges201 */202 memoryRanges (): MemoryRange[] {203 return this.ranges204 }205 /**206 * Returns the memory type for the specified true address.207 *208 * @param trueAddress the address to examine209 * @returns the memory type for the specified true address210 */211 memoryType (trueAddress: number): MemoryType {212 if (trueAddress < 0) {213 return MemoryType.Nonexistent214 }215 const type = this.ranges.find(range => trueAddress <= range.max)216 return type === undefined ? MemoryType.Nonexistent : type.type217 }218 /**219 * Returns true iff the specified type is in the erasable range.220 *221 * @param type the type to examine222 * @returns true iff the specified type is in the erasable range223 */224 isErasable (type: MemoryType): boolean {225 switch (type) {226 case MemoryType.Hardware:227 case MemoryType.Special_Erasable:228 case MemoryType.Unswitched_Banked_Erasable:229 case MemoryType.Switched_Erasable:230 return true231 }232 return false233 }234 /**235 * Returns true iff the specified type is in the fixed range.236 *237 * @param type the type to examine238 * @returns true iff the specified type is in the fixed range239 */240 isFixed (type: MemoryType): boolean {241 return type === MemoryType.Fixed_Fixed242 || type === MemoryType.Variable_Fixed243 }244 /**245 * Returns the number of erasable banks in this memory.246 *247 * @returns the number of erasable banks in this memory248 */249 numErasableBanks (): number {250 return this.erasableBanksCount251 }252 /**253 * Returns the number of fixed banks in this memory.254 *255 * @returns the number of fixed banks in this memory256 */257 numFixedBanks (): number {258 return this.fixedBanks.length259 }260 /**261 * Returns the bank number of the first fixed bank in this memory.262 *263 * @returns the bank number of the first fixed bank in this memory264 */265 firstFixedBankNumber (): number {266 return this.firstFixedBank267 }268 /**269 * Returns the true address range for the specified fixed bank number.270 * If the bank number is outside the range for this memory, undefined is returned.271 *272 * @param bank the fixed bank number273 * @returns the true address range for the specified fixed bank number274 */275 fixedBankRange (bank: number): Range | undefined {276 return this.fixedBanks[bank - this.firstFixedBank]277 }278 /**279 * Returns the number of the fixed bank that contains the specified true address.280 * If the address is outside the fixed memory range for this memory, undefined is returned.281 *282 * @param trueAddress the address to examine283 * @returns the number of the fixed bank that contains the specified true address284 */285 fixedBankNumber (trueAddress: number): number | undefined {286 const result = this.asBankAndAddress(trueAddress)287 if (result?.bank.fBank === undefined) {288 return undefined289 }290 if (result.bank.sBank === undefined || result.bank.sBank === 3) {291 return result.bank.fBank292 }293 return result.bank.fBank + 8 * (result.bank.sBank - 3)294 }295 /**296 * Returns true iff the specified bank number corresponds to an erasable bank for this memory.297 *298 * @param bank the bank number to examine299 * @returns true iff the specified bank number corresponds to an erasable bank300 */301 isErasableBank (bank: number): boolean {302 return bank >= 0 && bank < this.numErasableBanks()303 }304 /**305 * Returns true iff the specified bank number corresponds to a fixed bank for this memory.306 *307 * @param bank the bank number to examine308 * @returns true iff the specified bank number corresponds to a fixed bank309 */310 isFixedBank (bank: number): boolean {311 const adjusted = bank - this.firstFixedBank312 return adjusted >= 0 && adjusted < this.numFixedBanks()313 }314 /**315 * Returns the FBANK number and SBANK number if applicable for the specified fixed bank number.316 * If the bank number is outside this memory range, undefined is returned.317 *318 * @param bank the bank number to examine319 * @returns the FBANK number and SBANK number if applicable for the specified fixed bank number320 */321 abstract fixedBankNumberToBank (bank: number): { fBank: number, sBank?: number } | undefined322 protected abstract asErasableBankAndAddress (trueAddress: number): { bank: Bank, address: number }323 protected abstract asFixedBankAndAddress (trueAddress: number): { bank: Bank, address: number }324 /**325 * Returns the bank information and S-register address for the specified true address.326 * If the address is outside the machine's memory range, undefined is returned.327 *328 * @param trueAddress the address to translate329 * @returns the bank information and S-register address for the specified true address330 */331 asBankAndAddress (trueAddress: number): { bank: Bank, address: number } | undefined {332 const type = this.memoryType(trueAddress)333 if (this.isErasable(type)) {334 return this.asErasableBankAndAddress(trueAddress)335 } else if (this.isFixed(type)) {336 return this.asFixedBankAndAddress(trueAddress)337 }338 }339 /**340 * Returns the switched bank information and S-register address for the specified true address.341 * If the true address is in unswitched memory, it is returned as is with bank as undefined.342 * Otherwise equivalent to calling asBankAndAddress.343 *344 * @param trueAddress the address to translate345 * @returns the switched bank information and S-register address for the specified true address346 */347 asSwitchedBankAndAddress (trueAddress: number): { bank?: Bank, address: number } | undefined {348 const type = this.memoryType(trueAddress)349 if (type === MemoryType.Switched_Erasable) {350 return this.asErasableBankAndAddress(trueAddress)351 } else if (type === MemoryType.Variable_Fixed) {352 return this.asFixedBankAndAddress(trueAddress)353 } else if (type !== MemoryType.Nonexistent) {354 return { address: trueAddress }355 }356 }357 private asCompleteSwitchedBankAndAddress (trueAddress: number): { bank?: Bank, address: number } | undefined {358 const type = this.memoryType(trueAddress)359 if (type === MemoryType.Switched_Erasable) {360 return this.asErasableBankAndAddress(trueAddress)361 } else if (type === MemoryType.Variable_Fixed) {362 return this.asFixedBankAndAddress(trueAddress)363 } else if (type !== MemoryType.Nonexistent) {364 return { address: trueAddress }365 } else if (trueAddress <= this.maxMemory) {366 return this.asFixedBankAndAddress(trueAddress)367 }368 }369 /**370 * Returns the fixed complete address for the specified true address.371 * This is the FBANK in the 4 high bits and the S-register offset ([0, 01777]) in the 10 low bits.372 * See Ref BTM, page 1-11.373 * If the address is outside the fixed memory range, undefined is returned.374 *375 * @param trueAddress the address to translate376 * @returns the fixed complete address for the specified true address377 */378 abstract asFixedCompleteAddress (trueAddress: number): number | undefined379 /**380 * Returns the interpretive fixed complete address, used for interpretive indexing.381 *382 * @param locationCounter the location counter of the interpretive instruction383 * @param trueAddress the true address referenced by the IAW384 * @returns the interpretive fixed complete address385 */386 abstract asInterpretiveFixedAddress (locationCounter: number, trueAddress: number): number | undefined387 /**388 * Formats the specified true address as an assembly string to match the YUL assembly listing.389 *390 * The assembly string format is as follows.391 * SREG is the S-register value.392 * All values are in octal.393 * - If in erasable memory: "E" <EBANK> "," <SREG>394 * - If in fixed memory for this memory: <fixed bank> "," <SREG>395 * - If not addressable: <address> "?"396 *397 * @param trueAddress the address to format398 * @returns the assembly string formatted address399 */400 asAssemblyString (trueAddress?: number): string {401 if (trueAddress === undefined) {402 return ''403 }404 const bankAndAddress = this.asCompleteSwitchedBankAndAddress(trueAddress)405 let bankField = ''406 if (bankAndAddress === undefined) {407 return trueAddress.toString(8) + '?'408 } else if (bankAndAddress.bank !== undefined) {409 if (bankAndAddress.bank.eBank !== undefined) {410 bankField = 'E' + bankAndAddress.bank.eBank.toString(8) + ','411 } else if (bankAndAddress.bank.fBank !== undefined) {412 const adjustedFBank = bankAndAddress.bank.fBank + 8 * ((bankAndAddress.bank.sBank ?? 3) - 3)413 bankField = adjustedFBank.toString(8).padStart(2, '0') + ','414 }415 }416 const addressField = bankAndAddress.address.toString(8).padStart(4, '0')417 return bankField + addressField418 }419 /**420 * Returns the paragraph number for the specified fixed memory true address.421 * If the address is outside the fixed memory range, undefined is returned.422 * Ref SYM, IIF-4.423 *424 * @param trueAddress the address to examine425 * @returns the paragraph number426 */427 paragraph (trueAddress: number): number | undefined {428 return this.isFixed(this.memoryType(trueAddress)) ? Math.floor(trueAddress / 256) : undefined429 }430 /**431 * Returns the hardware module number for the specified fixed bank number.432 * Ref SYM, IIF-3, differs for Block 1.433 *434 * @param bank the fixed bank435 * @returns the module number, or undefined if bank is not a fixed bank number436 */437 abstract hardwareModule (bank: number): number | undefined438 /**439 * Returns the hardware side string ('A' or 'B') for the specified S-register address.440 * Ref SYM, IIF-3.441 * Only applicable to Block 2.442 *443 * @param sRegister the S-register value444 * @returns the side445 */446 abstract hardwareSide (sRegister: number): string447 /**448 * Returns the hardware stick number.449 * Only applicable to Block 1.450 *451 * @param bank the fixed bank452 * @returns the stick number, or undefined if bank is not a fixed bank number453 */454 abstract hardwareStick (bank: number): string | undefined455 /**456 * Returns the hardware strand (1 - 12) within a module for the specified bank and S-register address.457 * Ref SYM, IIF-3, differs for Block 1.458 *459 * @param bank the fixed bank460 * @param sRegister the S-register value461 */462 abstract hardwareStrand (bank: number, sRegister: number): number463 /**464 * Returns the hardware wire range for the specified set.465 * Empirically from original assembly output.466 *467 * @param set the set468 * @returns the wire range469 */470 abstract hardwareWires (set: number): Range471 /**472 * Returns the number of usable memory words.473 * This is the memory range minus any nonexistent ranges.474 *475 * @returns the number of usable memory words476 */477 cellCount (): number {478 const unaddressable = this.nonExistent.reduce(479 (total: number, range: MemoryRange) => { return total + range.max - range.min + 1 }, 0)480 return this.maxMemory - unaddressable + 1481 }482 /**483 * Returns the first fixed bank's offset from the start of memory.484 *485 * @returns the first fixed bank's offset from the start of memory486 */487 fixedMemoryOffset (): number {488 return this.memoryOffset(this.fixedMemoryStartAddress)489 }490 /**491 * Returns the specified true address's offset from the start of memory, ignoring the nonexistent ranges.492 * No checking is done to ensure the address falls within the memory range.493 *494 * @param trueAddress the address to examine495 * @returns the specified true address's offset from the start of memory496 */497 memoryOffset (trueAddress: number): number {498 const unaddressable = this.nonExistent.reduce(499 (total: number, range: MemoryRange) => {500 if (trueAddress > range.max) {501 return total + range.max - range.min + 1502 }503 return total504 }, 0)505 return trueAddress - unaddressable506 }507 /**508 * Returns the true memory address for the specified offset from the start of memory.509 * This is the complement to memoryOffset.510 * No range checking is done on the input.511 *512 * @param offset the offset from the start of memory513 * @returns the true memory address for the specified offset from the start of memory514 */515 memoryAddress (offset: number): number {516 return this.nonExistent.reduce(517 (total: number, range: MemoryRange) => {518 if (total < range.min) {519 return total520 }521 return total + range.max - range.min + 1522 }, offset)523 }524}525class Block1Memory extends Memory {526 private readonly lowMemoryMin: number527 private readonly lowMemoryMax: number528 private readonly highMemoryMin: number529 private readonly highMemoryMax: number530 /**531 * Constructs a block 1 memory representation.532 */533 constructor () {534 const ranges: MemoryRange[] = []535 const fixedBanks: MemoryRange[] = []536 const nonExistent: MemoryRange[] = []537 BLOCK1_TRUE_ADDRESS_RANGES.forEach(range => {538 ranges.push(range)539 if (range.type === MemoryType.Nonexistent) {540 nonExistent.push(range)541 fixedBanks.push(range)542 } else if (range.type === MemoryType.Fixed_Fixed || range.type === MemoryType.Variable_Fixed) {543 fixedBanks.push(range)544 }545 })546 super(ranges, fixedBanks, 1, nonExistent)547 this.lowMemoryMin = fixedBanks[2].min548 this.lowMemoryMax = fixedBanks[12].max549 this.highMemoryMin = fixedBanks[13].min550 this.highMemoryMax = fixedBanks[fixedBanks.length - 1].max551 }552 fixedBankNumberToBank (bank: number): { fBank: number, sBank?: number } | undefined {553 if (!this.isFixedBank(bank)) {554 return undefined555 }556 return { fBank: bank }557 }558 protected asErasableBankAndAddress (trueAddress: number): { bank: Bank, address: number } {559 const eBank = (trueAddress & 0x700) >> 8560 return { bank: { eBank }, address: trueAddress }561 }562 protected asFixedBankAndAddress (trueAddress: number): { bank: Bank, address: number } {563 const fixed = trueAddress564 const address = 0xC00 + (fixed & 0x3FF)565 const fBank = (fixed & 0x7C00) >> 10566 return { bank: { fBank, sBank: undefined }, address }567 }568 asFixedCompleteAddress (trueAddress: number): number | undefined {569 const bankAndAddress = this.asBankAndAddress(trueAddress)570 if (bankAndAddress === undefined || bankAndAddress.bank.fBank === undefined) {571 return undefined572 }573 return bankAndAddress.bank.fBank << 10 | (bankAndAddress.address - 0xC00)574 }575 asInterpretiveFixedAddress (locationCounter: number, trueAddress: number): number | undefined {576 if (trueAddress < 0) {577 return -trueAddress578 }579 const bankAndAddress = this.asBankAndAddress(trueAddress)580 if (bankAndAddress?.bank.fBank !== undefined) {581 if (bankAndAddress.bank.fBank <= 12) {582 return bankAndAddress.bank.fBank << 10 | (bankAndAddress.address - 0xC00)583 } else if (bankAndAddress.bank.fBank >= 17) {584 return (bankAndAddress.bank.fBank - 16) << 10 | (bankAndAddress.address - 0xC00)585 }586 }587 }588 hardwareModule (bank: number): number | undefined {589 if (!this.isFixedBank(bank)) {590 return undefined591 }592 const moduleOffset = (bank - 1) >> 2 & 3593 const offset = bank % 4 < 2 ? 0 : 1594 switch (moduleOffset) {595 case 0:596 return 28 + offset597 case 1:598 return 21 + offset599 case 2:600 return 23 + offset601 }602 }603 hardwareSide (sRegister: number): string {604 throw new Error('Unsupported operation')605 }606 hardwareStick (bank: number): string | undefined {607 if (!this.isFixedBank(bank)) {608 return undefined609 }610 const moduleOffset = (bank - 1) >> 2 & 3611 const rope = String.fromCharCode('R'.charCodeAt(0) + moduleOffset)612 const offset = bank % 4 < 2 ? '1' : '2'613 const side = bank % 2 === 0 ? 'A' : 'B'614 return rope + offset + side615 }616 hardwareStrand (bank: number, sRegister: number): number {617 return 4 * Math.floor(bank / 17) + Math.floor((sRegister - 0xC00) / 0xFF)618 }619 hardwareWires (set: number): Range {620 const min = 1 + set * 16621 const max = min + 15622 return { min, max }623 }624}625class Block2Memory extends Memory {626 private readonly moduleOffset: number627 /**628 * Constructs a block 2 memory representation with the specified number of629 * banks and nonexistent high memory range.630 * EOL output on MEMORY TYPE & AVAILABILITY DISPLAY page shows banks above 043631 * that are never used.632 *633 * @param numFixedBanks the number of fixed banks typically 027, 037, 043634 * @param nonexistentHighMem special unaddressable high memory, if any635 * @param moduleOffset bank offset to calculate hardware module636 * @throws if fixedBanks is not in the range [027, 043]637 */638 constructor (639 numFixedBanks: number,640 nonexistentHighMem: Range | undefined,641 moduleOffset: number) {642 if (numFixedBanks < 23 || numFixedBanks > 43) {643 throw new Error('fixedBanks out of range')644 }645 const ranges: MemoryRange[] = []646 const fixedBanks: MemoryRange[] = []647 const nonExistent: MemoryRange[] = []648 for (let i = 0; i < BLOCK2_FIXED_BANK_04_INDEX; i++) {649 ranges.push(BLOCK2_TRUE_ADDRESS_RANGES[i])650 }651 fixedBanks.push(BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_FIXED_BANKS_START_INDEX + 2])652 fixedBanks.push(BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_FIXED_BANKS_START_INDEX + 3])653 fixedBanks.push(BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_FIXED_BANKS_START_INDEX + 0])654 fixedBanks.push(BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_FIXED_BANKS_START_INDEX + 1])655 nonExistent.push(BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_NONEXISTENT_BANK_02_INDEX])656 let i = 0657 let fixedBanksRemaining = numFixedBanks - 3658 while (fixedBanksRemaining > 0) {659 const range = BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_FIXED_BANK_04_INDEX + i++]660 ranges.push(range)661 if (range.type === MemoryType.Nonexistent) {662 nonExistent.push(range)663 } else {664 fixedBanks.push(range)665 --fixedBanksRemaining666 }667 }668 if (nonexistentHighMem !== undefined) {669 // Add the nonexistent high memory670 const range = { min: nonexistentHighMem?.min, max: nonexistentHighMem?.max, type: MemoryType.Nonexistent }671 ranges.push(range)672 nonExistent.push(range)673 }674 super(ranges, fixedBanks, 0, nonExistent)675 this.moduleOffset = moduleOffset676 }677 fixedBankNumberToBank (bank: number): { fBank: number, sBank?: number } | undefined {678 if (!this.isFixedBank(bank)) {679 return undefined680 }681 if (bank < 24) {682 return { fBank: bank }683 } else if (bank < 32) {684 return { fBank: bank, sBank: 3 }685 } else {686 const sBank = Math.floor(bank / 8)687 return { fBank: bank, sBank }688 }689 }690 protected asErasableBankAndAddress (trueAddress: number): { bank: Bank, address: number } {691 const address = 0x300 + (trueAddress & 0xFF)692 const eBank = (trueAddress & 0x700) >> 8693 return { bank: { eBank }, address }694 }695 protected asFixedBankAndAddress (trueAddress: number): { bank: Bank, address: number } {696 const fixed = trueAddress >= 0x1000 ? trueAddress - 0x1000 : trueAddress697 const address = 0x400 + (fixed & 0x3FF)698 let allSBank = ((fixed & 0xE000) >> 13)699 if (allSBank < 3) {700 allSBank = 3701 }702 const fBank = allSBank <= 3 ? (fixed & 0x7C00) >> 10 : 0x18 + ((fixed & 0x1C00) >> 10)703 const sBank = trueAddress < BLOCK2_TRUE_ADDRESS_RANGES[BLOCK2_S3_START_INDEX].min ? undefined : allSBank704 return { bank: { fBank, sBank }, address }705 }706 asFixedCompleteAddress (trueAddress: number): number | undefined {707 const bankAndAddress = this.asBankAndAddress(trueAddress)708 if (bankAndAddress === undefined || bankAndAddress.bank.fBank === undefined) {709 return undefined710 }711 return bankAndAddress.bank.fBank << 10 | (bankAndAddress.address - 0x400)712 }713 /**714 * Returns the interpretive fixed complete address, used for interpretive indexing.715 * The true address must be in the same "half-memory" as the location counter.716 * The returned value is the same as the fixed complete address for "low" half-memory, and similar for "high"717 * half-memory but with the FBANK offset by -020.718 * See Ref BTM, section 2.2.3.719 * If the address is not in the same half-memory as the location counter, undefined is returned.720 *721 * @param locationCounter the location counter of the interpretive instruction722 * @param trueAddress the true address referenced by the IAW723 * @returns the interpretive fixed complete address724 */725 asInterpretiveFixedAddress (locationCounter: number, trueAddress: number): number | undefined {726 const locationBank = this.asBankAndAddress(locationCounter)?.bank.fBank727 const bankAndAddress = this.asBankAndAddress(trueAddress)728 const addressBank = bankAndAddress?.bank.fBank729 if (locationBank !== undefined && bankAndAddress !== undefined && addressBank !== undefined) {730 const locationLow = this.isLowMemoryInterpretive(locationBank)731 const addressLow = this.isLowMemoryInterpretive(addressBank)732 if (addressLow === undefined || addressLow !== locationLow) {733 return undefined734 }735 if (addressLow) {736 return addressBank << 10 | (bankAndAddress.address - 0x400)737 } else {738 return (addressBank - 16) << 10 | (bankAndAddress.address - 0x400)739 }740 }741 }742 private isLowMemoryInterpretive (fBank: number): boolean | undefined {743 if (fBank >= 4) {744 if (fBank <= 15) {745 return true746 }747 if (fBank >= 16 && fBank <= 35) {748 return false749 }750 }751 }752 hardwareModule (bank: number): number | undefined {753 if (!this.isFixedBank(bank)) {754 return undefined755 }756 return Math.floor((bank + this.moduleOffset) / 6) + 1757 }758 hardwareSide (sRegister: number): string {759 return (sRegister & 0x100) === 0 ? 'A' : 'B'760 }761 hardwareStick (bank: number): string | undefined {762 throw new Error('Unsupported operation')763 }764 hardwareStrand (bank: number, sRegister: number): number {765 return 2 * (bank % 6) + ((sRegister & 0x200) === 0 ? 0 : 1) + 1766 }767 hardwareWires (set: number): Range {768 const min = 1 + (set - 1) * 16769 const max = min + 15770 return { min, max }771 }...

Full Screen

Full Screen

S7RequestManager.js

Source:S7RequestManager.js Github

copy

Full Screen

1const S7Request = require("../../Request/S7Request/S7Request");2const RequestManager = require("../RequestManager");3class S7RequestManager extends RequestManager {4 //#region ========= PUBLIC STATIC METHODS =========5 /**6 * @description Method for grouping S7Variables that can be represented as one S7Request. Returns a List of lists: List<List<S7Variable>> reperesenting groups of variable7 * @param {Array} variables Array of variables8 */9 static groupS7Variables(variables) {10 /*11 * creating variables object to group variables12 * {13 * readGroup:14 * {15 * memoryType: {16 *17 * //If MemoryAreaType is DB18 * dbNumber:19 * {20 * sampleTime: [] <-- array containing all variables ordered by offset21 * }22 *23 * // Memory area type is not DB24 * sampleTime: [] <-- array containing all variables ordered by offset25 *26 * }27 * },28 * writeGroup:29 * {30 * memoryType: {31 *32 * //If MemoryAreaType is DB33 * dbNumber:34 * {35 * sampleTime: [] <-- array containing all variables ordered by offset36 * }37 *38 * // Memory area type is not DB39 * sampleTime: [] <-- array containing all variables ordered by offset40 *41 * }42 * }43 * readSeperately: [] <-- array containing all variables that should be read seperately44 * writeSeperately: [] <-- array containing all variables that should be write seperately45 * }46 *47 */48 let variablesObject = {49 read: {},50 write: {},51 readSeperately: [],52 writeSeperately: [],53 };54 for (let variable of variables) {55 //#region variable for reading56 if (variable.Read) {57 if (variable.ReadSeperately) {58 variablesObject.readSeperately.push(variable);59 } else {60 let memoryType = variable.MemoryType;61 let sampleTime = variable.SampleTime;62 if (memoryType === "DB") {63 //for memory type of DB64 let dbNumber = variable.DBNumber;65 if (!variablesObject.read[memoryType])66 variablesObject.read[memoryType] = {};67 if (!variablesObject.read[memoryType][dbNumber])68 variablesObject.read[memoryType][dbNumber] = {};69 if (!variablesObject.read[memoryType][dbNumber][sampleTime])70 variablesObject.read[memoryType][dbNumber][sampleTime] = [];71 variablesObject.read[memoryType][dbNumber][sampleTime].push(72 variable73 );74 variablesObject.read[memoryType][dbNumber][sampleTime].sort(75 (var1, var2) => var1.Offset - var2.Offset76 );77 } else {78 //for memory type not DB79 if (!variablesObject.read[memoryType])80 variablesObject.read[memoryType] = {};81 if (!variablesObject.read[memoryType][sampleTime])82 variablesObject.read[memoryType][sampleTime] = [];83 variablesObject.read[memoryType][sampleTime].push(variable);84 variablesObject.read[memoryType][sampleTime].sort(85 (var1, var2) => var1.Offset - var2.Offset86 );87 }88 }89 }90 //#endregion variable for reading91 //#region variable for writing92 else if (variable.Write) {93 if (variable.WriteSeperately) {94 variablesObject.writeSeperately.push(variable);95 } else {96 let memoryType = variable.MemoryType;97 let sampleTime = variable.SampleTime;98 if (memoryType === "DB") {99 //for memory type of DB100 let dbNumber = variable.DBNumber;101 if (!variablesObject.write[memoryType])102 variablesObject.write[memoryType] = {};103 if (!variablesObject.write[memoryType][dbNumber])104 variablesObject.write[memoryType][dbNumber] = {};105 if (!variablesObject.write[memoryType][dbNumber][sampleTime])106 variablesObject.write[memoryType][dbNumber][sampleTime] = [];107 variablesObject.write[memoryType][dbNumber][sampleTime].push(108 variable109 );110 variablesObject.write[memoryType][dbNumber][sampleTime].sort(111 (var1, var2) => var1.Offset - var2.Offset112 );113 } else {114 //for memory type not DB115 if (!variablesObject.write[memoryType])116 variablesObject.write[memoryType] = {};117 if (!variablesObject.write[memoryType][sampleTime])118 variablesObject.write[memoryType][sampleTime] = [];119 variablesObject.write[memoryType][sampleTime].push(variable);120 variablesObject.write[memoryType][sampleTime].sort(121 (var1, var2) => var1.Offset - var2.Offset122 );123 }124 }125 }126 //#endregion variable for writing127 }128 let allGroups = [];129 //Creating groups for all single read variables130 for (let variable of variablesObject.readSeperately) {131 let group = [variable];132 allGroups.push(group);133 }134 //Creating groups for all single write variables135 for (let variable of variablesObject.writeSeperately) {136 let group = [variable];137 allGroups.push(group);138 }139 //Creating groups for all read variables140 for (let memoryType of Object.keys(variablesObject.read)) {141 if (memoryType === "DB") {142 //for memory type DB143 for (let dbNumber of Object.keys(variablesObject.read[memoryType])) {144 for (let sampleTime of Object.keys(145 variablesObject.read[memoryType][dbNumber]146 )) {147 let group = [];148 let actualOffset = 0;149 //For each variable - create groups if there is a gap between offsets of variables150 let variablesLength =151 variablesObject.read[memoryType][dbNumber][sampleTime].length;152 for (let index = 0; index < variablesLength; index++) {153 let actualVariable =154 variablesObject.read[memoryType][dbNumber][sampleTime][index];155 //For first variable - actual offset should be initialized156 if (index === 0) {157 group.push(actualVariable);158 actualOffset = actualVariable.Offset + actualVariable.Length;159 } else {160 //For other variables - if there is a gap - assign old group to allGroups and create new one161 //Added > sign - if variable is overlapped it should also be in this group162 if (actualVariable.Offset > actualOffset) {163 allGroups.push(group);164 group = [actualVariable];165 actualOffset = actualVariable.Offset + actualVariable.Length;166 } else {167 group.push(actualVariable);168 //if actualOffset is longer than variable length + actualVariableOffset (overlapped shorter variable inside longer one)169 let newOffset = actualVariable.Offset + actualVariable.Length;170 if (newOffset > actualOffset) actualOffset = newOffset;171 }172 }173 //For last variable - actual groups should be pushed to all groups174 if (index === variablesLength - 1) {175 allGroups.push(group);176 }177 }178 }179 }180 } else {181 //for memory type not DB182 for (let sampleTime of Object.keys(variablesObject.read[memoryType])) {183 let group = [];184 let actualOffset = 0;185 //For each variable - create groups if there is a gap between offsets of variables186 let variablesLength =187 variablesObject.read[memoryType][sampleTime].length;188 for (let index = 0; index < variablesLength; index++) {189 let actualVariable =190 variablesObject.read[memoryType][sampleTime][index];191 //For first variable - actual offset should be initialized192 if (index === 0) {193 group.push(actualVariable);194 actualOffset = actualVariable.Offset + actualVariable.Length;195 } else {196 //For other variables - if there is a gap - assign old group to allGroups and create new one197 //Added > sign - if variable is overlapped it should also be in this group198 if (actualVariable.Offset > actualOffset) {199 allGroups.push(group);200 group = [actualVariable];201 actualOffset = actualVariable.Offset + actualVariable.Length;202 } else {203 group.push(actualVariable);204 //if actualOffset is longer than variable length + actualVariableOffset (overlapped shorter variable inside longer one)205 let newOffset = actualVariable.Offset + actualVariable.Length;206 if (newOffset > actualOffset) actualOffset = newOffset;207 }208 }209 //For last variable - actual groups should be pushed to all groups210 if (index === variablesLength - 1) {211 allGroups.push(group);212 }213 }214 }215 }216 }217 //Creating groups for all write variables218 for (let memoryType of Object.keys(variablesObject.write)) {219 if (memoryType === "DB") {220 //for memory type DB221 for (let dbNumber of Object.keys(variablesObject.write[memoryType])) {222 for (let sampleTime of Object.keys(223 variablesObject.write[memoryType][dbNumber]224 )) {225 let group = [];226 let actualOffset = 0;227 //For each variable - create groups if there is a gap between offsets of variables228 let variablesLength =229 variablesObject.write[memoryType][dbNumber][sampleTime].length;230 for (let index = 0; index < variablesLength; index++) {231 let actualVariable =232 variablesObject.write[memoryType][dbNumber][sampleTime][index];233 //For first variable - actual offset should be initialized234 if (index === 0) {235 group.push(actualVariable);236 actualOffset = actualVariable.Offset + actualVariable.Length;237 } else {238 //For other variables - if there is a gap - assign old group to allGroups and create new one239 //Added > sign - if variable is overlapped it should also be in this group240 if (actualVariable.Offset > actualOffset) {241 allGroups.push(group);242 group = [actualVariable];243 actualOffset = actualVariable.Offset + actualVariable.Length;244 } else {245 group.push(actualVariable);246 //if actualOffset is longer than variable length + actualVariableOffset (overlapped shorter variable inside longer one)247 let newOffset = actualVariable.Offset + actualVariable.Length;248 if (newOffset > actualOffset) actualOffset = newOffset;249 }250 }251 //For last variable - actual groups should be pushed to all groups252 if (index === variablesLength - 1) {253 allGroups.push(group);254 }255 }256 }257 }258 } else {259 //for memory type not DB260 for (let sampleTime of Object.keys(variablesObject.write[memoryType])) {261 let group = [];262 let actualOffset = 0;263 //For each variable - create groups if there is a gap between offsets of variables264 let variablesLength =265 variablesObject.write[memoryType][sampleTime].length;266 for (let index = 0; index < variablesLength; index++) {267 let actualVariable =268 variablesObject.write[memoryType][sampleTime][index];269 //For first variable - actual offset should be initialized270 if (index === 0) {271 group.push(actualVariable);272 actualOffset = actualVariable.Offset + actualVariable.Length;273 } else {274 //For other variables - if there is a gap - assign old group to allGroups and create new one275 //Added > sign - if variable is overlapped it should also be in this group276 if (actualVariable.Offset > actualOffset) {277 allGroups.push(group);278 group = [actualVariable];279 actualOffset = actualVariable.Offset + actualVariable.Length;280 } else {281 group.push(actualVariable);282 //if actualOffset is longer than variable length + actualVariableOffset (overlapped shorter variable inside longer one)283 let newOffset = actualVariable.Offset + actualVariable.Length;284 if (newOffset > actualOffset) actualOffset = newOffset;285 }286 }287 //For last variable - actual groups should be pushed to all groups288 if (index === variablesLength - 1) {289 allGroups.push(group);290 }291 }292 }293 }294 }295 return allGroups;296 }297 //#endregion ========= PUBLIC STATIC METHODS =========298 //#region ========= OVERRIDE PUBLIC METHODS =========299 /**300 * @description Method for creating requests out of collection of variables.301 * @param {Array} variables collection of variable to create request from302 */303 async createRequests(variables) {304 this._requests = [];305 let groupedVariables = S7RequestManager.groupS7Variables(variables);306 for (let group of groupedVariables) {307 if (group.length > 0) {308 //Getting properties for request from first variable from group309 let sampleTime = group[0].SampleTime;310 let memoryType = group[0].MemoryType;311 let writeRequest = !group[0].Read;312 let dbNumber = memoryType === "DB" ? group[0].DBNumber : null;313 let request = new S7Request(314 group,315 sampleTime,316 writeRequest,317 memoryType,318 dbNumber319 );320 this.Requests.push(request);321 }322 }323 }324 //#endregion ========= OVERRIDE PUBLIC METHODS =========325}...

Full Screen

Full Screen

productsFactory.js

Source:productsFactory.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.ProductsFactory = exports.MemoryType = void 0;4const products_1 = require("./DAOs/Mongo/products");5/**6 *7 * Different types of memory storage8 *9 */10var MemoryType;11(function (MemoryType) {12 MemoryType["MongoAtlas"] = "Mongo-Atlas";13 MemoryType["LocalMongo"] = "Local-Mongo";14})(MemoryType = exports.MemoryType || (exports.MemoryType = {}));15/**16 *17 *18 * Factory of Products DAOs19 *20 * This class will return the selected type of memory storage21 *22 *23 */24class ProductsFactory {25 static get(type) {26 switch (type) {27 case MemoryType.MongoAtlas:28 console.log(`Using MongoAtlas`);29 return new products_1.MongoProducts('atlas');30 case MemoryType.LocalMongo:31 console.log(`Using Local Mongo`);32 return new products_1.MongoProducts('local');33 default:34 console.log(`DEFAULT: MongoAtlas`);35 return new products_1.MongoProducts('atlas');36 }37 }38}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getTesters(function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9wpt.getLocations(function(err, data) {10 if (err) return console.error(err);11 console.log(data);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15wpt.getTesters(function(err, data) {16 if (err) return console.error(err);17 console.log(data);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.getTesters(function(err, data) {22 if (err) return console.error(err);23 console.log(data);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27wpt.getTesters(function(err, data) {28 if (err) return console.error(err);29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.getTesters(function(err, data) {34 if (err) return console.error(err);35 console.log(data);36});37var wpt = require('webpagetest');38var wpt = new WebPageTest('www.webpagetest.org');39wpt.getTesters(function(err, data) {40 if (err) return console.error(err);41 console.log(data);42});43var wpt = require('webpag

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getMemoryType(function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test Results: %j', data);6 wpt.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test Results: %j', data);9 });10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13}, function(err, data) {14 if (err) return console.error(err);15 console.log('Test Results: %j', data);16 wpt.getTestResults(data.data.testId, function(err, data) {17 if (err) return console.error(err);18 console.log('Test Results: %j', data);19 });20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23}, function(err, data) {24 if (err) return console.error(err);25 console.log('Test Results: %j', data);26 wpt.getTestResults(data.data.testId, function(err, data) {27 if (err) return console.error(err);28 console.log('Test Results: %j', data);29 });30});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webpagetest = new wpt('API_KEY');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test Response: %j', data);6 webpagetest.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test Results: %j', data);9 });10});11var wpt = require('webpagetest');12var webpagetest = new wpt('API_KEY');13}, function(err, data) {14 if (err) return console.error(err);15 console.log('Test Response: %j', data);16 webpagetest.getTestResults(data.data.testId, function(err, data) {17 if (err) return console.error(err);18 console.log('Test Results: %j', data);19 });20});21var wpt = require('webpagetest');22var webpagetest = new wpt('API_KEY');23}, function(err, data) {24 if (err) return console.error(err);25 console.log('Test Response: %j', data);26 webpagetest.getTestResults(data.data.testId, function(err, data) {27 if (err) return console.error(err);28 console.log('Test Results: %j', data);29 });30});31var wpt = require('webpagetest');32var webpagetest = new wpt('API_KEY');33}, function(err, data) {34 if (err) return console.error(err);35 console.log('Test Response: %j', data);36 webpagetest.getTestResults(data.data.testId, function(err, data) {37 if (err) return console.error(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2}, function(err, data) {3 if (err) return console.error(err);4 console.log('Test status: ' + data.statusText);5 console.log('Test ID: ' + data.data.testId);6 console.log('Test URL: ' + data.data.summary);7 console.log('Test results: ' + data.data.runs[1].firstView.results);8 console.log('Test results: ' + data.data.runs[1].firstView.SpeedIndex);9 console.log('Test results: ' + data.data.runs[1].firstView.TTFB);10 console.log('Test results: ' + data.data.runs[1].firstView.render);11 console.log('Test results: ' + data.data.runs[1].firstView.fullyLoaded);12 console.log('Test results: ' + data.data.runs[1].firstView.bytesIn);13 console.log('Test results: ' + data.data.runs[1].firstView.bytesOut);14 console.log('Test results: ' + data.data.runs[1].firstView.requests);15 console.log('Test results: ' + data.data.runs[1].firstView.responses_200);16 console.log('Test results: ' + data.data.runs[1].firstView.responses_404);17 console.log('Test results: ' + data.data.runs[1].firstView.responses_other);18 console.log('Test results: ' + data.data.runs[1].firstView.result);19 console.log('Test results: ' + data.data.runs[1].firstView.loadTime);20 console.log('Test results: ' + data.data.runs[1].firstView.docTime);21 console.log('Test results: ' + data.data.runs[1].firstView.domTime);22 console.log('Test results: ' + data.data.runs[1].firstView.fullyLoaded);23 console.log('Test results: ' + data.data.runs[1].firstView.domElements);24 console.log('Test results: ' + data.data.runs[1].firstView

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('API_KEY');3webPageTest.getTestResults('TEST_ID', function(err, data) {4 var memoryType = data.data.median.firstView.memoryType;5 console.log(memoryType);6});7var wpt = require('webpagetest');8var webPageTest = new wpt('API_KEY');9webPageTest.getTestResults('TEST_ID', function(err, data) {10 var memoryType = data.data.median.firstView.memoryType;11 console.log(memoryType);12});13var wpt = require('webpagetest');14var webPageTest = new wpt('API_KEY');15webPageTest.getTestResults('TEST_ID', function(err, data) {16 var memoryType = data.data.median.firstView.memoryType;17 console.log(memoryType);18});19var wpt = require('webpagetest');20var webPageTest = new wpt('API_KEY');21webPageTest.getTestResults('TEST_ID', function(err, data) {22 var memoryType = data.data.median.firstView.memoryType;23 console.log(memoryType);24});25var wpt = require('webpagetest');26var webPageTest = new wpt('API_KEY');27webPageTest.getTestResults('TEST_ID', function(err, data) {28 var memoryType = data.data.median.firstView.memoryType;29 console.log(memoryType);30});31var wpt = require('webpagetest');32var webPageTest = new wpt('API_KEY');33webPageTest.getTestResults('TEST_ID', function(err, data) {34 var memoryType = data.data.median.firstView.memoryType;35 console.log(memoryType);36});37var wpt = require('webpagetest');38var webPageTest = new wpt('API_KEY');39webPageTest.getTestResults('TEST_ID', function(err, data) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('wptool');2var mem = new wptool.memorytype();3mem.set(1);4console.log(mem.get());5var wptool = require('wptool');6var mem = new wptool.memorytype();7mem.set(1);8console.log(mem.get());9var wptool = require('wptool');10var mem = new wptool.memorytype();11mem.set(1);12console.log(mem.get());13var wptool = require('wptool');14var mem = new wptool.memorytype();15mem.set(1);16console.log(mem.get());17var wptool = require('wptool');18var mem = new wptool.memorytype();19mem.set(1);20console.log(mem.get());21var wptool = require('wptool');22var mem = new wptool.memorytype();23mem.set(1);24console.log(mem.get());25var wptool = require('wptool');26var mem = new wptool.memorytype();27mem.set(1);28console.log(mem.get());29var wptool = require('wptool');30var mem = new wptool.memorytype();31mem.set(1);32console.log(mem.get());33var wptool = require('wptool');34var mem = new wptool.memorytype();35mem.set(1);36console.log(mem.get());

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

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

Run wpt automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful