How to use startMeasure method in Best

Best JavaScript code snippet using best

liquid.js

Source:liquid.js Github

copy

Full Screen

1module.exports = function(Vex) {2 const log = (...args) =>3 Vex.Flow.DocumentFormatter.Liquid.DEBUG4 ? console.log('Vex.Flow.DocumentFormatter.Liquid', args)5 : null6 /**7 * Vex.Flow.DocumentFormatter.prototype.draw - defined in subclass8 * Render document inside HTML element, creating canvases, etc.9 * Called a second time to update as necessary if the width of the element10 * changes, etc.11 * @param {Node} HTML node to draw inside12 * @param {Object} Subclass-specific options13 */14 /**15 * Vex.Flow.DocumentFormatter.Liquid - default liquid formatter16 * Fit measures onto lines with a given width, in blocks of 1 line of music17 *18 * @constructor19 */20 Vex.Flow.DocumentFormatter.Liquid = function(document, options) {21 Vex.Flow.DocumentFormatter.call(this, document, options)22 this.width = 50023 this.zoom = 124 this.scale = 125 // TODO: Test scaling26 if (typeof window.devicePixelRatio == "number"27 && window.devicePixelRatio > 1) {28 this.scale = Math.floor(window.devicePixelRatio)29 }30 }31 Vex.Flow.DocumentFormatter.Liquid.DEBUG = false32 Vex.Flow.DocumentFormatter.Liquid.prototype = new Vex.Flow.DocumentFormatter()33 Vex.Flow.DocumentFormatter.Liquid.constructor =34 Vex.Flow.DocumentFormatter.Liquid35 Vex.Flow.DocumentFormatter.Liquid.prototype.setWidth = function(width) {36 this.width = width37 return this38 }39 Vex.Flow.DocumentFormatter.Liquid.prototype.getBlock = function(b, options = {}) {40 if (b in this.blockDimensions) return this.blockDimensions[b]41 let startMeasure = 042 if (b > 0) {43 this.getBlock(b - 1)44 let prevMeasures = this.measuresInBlock[b - 1]45 startMeasure = prevMeasures[prevMeasures.length - 1] + 146 }47 let numMeasures = this.document.getNumberOfMeasures()48 if (startMeasure >= numMeasures) return null49 // Default modifiers for first measure50 const defaultModifiers = ['clef', 'time', 'key']51 const modifiersPerStave = this.document52 .getMeasure(startMeasure)53 .getStaves()54 .map(s => defaultModifiers.reduce((obj, key) => {55 obj[key] = s[key]56 s.addDefaultModifiers()57 return obj58 }, {})59 )60 // Store x, width of staves (y calculated automatically)61 if (! this.measureX) this.measureX = []62 if (! this.measureWidth) this.measureWidth = []63 // Calculate start x64 let start_x = 065 // Add space for braces66 const parts = this.document.getMeasure(startMeasure).getParts()67 if (parts.length > 1) start_x = 1568 parts.forEach((part) => {69 if (part.showsBrace()) start_x = 1570 })71 let endMeasure = startMeasure72 const endPad = 1073 const minMeasureWidth = this.getMinMeasureWidth(startMeasure)74 + start_x + endPad75 if (minMeasureWidth >= this.width) {76 // Use only this measure and the minimum possible width77 let block = [minMeasureWidth, 0]78 this.blockDimensions[b] = block79 this.measuresInBlock[b] = [startMeasure]80 this.measureX[startMeasure] = start_x81 this.measureWidth[startMeasure] = block[0] - start_x - endPad82 } else {83 let curMeasure = startMeasure84 let width = start_x + endPad85 //log('CHECK MIN WIDTH', width, this.width)86 const isSame = (val1, val2) => {87 if (typeof val1==='string') return val1===val288 let same = true89 Object.keys(val1).forEach(k => {90 if (val1[k]!==val2[k]) same = false91 })92 return same93 }94 while (width < this.width && curMeasure < numMeasures) {95 // Remove automatic modifiers except for first measure96 // If there were any, invalidate the measure width97 if (curMeasure != startMeasure) {98 let keepDefaultModifier = {}99 this.document.getMeasure(curMeasure).getStaves().forEach((s, staveIndex) => {100 // Decide whether to keep: only if different from previous101 defaultModifiers.forEach(key => {102 if (!s[key]) return103 const inherit = modifiersPerStave[staveIndex][key]104 if (!inherit || !isSame(inherit, s[key])) {105 modifiersPerStave[staveIndex][key] = s[key]106 keepDefaultModifier[key] = true107 //log('KEY IS DIFFERENT', curMeasure, staveIndex, key, inherit, s[key])108 } else {109 keepDefaultModifier[key] = false110 //log('KEY IS SAME', curMeasure, staveIndex, key, inherit, s[key])111 }112 })113 defaultModifiers.forEach(key =>114 !keepDefaultModifier[key] && s.deleteModifier(key)115 )116 //log('DELETE MODIFIERS BEFORE', curMeasure, ...s.modifiers)117 if (s.deleteAutomaticModifiers()118 && this.minMeasureWidths119 && curMeasure in this.minMeasureWidths120 ) {121 delete this.minMeasureWidths[curMeasure]122 }123 })124 }125 width += this.getMinMeasureWidth(curMeasure)126 curMeasure++127 }128 endMeasure = curMeasure - 1129 let measureRange = []130 for (let m = startMeasure; m <= endMeasure; m++) measureRange.push(m)131 this.measuresInBlock[b] = measureRange132 // Allocate width to measures133 let remainingWidth = this.width - start_x - 10134 for (let m = startMeasure; m <= endMeasure; m++) {135 // Set each width to the minimum136 this.measureWidth[m] = Math.ceil(this.getMinMeasureWidth(m))137 remainingWidth -= this.measureWidth[m]138 }139 // Split rest of width evenly140 let extraWidth = Math.floor(remainingWidth / (endMeasure-startMeasure+1))141 for (let m = startMeasure; m <= endMeasure; m++)142 this.measureWidth[m] += extraWidth143 remainingWidth -= extraWidth * (endMeasure - startMeasure + 1)144 this.measureWidth[startMeasure] += remainingWidth // Add remainder145 // Calculate x value for each measure146 this.measureX[startMeasure] = start_x147 for (let m = startMeasure + 1; m <= endMeasure; m++)148 this.measureX[m] = this.measureX[m-1] + this.measureWidth[m-1]149 this.blockDimensions[b] = [this.width, 0]150 }151 // Calculate height of first measure152 let i = 0153 let lastStave = undefined154 let stave = this.getStave(startMeasure, 0)155 while (stave) {156 lastStave = stave157 i++158 stave = this.getStave(startMeasure, i)159 }160 let height = this.getStaveY(startMeasure, i-1)161 // Add max extra space for last stave on any measure in this block162 // Default: minimum height of stave // was 90163 // TODO: this.options.inline164 let maxExtraHeight = 60 // NOTE: Adds bottom pad165 for (let i = startMeasure; i <= endMeasure; i++) {166 let minHeights = this.getMinMeasureHeight(i)167 let extraHeight = minHeights[minHeights.length - 1]168 if (extraHeight > maxExtraHeight) maxExtraHeight = extraHeight169 }170 height += maxExtraHeight171 this.blockDimensions[b][1] = height172 console.log('getBlock', b, {173 maxExtraHeight,174 staveY: this.getStaveY(startMeasure, i-1),175 width: this.blockDimensions[b][0],176 height: this.blockDimensions[b][1]177 })178 return this.blockDimensions[b]179 }180 Vex.Flow.DocumentFormatter.Liquid.prototype.getStaveX = function(m, s) {181 if (! (m in this.measureX))182 throw new Vex.RERR("FormattingError",183 "Creating stave for measure which does not belong to a block")184 return this.measureX[m]185 }186 Vex.Flow.DocumentFormatter.Liquid.prototype.getStaveWidth = function(m, s) {187 if (! (m in this.measureWidth))188 throw new Vex.RERR("FormattingError",189 "Creating stave for measure which does not belong to a block")190 return this.measureWidth[m]191 }192 Vex.Flow.DocumentFormatter.Liquid.prototype.draw = function(elem, options = {}) {193 if (this._htmlElem != elem) {194 this._htmlElem = elem195 elem.innerHTML = ''196 this.canvases = []197 }198 const scale = options.scale || this.scale || 1199 const zoom = options.zoom || this.zoom || 1200 let canvasWidth = options.inline ? 0 : elem.offsetWidth //- 10201 let renderWidth = Math.floor(canvasWidth / zoom)202 //console.log('START DRAW', { elem, options, canvasWidth, renderWidth, zoom })203 // Invalidate all blocks/staves/voices204 this.minMeasureWidths = [] // heights don't change with stave modifiers205 this.measuresInBlock = []206 this.blockDimensions = []207 this.vfStaves = []208 this.measureX = []209 this.measureWidth = []210 this.setWidth(renderWidth)211 // TODO: Refactor to use a single canvas element for all blocks212 // Remove all non-canvas child nodes of element213 /*214 const children = elem.children215 for (let i = 0; i < children.length; i++) {216 const child = children[i]217 if (child.nodeName === 'CANVAS') continue218 elem.removeChild(child)219 }*/220 let b = 0221 while (this.getBlock(b, options)) {222 let canvas, context223 let dims = this.blockDimensions[b]224 let width = Math.ceil(dims[0] * zoom)225 let height = Math.ceil(dims[1] * zoom)226 if (! this.canvases[b]) {227 // Create new canvas for this block228 canvas = document.createElement('canvas')229 canvas.width = width * scale230 canvas.height = height * scale231 if (scale > 1) {232 canvas.style.width = width.toString() + "px"233 canvas.style.height = height.toString() + "px"234 }235 canvas.id = elem.id + "_canvas" + b.toString()236 // If a canvas exists after this one, insert before that canvas237 /*for (let a = b + 1; this.getBlock(a); a++) {238 if (typeof this.canvases[a] == "object") {239 elem.insertBefore(canvas, this.canvases[a])240 break241 }242 }*/243 if (! canvas.parentNode) {244 elem.appendChild(canvas) // Insert at the end of elem245 }246 this.canvases[b] = canvas247 context = Vex.Flow.Renderer.bolsterCanvasContext(canvas.getContext("2d"))248 } else {249 canvas = this.canvases[b]250 canvas.style.display = "inherit"251 canvas.width = width * scale252 canvas.height = height * scale253 if (scale > 1) {254 canvas.style.width = width.toString() + "px"255 canvas.style.height = height.toString() + "px"256 }257 context = Vex.Flow.Renderer.bolsterCanvasContext(canvas.getContext("2d"))258 context.clearRect(0, 0, canvas.width, canvas.height)259 }260 // TODO: Figure out why setFont method is called261 if (typeof context.setFont != "function") {262 context.setFont = function(font) { this.font = font; return this }263 }264 context.scale(zoom * scale, zoom * scale)265 /*console.log('Call draw block', b, {266 canvasWidth, renderWidth,267 scale, zoom, totalScale: scale * zoom,268 height: height * scale,269 width: width * scale270 })*/271 this.drawBlock(b, context) // --> formatter.drawBlock272 // Add anchor elements before canvas273 /*let lineAnchor = document.createElement("a")274 lineAnchor.id = elem.id + "_line" + (b+1).toString()275 elem.insertBefore(lineAnchor, canvas)276 this.measuresInBlock[b].forEach(function(m) {277 let anchor = elem.id + "_m" +278 this.document.getMeasureNumber(m).toString()279 let anchorElem = document.createElement("a")280 anchorElem.id = anchor281 elem.insertBefore(anchorElem, canvas)282 }, this)283 */284 b++285 }286 // Remove canvases beyond last287 while (typeof this.canvases[b] == "object") {288 elem.removeChild(this.canvases[b])289 delete this.canvases[b]290 b++291 }292 }...

Full Screen

Full Screen

RouteLocatorParametersTest.js

Source:RouteLocatorParametersTest.js Github

copy

Full Screen

1module("RouteLocatorParameters");2test("TestDefaultConstructor", function () {3 var routeLocatorParameters = new SuperMap.REST.RouteLocatorParameters();4 ok(routeLocatorParameters !== null, "routeLocatorParameters not null");5 equal(routeLocatorParameters.sourceRoute, null, "routeLocatorParameters.sourceRoute");6 equal(routeLocatorParameters.type, null, "routeLocatorParameters.type");7 equal(routeLocatorParameters.offset, 0, "routeLocatorParameters.offset");8 ok(!routeLocatorParameters.isIgnoreGap, "routeLocatorParameters.isIgnoreGap");9 equal(routeLocatorParameters.startMeasure, null, "routeLocatorParameters.startMeasure");10 equal(routeLocatorParameters.startMeasure, null, "routeLocatorParameters.startMeasure");11});12test("TestCustomConstructor", function () {13 var routeLocatorParameters_point = new SuperMap.REST.RouteLocatorParameters({14 "sourceRoute":{15 "type":"LINEM",16 "parts":[4],17 "points":[18 {19 "measure":0,20 "y":-6674.466867067764,21 "x":3817.352787613013322 },23 {24 "measure":199.57954019411724,25 "y":-6670.830929417594,26 "x":3617.80636990149627 },28 {29 "measure":609.3656478634477,30 "y":-6877.837541432356,31 "x":3264.149874667844432 },33 {34 "measure":936.0174126282958,35 "y":-7038.687780615184,36 "x":2979.84620606890337 }38 ]39 },40 "type":"POINT",41 "measure":10,42 "offset":3,43 "isIgnoreGap":true44 });45 var routeLocatorParameters_line = new SuperMap.REST.RouteLocatorParameters({46 "sourceRoute":{47 "type":"LINEM",48 "parts":[4],49 "points":[50 {51 "measure":0,52 "y":-6674.466867067764,53 "x":3817.352787613013354 },55 {56 "measure":199.57954019411724,57 "y":-6670.830929417594,58 "x":3617.80636990149659 },60 {61 "measure":609.3656478634477,62 "y":-6877.837541432356,63 "x":3264.149874667844464 },65 {66 "measure":936.0174126282958,67 "y":-7038.687780615184,68 "x":2979.84620606890369 }70 ]71 },72 "type":"LINE",73 "startMeasure":150,74 "endMeasure":240,75 "isIgnoreGap":true76 });77 ok(routeLocatorParameters_point !== null, "routeLocatorParameters_point not null");78 ok(routeLocatorParameters_line !== null, "routeLocatorParameters_line not null");79 equal(routeLocatorParameters_point.sourceRoute.type, "LINEM", "routeLocatorParameters_point.sourceRoute.type");80 equal(routeLocatorParameters_line.sourceRoute.type, "LINEM", "routeLocatorParameters_line.sourceRoute.type");81 equal(routeLocatorParameters_point.type, "POINT", "routeLocatorParameters_point.type");82 equal(routeLocatorParameters_line.type, "LINE", "routeLocatorParameters_line.type");83 equal(routeLocatorParameters_point.offset, 3, "routeLocatorParameters_point.offset");84 equal(routeLocatorParameters_line.offset, 0, "routeLocatorParameters_line.offset");85 ok(routeLocatorParameters_point.isIgnoreGap, "routeLocatorParameters_point.isIgnoreGap");86 ok(routeLocatorParameters_line.isIgnoreGap, "routeLocatorParameters_line.isIgnoreGap");87 equal(routeLocatorParameters_point.startMeasure, null, "routeLocatorParameters_point.startMeasure");88 equal(routeLocatorParameters_line.startMeasure, 150, "routeLocatorParameters_line.startMeasure");89 equal(routeLocatorParameters_point.startMeasure, null, "routeLocatorParameters_point.startMeasure");90 equal(routeLocatorParameters_line.endMeasure, 240, "routeLocatorParameters_line.startMeasure");91});92test("TestDefaultConstructor_destroy", function () {93 var routeLocatorParameters = new SuperMap.REST.RouteLocatorParameters();94 routeLocatorParameters.destroy();95 ok(routeLocatorParameters !== null, "routeLocatorParameters not null");96 equal(routeLocatorParameters.sourceRoute, null, "routeLocatorParameters.sourceRoute");97 equal(routeLocatorParameters.type, null, "routeLocatorParameters.type");98 equal(routeLocatorParameters.offset, 0, "routeLocatorParameters.offset");99 ok(!routeLocatorParameters.isIgnoreGap, "routeLocatorParameters.isIgnoreGap");100 equal(routeLocatorParameters.startMeasure, null, "routeLocatorParameters.startMeasure");101 equal(routeLocatorParameters.startMeasure, null, "routeLocatorParameters.startMeasure");102});103test("TestCustomConstructor", function () {104 var routeLocatorParameters_point = new SuperMap.REST.RouteLocatorParameters({105 "sourceRoute":{106 "type":"LINEM",107 "parts":[4],108 "points":[109 {110 "measure":0,111 "y":-6674.466867067764,112 "x":3817.3527876130133113 },114 {115 "measure":199.57954019411724,116 "y":-6670.830929417594,117 "x":3617.806369901496118 },119 {120 "measure":609.3656478634477,121 "y":-6877.837541432356,122 "x":3264.1498746678444123 },124 {125 "measure":936.0174126282958,126 "y":-7038.687780615184,127 "x":2979.846206068903128 }129 ]130 },131 "type":"POINT",132 "measure":10,133 "offset":3,134 "isIgnoreGap":true135 });136 var routeLocatorParameters_line = new SuperMap.REST.RouteLocatorParameters({137 "sourceRoute":{138 "type":"LINEM",139 "parts":[4],140 "points":[141 {142 "measure":0,143 "y":-6674.466867067764,144 "x":3817.3527876130133145 },146 {147 "measure":199.57954019411724,148 "y":-6670.830929417594,149 "x":3617.806369901496150 },151 {152 "measure":609.3656478634477,153 "y":-6877.837541432356,154 "x":3264.1498746678444155 },156 {157 "measure":936.0174126282958,158 "y":-7038.687780615184,159 "x":2979.846206068903160 }161 ]162 },163 "type":"LINE",164 "startMeasure":150,165 "endMeasure":240,166 "isIgnoreGap":true167 });168 routeLocatorParameters_point.destroy();169 routeLocatorParameters_line.destroy();170 ok(routeLocatorParameters_point !== null, "routeLocatorParameters_point not null");171 equal(routeLocatorParameters_point.sourceRoute, null, "routeLocatorParameters_point.sourceRoute");172 equal(routeLocatorParameters_point.type, null, "routeLocatorParameters_point.type");173 equal(routeLocatorParameters_point.offset, 0, "routeLocatorParameters_point.offset");174 ok(!routeLocatorParameters_point.isIgnoreGap, "routeLocatorParameters_point.isIgnoreGap");175 equal(routeLocatorParameters_point.startMeasure, null, "routeLocatorParameters_point.startMeasure");176 equal(routeLocatorParameters_point.startMeasure, null, "routeLocatorParameters_point.startMeasure");177 ok(routeLocatorParameters_line !== null, "routeLocatorParameters_line not null");178 equal(routeLocatorParameters_line.sourceRoute, null, "routeLocatorParameters_line.sourceRoute");179 equal(routeLocatorParameters_line.type, null, "routeLocatorParameters_line.type");180 equal(routeLocatorParameters_line.offset, 0, "routeLocatorParameters_line.offset");181 ok(!routeLocatorParameters_line.isIgnoreGap, "routeLocatorParameters_line.isIgnoreGap");182 equal(routeLocatorParameters_line.startMeasure, null, "routeLocatorParameters_line.startMeasure");183 equal(routeLocatorParameters_line.startMeasure, null, "routeLocatorParameters_line.startMeasure");...

Full Screen

Full Screen

main-app.js

Source:main-app.js Github

copy

Full Screen

...158 break;159 }160 }161 selectOne(id, target) {162 startMeasure('select');163 this.selectedId = id;164 store.select(id);165 this.selectedNode ? this.selectedNode.classList.remove('danger') : void 0;166 this.selectedNode = target.parentElement.parentElement;167 this.selectedNode.classList.add('danger');168 stopMeasure('select');169 }170 deleteOne(id) {171 startMeasure('delete');172 store.delete(id);173 this.selectedNode ? this.selectedNode.classList.remove('danger') : void 0;174 this.selectedNode = null;175 this.items = store.data;176 stopMeasure();177 }178 update10() {179 startMeasure('update');180 store.update();181 this.items = [...store.data];182 stopMeasure();183 }184 185 testClear() {186 startMeasure('clear');187 store.clear();188 this.items = store.data;189 stopMeasure();190 }191 192 append1k() {193 startMeasure('add');194 store.add(1000);195 this.items = store.data;196 stopMeasure();197 }198 199 swap() {200 startMeasure('swap');201 store.swapRows();202 this.items = store.data;203 stopMeasure();204 }205 206 create10k() {207 store.clear();208 store.runLots();209 startMeasure('runLots');210 this.items = store.data;211 stopMeasure();212 }213 create1k() {214 store.clear();215 store.run(1000);216 startMeasure('run');217 this.items = store.data;218 stopMeasure();219 }220}...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import { h, mount, patch } from "petit-dom"2import { Store } from "./store"3var store = new Store()4function startMeasure(name, meth) {5 meth.call(store)6 updateView()7}8var runAction = () => startMeasure("run", store.run)9var runLotsAction = () => startMeasure("runLots", store.runLots)10var addAction = () => startMeasure("add", store.add)11var updateAction = () => startMeasure("update", store.update)12var clearAction = () => startMeasure("clear", store.clear)13var swapRowsAction = () => startMeasure("swapRows", store.swapRows)14var selectAction = id => () => {15 store.select(id)16 updateView()17}18var deleteAction = id => () => {19 store.delete(id)20 updateView()21}22function updateView() {23 var vel2 = render()24 patch(vel2, vel)25 vel = vel226}27var main = document.getElementById("main")...

Full Screen

Full Screen

react1.js

Source:react1.js Github

copy

Full Screen

...39 )40 ,document.getElementById('root'));41}42const add = () => {43 startMeasure("add");44 start = performance.now();45 let data = state.data.concat(buildData(100));46 setState({'data':data})47 // render();48 printDuration();49}50const update = () => {51 startMeasure("update");52 start = performance.now();53 let data = state.data;54 for (let i = 0;i < data.length;i += 10) {55 data[i].label += ' !!!';56 }57 setState({'data':data})58 printDuration();59}60const run = () => {61 startMeasure("run");62 start = performance.now();63 let data = buildData(5000);64 setState({'data':data});65 printDuration();66};67const runLots = () => {68 startMeasure("runLots");69 start = performance.now();70 let data = buildData(1000);71 setState({'data':data});72 printDuration();73};74const clearA = () => {75 startMeasure("clear");76 start = performance.now();77 setState({'data':[]})78 printDuration();79};80const swapRows = ()=> {81 startMeasure("swapRows");82 let data = state.data;83 if(data.length) {84 var a = data[1];85 data[1] = data[data.length-1];86 data[data.length-1] = a;87 }88 setState({'data':data});89 printDuration();90};91const updateStyle = () => {92 startMeasure("updateStyle");93 start = performance.now();94 setState({'styleObj':{fontWeight: 'bold'}})95 printDuration();96}97run();98add();99updateStyle();100swapRows();101update();...

Full Screen

Full Screen

angular.js

Source:angular.js Github

copy

Full Screen

...32 const _random = (max) => {33 return Math.round(Math.random() * 1000) % max;34 };35 $scope.add = () => {36 startMeasure("add");37 start = performance.now();38 $scope.names = $scope.names.concat(buildData(100));39 printDuration();40 }41 $scope.update = () => {42 startMeasure("update");43 start = performance.now();44 for (let i=0;i<$scope.names.length;i+=10) {45 $scope.names[i].label += ' !!!';46 }47 printDuration();48 }49 $scope.updateStyle = () => {50 startMeasure("updateStyle");51 start = performance.now();52 $scope.styleObj = {'font-weight':'bold' }53 printDuration();54 }55 $scope.run = () => {56 startMeasure("run");57 start = performance.now();58 $scope.names = buildData(5000);59 printDuration();60 };61 $scope.runLots = () => {62 startMeasure("runLots");63 start = performance.now();64 $scope.names = buildData(1000);65 printDuration();66 };67 $scope.clear = () => {68 startMeasure("clear");69 start = performance.now();70 $scope.names = [];71 printDuration();72 };73 74 $scope.swapRows = ()=> {75 startMeasure("swapRows");76 if($scope.names.length) {77 var a = $scope.names[1];78 $scope.names[1] = $scope.names[$scope.names.length-1];79 $scope.names[$scope.names.length-1] = a;80 }81 printDuration();82 };83 $scope.run();84 $scope.add();85 $scope.updateStyle();86 $scope.swapRows();87 $scope.update();88 $scope.clear();89});

