Best JavaScript code snippet using wpt
index.js
Source:index.js
...3Object.defineProperty(exports, "__esModule", {4 value: true5});6exports["default"] = void 0;7function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }8function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }9function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }10var Canvas = /*#__PURE__*/_createClass(function Canvas(container) {11 _classCallCheck(this, Canvas);12 // конÑÐµÐ¹Ð½ÐµÑ ÐºÑда вÑÑавлÑем ÐºÐ°Ð½Ð²Ð°Ñ 13 this.element = document.createElement('canvas');14 this.context = this.element.getContext('2d');15 this.element.width = 320;16 this.element.height = 400;17 container.appendChild(this.element); // ÑазмеÑаем на ÑÑÑ18});19exports["default"] = Canvas;20"use strict";21Object.defineProperty(exports, "__esModule", {22 value: true23});24exports["default"] = void 0;25function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }26function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }27function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }28// ÐаÑÑÑйоки обÑекÑа29var Config = /*#__PURE__*/_createClass(function Config() {30 _classCallCheck(this, Config);31 this.step = 0;32 this.maxStep = 15;33 this.sizeCell = 16;34 this.sizePoint = 16 / 4;35});36exports["default"] = Config;37"use strict";38var _canvas = _interopRequireDefault(require("./canvas.js"));39var _gameCycle = _interopRequireDefault(require("./gameCycle.js"));40var _snake = _interopRequireDefault(require("./snake.js"));41var _score = _interopRequireDefault(require("./score.js"));42var _point = _interopRequireDefault(require("./point.js"));43function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }44function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }45function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }46function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }47var Game = /*#__PURE__*/function () {48 function Game(container) {49 _classCallCheck(this, Game);50 // пеÑедаем в гейм Ð½Ð°Ñ ÐºÐ¾Ð½Ñейн51 this.canvas = new _canvas["default"](container);52 this.Snake = new _snake["default"]();53 this.Point = new _point["default"](this.canvas);54 this.Score = new _score["default"](".game-score .score-count", 0);55 new _gameCycle["default"](this.update.bind(this), this.draw.bind(this)); // (апдейÑ, оÑÑиÑовка канваÑ)56 }57 _createClass(Game, [{58 key: "update",59 value: function update() {60 this.Snake.update(this.Point, this.Score, this.canvas); // (поинÑ, оÑки, канваÑ)61 }62 }, {63 key: "draw",64 value: function draw() {65 this.canvas.context.clearRect(0, 0, this.canvas.element.width, this.canvas.element.height);66 this.Snake.draw(this.canvas.context);67 this.Point.draw(this.canvas.context);68 }69 }]);70 return Game;71}();72new Game(document.querySelector('.canvas-wrapper'));73"use strict";74Object.defineProperty(exports, "__esModule", {75 value: true76});77exports["default"] = void 0;78var _config = _interopRequireDefault(require("./config.js"));79function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }80function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }81function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }82function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }83//конÑÑоллиÑоваÑÑ ÑкоÑоÑÑÑ Ð¾ÑÑиÑовки84var GameCycle = /*#__PURE__*/function () {85 function GameCycle(update, draw) {86 _classCallCheck(this, GameCycle);87 //(изменение в игÑе, оÑÑиÑовка на ÑкÑане)88 this.update = update;89 this.draw = draw;90 this.config = new _config["default"]();91 this.animate = this.animate.bind(this);92 this.animate();93 }94 _createClass(GameCycle, [{95 key: "animate",96 value: function animate() {97 requestAnimationFrame(this.animate);98 if (++this.config.step < this.config.maxStep) {99 return;100 }101 this.config.step = 0;102 this.update();103 this.draw();104 }105 }]);106 return GameCycle;107}();108exports["default"] = GameCycle;109"use strict";110Object.defineProperty(exports, "__esModule", {111 value: true112});113exports["default"] = void 0;114var _config = _interopRequireDefault(require("./config.js"));115var _supportFunc = require("./supportFunc.js");116function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }117function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }118function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }119function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }120var Point = /*#__PURE__*/function () {121 function Point(canvas) {122 _classCallCheck(this, Point);123 this.x = 0;124 this.y = 0;125 this.canvas = canvas;126 this.Config = new _config["default"]();127 this.randomPosition();128 }129 _createClass(Point, [{130 key: "draw",131 value: function draw(context) {132 context.fillStyle = "#FFFFFF";133 context.fillRect(this.x, this.y, 15, 15);134 context.fill();135 }136 }, {137 key: "randomPosition",138 value: function randomPosition() {139 this.x = (0, _supportFunc.getRandomInt)(0, this.canvas.element.width / this.Config.sizeCell) * this.Config.sizeCell;140 this.y = (0, _supportFunc.getRandomInt)(0, this.canvas.element.height / this.Config.sizeCell) * this.Config.sizeCell;141 }142 }]);143 return Point;144}();145exports["default"] = Point;146"use strict";147Object.defineProperty(exports, "__esModule", {148 value: true149});150exports["default"] = void 0;151function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }152function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }153function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }154var Score = /*#__PURE__*/function () {155 function Score(scoreBlock) {156 var score = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;157 _classCallCheck(this, Score);158 this.scoreBlock = document.querySelector(scoreBlock);159 this.score = score;160 this.draw();161 }162 _createClass(Score, [{163 key: "incScore",164 value: function incScore() {165 this.score++;166 this.draw();167 }168 }, {169 key: "setToZero",170 value: function setToZero() {171 this.score = 0;172 this.draw();173 }174 }, {175 key: "draw",176 value: function draw() {177 this.scoreBlock.innerHTML = this.score;178 }179 }]);180 return Score;181}();182exports["default"] = Score;183"use strict";184Object.defineProperty(exports, "__esModule", {185 value: true186});187exports["default"] = void 0;188var _config = _interopRequireDefault(require("./config.js"));189function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }190function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }191function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }192function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }193var Snake = /*#__PURE__*/function () {194 function Snake() {195 _classCallCheck(this, Snake);196 this.config = new _config["default"]();197 this.x = 160;198 this.y = 160;199 this.dx = this.config.sizeCell; // ÑкоÑоÑÑÑ200 this.dy = 0;201 this.tails = []; // маÑÑив ÑÑеек под конÑÑолем 202 this.maxTails = 4; // кол-во ÑÑеек203 this.control();204 }205 _createClass(Snake, [{206 key: "update",...
bundle.js
Source:bundle.js
...38 if (!(instance instanceof Constructor)) {39 throw new TypeError("Cannot call a class as a function");40 }41 }42 function _defineProperties(target, props) {43 for (var i = 0; i < props.length; i++) {44 var descriptor = props[i];45 descriptor.enumerable = descriptor.enumerable || false;46 descriptor.configurable = true;47 if ("value" in descriptor) descriptor.writable = true;48 Object.defineProperty(target, descriptor.key, descriptor);49 }50 }51 function _createClass(Constructor, protoProps, staticProps) {52 if (protoProps) _defineProperties(Constructor.prototype, protoProps);53 if (staticProps) _defineProperties(Constructor, staticProps);54 return Constructor;55 }56 var Classroom =57 /*#__PURE__*/58 function () {59 function Classroom() {60 _classCallCheck(this, Classroom);61 }62 _createClass(Classroom, [{63 key: "test",64 value: function test() {65 var root = document.getElementById('root');66 var node = document.createElement("div");67 node.innerText = 'Classroom';68 root.appendChild(node);69 }70 }]);71 return Classroom;72 }();73 exports["default"] = Classroom;74 },75 {},76 ], 2: [77 function (require, module, exports) {78 "use strict";79 Object.defineProperty(exports, "__esModule", {80 value: true81 });82 exports["default"] = void 0;83 function _classCallCheck(instance, Constructor) {84 if (!(instance instanceof Constructor)) {85 throw new TypeError("Cannot call a class as a function");86 }87 }88 function _defineProperties(target, props) {89 for (var i = 0; i < props.length; i++) {90 var descriptor = props[i];91 descriptor.enumerable = descriptor.enumerable || false;92 descriptor.configurable = true;93 if ("value" in descriptor) descriptor.writable = true;94 Object.defineProperty(target, descriptor.key, descriptor);95 }96 }97 function _createClass(Constructor, protoProps, staticProps) {98 if (protoProps) _defineProperties(Constructor.prototype, protoProps);99 if (staticProps) _defineProperties(Constructor, staticProps);100 return Constructor;101 }102 var Student =103 /*#__PURE__*/104 function () {105 function Student() {106 _classCallCheck(this, Student);107 }108 _createClass(Student, [{109 key: "test",110 value: function test() {111 var root = document.getElementById('root');112 var node = document.createElement("div");113 node.innerText = 'Student';114 root.appendChild(node);115 }116 }]);117 return Student;118 }();119 exports["default"] = Student;120 },121 {},122 ], 3: [123 function (require, module, exports) {124 "use strict";125 Object.defineProperty(exports, "__esModule", {126 value: true127 });128 exports["default"] = void 0;129 function _classCallCheck(instance, Constructor) {130 if (!(instance instanceof Constructor)) {131 throw new TypeError("Cannot call a class as a function");132 }133 }134 function _defineProperties(target, props) {135 for (var i = 0; i < props.length; i++) {136 var descriptor = props[i];137 descriptor.enumerable = descriptor.enumerable || false;138 descriptor.configurable = true;139 if ("value" in descriptor) descriptor.writable = true;140 Object.defineProperty(target, descriptor.key, descriptor);141 }142 }143 function _createClass(Constructor, protoProps, staticProps) {144 if (protoProps) _defineProperties(Constructor.prototype, protoProps);145 if (staticProps) _defineProperties(Constructor, staticProps);146 return Constructor;147 }148 var Teacher =149 /*#__PURE__*/150 function () {151 function Teacher() {152 _classCallCheck(this, Teacher);153 }154 _createClass(Teacher, [{155 key: "test",156 value: function test() {157 var root = document.getElementById('root');158 var node = document.createElement("div");159 node.innerText = 'Teacher';...
Using AI Code Generation
1var obj = {};2Object._defineProperties(obj, {3 property1: {4 },5 property2: {6 }7});8console.log(obj.property1);9console.log(obj.property2);10console.log(obj.property2 = 'World');11var obj = {};12Object._defineProperty(obj, 'property1', {13});14console.log(obj.property1);15obj.property1 = 77;16console.log(obj.property1);17var obj = {18};19var descriptor1 = Object._getOwnPropertyDescriptor(obj, 'property1');20console.log(descriptor1.configurable);21console.log(descriptor1.value);22var obj = {23 property2: {}24};25var descriptors1 = Object._getOwnPropertyDescriptors(obj);26console.log(descriptors1.property1.value);27console.log(descriptors1.property1.enumerable);28console.log(descriptors1.property2.value);29var obj = {30};31console.log(Object._getOwnPropertyNames(obj));32var obj = {};33var a = Symbol('a');34var b = Symbol.for('b');35obj[a] = 'localSymbol';36obj[b] = 'globalSymbol';37var objectSymbols = Object._getOwnPropertySymbols(obj);38console.log(objectSymbols.length);39console.log(objectSymbols);40console.log(objectSymbols[0]);41function Rectangle()
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest(options, function(err, data) {6 if (err) {7 return console.log(err);8 }9 console.log('Test ID: ' + data.data.testId);10 wpt.getTestResults(data.data.testId, function(err, data) {11 if (err) {12 return console.log(err);13 }14 console.log(data);15 });16});17{ statusCode: 200,18 { testId: '160408_1M_7e6c31a8a3f6b3b6e9c6c1f8c1d6d2c7',
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt._defineProperties = function (obj, properties) {4 for (var i in properties) {5 if (properties.hasOwnProperty(i)) {6 obj[i] = properties[i];7 }8 }9 return obj;10};11var test = {12};13wpt.runTest(test, function(err, data) {14 if (err) return console.error(err);15 console.log(data);16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org');19wpt._defineProperties = function (obj, properties) {20 for (var i in properties) {21 if (properties.hasOwnProperty(i)) {22 obj[i] = properties[i];23 }24 }25 return obj;26};27var test = {28};29wpt.runTest(test, function(err, data) {30 if (err) return console.error(err);31 console.log(data);32});33var wpt = require('webpagetest');34var wpt = new WebPageTest('www.webpagetest.org');35wpt._defineProperties = function (obj, properties) {36 for (var i in properties) {37 if (properties.hasOwnProperty(i)) {38 obj[i] = properties[i];39 }40 }41 return obj;42};43var test = {44};45wpt.runTest(test, function(err, data) {46 if (err) return console.error(err);47 console.log(data);48});49var wpt = require('webpagetest
Using AI Code Generation
1var wptools = require('wptools');2var _defineProperties = wptools._defineProperties;3function Person(name, age) {4 _defineProperties(this, {5 name: {6 },7 age: {8 }9 });10}11var p = new Person('John', 24);
Using AI Code Generation
1define(["wpt"], function(wpt) {2 var obj = {};3 wpt._defineProperties(obj, {4 "prop1": {5 }6 });7});8(function() {9 var wpt = window.wpt = window.wpt || {};10 wpt._defineProperties = function(obj, props) {11 var prop;12 for (prop in props) {13 if (props.hasOwnProperty(prop)) {14 Object.defineProperty(obj, prop, props[prop]);15 }16 }17 };18})();19define(["wpt"], function(wpt) {20 var obj = {};21 wpt._defineProperties(obj, {22 "prop1": {23 }24 });25});26define(["wpt"], function(wpt) {27 wpt._defineProperties = function(obj, props) {
Using AI Code Generation
1var wpt = require('webpagetest');2var util = require('util');3var wpt = new WebPageTest('www.webpagetest.org');4var properties = {5};6var callbacks = {7 onDone: function(data) {8 console.log('onDone');9 console.log(data);10 },11 onWait: function(data) {12 console.log('onWait');13 console.log(data);14 },15 onError: function(err) {16 console.log('onError');17 console.log(err);18 },19 onConsole: function(msg) {20 console.log('onConsole');21 console.log(msg);22 }23};24 console.log('runTest callback');25 console.log(data);26});27 console.log('runTest callback');28 console.log(data);29});30wpt.getTestResults('140119_2Q_2e2b1d8d2f6c7f7e0c0a0d0e0f0b0c0f', function(err, data) {31 console.log('getTestResults');32 console.log(data);33});34wpt.getTestResults('140119_2Q_2e2b1d8d2f6c7f7e0c0a0d0e0f0b0c0f', callbacks);35wpt.getTestResults('140119_2Q_2e2b1d8d2f6c7f7e0c0a0d0e0f0b0c0f', properties, function(err, data) {36 console.log('getTestResults');37 console.log(data);38});39wpt.getTestResults('140119_2Q_2e
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 var info = resp.data;5 console.log(info);6});7var wptools = require('wptools');8var page = wptools.page('Albert Einstein');9page.get(function(err, resp) {10 var info = resp.data;11 console.log(info);12});13var wptools = require('wptools');14var page = wptools.page('Albert Einstein');15page.get(function(err, resp) {16 var info = resp.data;17 console.log(info);18});19var wptools = require('wptools');20var page = wptools.page('Albert Einstein');21page.get(function(err, resp) {22 var info = resp.data;23 console.log(info);24});25var wptools = require('wptools');26var page = wptools.page('Albert Einstein');27page.get(function(err, resp) {28 var info = resp.data;29 console.log(info);30});31var wptools = require('wptools');32var page = wptools.page('Albert Einstein');33page.get(function(err, resp) {34 var info = resp.data;35 console.log(info);36});37var wptools = require('wptools');38var page = wptools.page('Albert Einstein');39page.get(function(err, resp) {40 var info = resp.data;41 console.log(info);42});43var wptools = require('wptools');44var page = wptools.page('Albert Einstein');45page.get(function(err, resp) {46 var info = resp.data;47 console.log(info);48});
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!!