Full Screen

Full Screen

krause-bench.js

Source:krause-bench.js Github

copy

Full Screen

...22 did = 123 selected2425 add() {26 startMeasure('add')27 this.data = this.data.concat(this.buildData(1000))28 stopMeasure()29 }3031 run() {32 startMeasure('run')33 this.data = this.buildData(1000)34 stopMeasure()35 }3637 runLots() {38 startMeasure('runLots')39 this.data = this.buildData(10000)40 stopMeasure()41 }4243 clear() {44 startMeasure('clear')45 this.data = []46 stopMeasure()47 }4849 del(e) {50 startMeasure('delete')51 let index = this.data.indexOf(e.currentTarget.item)52 this.data.splice(index, 1)53 stopMeasure()54 }5556 select(e) {57 startMeasure('select')58 this.selected = e.currentTarget.item.id59 stopMeasure()60 }6162 swapRows() {63 startMeasure('swapRows')64 if (this.data.length > 998) {65 var tmp = this.data[1];66 this.data[1] = this.data[998];67 this.data[998] = tmp;68 this.data = this.data.slice()69 }70 stopMeasure()71 }7273 update() {74 startMeasure('update')75 for (let i = 0; i < this.data.length; i += 10) {76 this.data[i].label = this.data[i].label + ' !!!'77 }78 stopMeasure()79 }808182 buildData(count) {83 let adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy']84 let colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange']85 let nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard']86 let data = []87 for (let i = 0; i < count; i++) {88 data.push({ id: this.did++, label: adjectives[this._random(adjectives.length)] + ' ' + colours[this._random(colours.length)] + ' ' + nouns[this._random(nouns.length)] }) ...

Full Screen

Full Screen

template.js

Source:template.js Github

copy

Full Screen

1"use strict";2// javascript code3// script_name: INSERT NAME4//5// author: YOUR NAME6// description: This is a template7//8// INITIALIZE THE SCRIPT AT THE BEGINNING9init();10// SET TEMPO (aka the speed at which a piece of music is played measured in beats per minute)11setTempo(200);12// assign meaningful variable names and get the value of each sound you want13var drumA = RD_UK_HOUSE__WARMPIANO_1;14var drumB = RD_UK_HOUSE__SQUAREPAD_2;15var bassA = RD_UK_HOUSE__ARPPLUCK_1;16var bassB = RD_UK_HOUSE_ACOUSTICGUITAR_3;17// CONSIDER defining a custom beat (to be used later in a for loop)18// This will look like a string, where 19// 0 <= start of beat (equal to a 16th note or 1/16th of a measure/phrase)20// + <= continued beat21// - <= end or no beat22var drumBeat = "--------0+0+0+0+";23// define new functions with input parameters to set the start and end measures24function sectionA(startMeasure, endMeasure) {25 fitMedia(drumA, 1, startMeasure, endMeasure);26 fitMedia(bassA, 2, startMeasure, endMeasure);27}28function sectionB(startMeasure, endMeasure) {29 fitMedia(drumB, 3, startMeasure, endMeasure);30 fitMedia(bassB, 4, startMeasure, endMeasure);31 // CONSIDER a for loop to loop through beats, which enables you to control the style and rhythm of your sound32 /*33 for (var i = measureBeg; i < measureEnd; i++) {34 makeBeat(drum, 5, i, drumBeat);35 }36 */37}38// Call the functions and pass in the desired start and end measure values (TIP: DO NOT OVERLAP CHANNELS)39sectionA(1, 5);40sectionB(5, 9);41sectionA(9, 13);42sectionB(13, 17);43// Make sure to end your program!...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestTime = require('./bestTime');2var bestTimeObj = new bestTime();3bestTimeObj.startMeasure();4bestTimeObj.stopMeasure();5console.log('Best Time: ' + bestTimeObj.getBestTime());6console.log('Worst Time: ' + bestTimeObj.getWorstTime());7console.log('Average Time: ' + bestTimeObj.getAverageTime());

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPerformance = require('./BestPerformance.js');2var bestPerformance = new BestPerformance();3bestPerformance.startMeasure();4bestPerformance.endMeasure();5var result = bestPerformance.getMeasure();6console.log('Time taken to execute code in test4.js file is ' + result + ' milliseconds');

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestTime = require('./BestTime');2bestTime.startMeasure();3setTimeout(function(){4bestTime.stopMeasure();5}, 5000);6var startTime = 0;7var stopTime = 0;8var elapsedTime = 0;9var BestTime = function(){10 this.startMeasure = function(){11 startTime = new Date();12 };13 this.stopMeasure = function(){14 stopTime = new Date();15 elapsedTime = stopTime - startTime;16 console.log(elapsedTime);17 };18};19module.exports = new BestTime();20var bestTime = require('./BestTime');21bestTime.startMeasure();22setTimeout(function(){23bestTime.stopMeasure();24}, 5000);25var startTime = 0;26var stopTime = 0;27var elapsedTime = 0;28var BestTime = function(){29 this.startMeasure = function(){30 startTime = new Date();31 };32 this.stopMeasure = function(){33 stopTime = new Date();34 elapsedTime = stopTime - startTime;35 console.log(elapsedTime);36 };37};38module.exports = BestTime;39var BestTime = require('./BestTime');40var bestTime = new BestTime();41bestTime.startMeasure();42setTimeout(function(){43bestTime.stopMeasure();44}, 5000);45var startTime = 0;46var stopTime = 0;47var elapsedTime = 0;48var BestTime = function(){49 this.startMeasure = function(){50 startTime = new Date();51 };52 this.stopMeasure = function(){53 stopTime = new Date();54 elapsedTime = stopTime - startTime;55 console.log(elapsedTime);56 };57};58module.exports = BestTime;59var BestTime = require('./BestTime');60var bestTime = new BestTime();61bestTime.startMeasure();62setTimeout(function(){63bestTime.stopMeasure();64}, 5000);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMeasure = require('./BestMeasure.js');2var myBestMeasure = new BestMeasure();3myBestMeasure.startMeasure(50, 0.5);4var BestMeasure = require('./BestMeasure.js');5var myBestMeasure = new BestMeasure();6myBestMeasure.startMeasure(50, 0.5);7var BestMeasure = function() {8 this.startMeasure = function(temp, humidity) {9 console.log('Temperature: ' + temp + ' Humidity: ' + humidity);10 }11}12module.exports = BestMeasure;13module.exports.getTemp = function() {14 return 50;15}16var BestMeasure = require('./BestMeasure.js');17var myBestMeasure = new BestMeasure();18myBestMeasure.startMeasure(50, 0.5);19var BestMeasure = require('./BestMeasure.js');20var myBestMeasure = new BestMeasure();21myBestMeasure.startMeasure(50, 0.5);22var BestMeasure = require('./BestMeasure.js');23console.log(BestMeasure.getTemp());

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestTime = require('BestTime');2var bestTime = new BestTime();3bestTime.startMeasure('test4.js');4var test4 = require('test4');5var result = test4.getSum(1, 2);6bestTime.endMeasure('test4.js');7console.log(result);8var BestTime = require('BestTime');9var bestTime = new BestTime();10bestTime.startMeasure('test5.js');11var test5 = require('test5');12var result = test5.getSum(1, 2);13bestTime.endMeasure('test5.js');14console.log(result);15var BestTime = require('BestTime');16var bestTime = new BestTime();17bestTime.startMeasure('test6.js');18var test6 = require('test6');19var result = test6.getSum(1, 2);20bestTime.endMeasure('test6.js');21console.log(result);

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 Best 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