Best JavaScript code snippet using wpt
app.js
Source:app.js
1var express = require('express');2var app = express();3var data = [4 { id: 1, color: "brown", disposition: "closed" },5 { id: 2, color: "yellow", disposition: "open" },6 { id: 3, color: "brown", disposition: "closed" },7 { id: 4, color: "brown", disposition: "open" },8 { id: 5, color: "red", disposition: "closed" },9 { id: 6, color: "blue", disposition: "open" },10 { id: 7, color: "green", disposition: "closed" },11 { id: 8, color: "green", disposition: "open" },12 { id: 9, color: "brown", disposition: "closed" },13 { id: 10, color: "red", disposition: "open" },14 { id: 11, color: "blue", disposition: "closed" },15 { id: 12, color: "yellow", disposition: "open" },16 { id: 13, color: "green", disposition: "open" },17 { id: 14, color: "yellow", disposition: "open" },18 { id: 15, color: "blue", disposition: "closed" },19 { id: 16, color: "blue", disposition: "closed" },20 { id: 17, color: "blue", disposition: "closed" },21 { id: 18, color: "green", disposition: "open" },22 { id: 19, color: "yellow", disposition: "open" },23 { id: 20, color: "brown", disposition: "closed" },24 { id: 21, color: "green", disposition: "closed" },25 { id: 22, color: "red", disposition: "closed" },26 { id: 23, color: "red", disposition: "open" },27 { id: 24, color: "red", disposition: "open" },28 { id: 25, color: "red", disposition: "open" },29 { id: 26, color: "red", disposition: "closed" },30 { id: 27, color: "brown", disposition: "closed" },31 { id: 28, color: "blue", disposition: "open" },32 { id: 29, color: "brown", disposition: "closed" },33 { id: 30, color: "blue", disposition: "closed" },34 { id: 31, color: "red", disposition: "open" },35 { id: 32, color: "blue", disposition: "open" },36 { id: 33, color: "yellow", disposition: "open" },37 { id: 34, color: "red", disposition: "open" },38 { id: 35, color: "blue", disposition: "open" },39 { id: 36, color: "green", disposition: "closed" },40 { id: 37, color: "green", disposition: "open" },41 { id: 38, color: "blue", disposition: "open" },42 { id: 39, color: "green", disposition: "closed" },43 { id: 40, color: "red", disposition: "closed" },44 { id: 41, color: "brown", disposition: "open" },45 { id: 42, color: "brown", disposition: "closed" },46 { id: 43, color: "green", disposition: "closed" },47 { id: 44, color: "blue", disposition: "closed" },48 { id: 45, color: "blue", disposition: "closed" },49 { id: 46, color: "yellow", disposition: "closed" },50 { id: 47, color: "green", disposition: "open" },51 { id: 48, color: "red", disposition: "closed" },52 { id: 49, color: "blue", disposition: "closed" },53 { id: 50, color: "blue", disposition: "open" },54 { id: 51, color: "green", disposition: "open" },55 { id: 52, color: "yellow", disposition: "open" },56 { id: 53, color: "yellow", disposition: "closed" },57 { id: 54, color: "red", disposition: "open" },58 { id: 55, color: "brown", disposition: "open" },59 { id: 56, color: "brown", disposition: "closed" },60 { id: 57, color: "blue", disposition: "open" },61 { id: 58, color: "brown", disposition: "closed" },62 { id: 59, color: "red", disposition: "open" },63 { id: 60, color: "brown", disposition: "closed" },64 { id: 61, color: "brown", disposition: "open" },65 { id: 62, color: "yellow", disposition: "closed" },66 { id: 63, color: "yellow", disposition: "open" },67 { id: 64, color: "yellow", disposition: "closed" },68 { id: 65, color: "green", disposition: "closed" },69 { id: 66, color: "blue", disposition: "open" },70 { id: 67, color: "green", disposition: "closed" },71 { id: 68, color: "brown", disposition: "open" },72 { id: 69, color: "blue", disposition: "closed" },73 { id: 70, color: "brown", disposition: "closed" },74 { id: 71, color: "green", disposition: "closed" },75 { id: 72, color: "green", disposition: "closed" },76 { id: 73, color: "blue", disposition: "closed" },77 { id: 74, color: "yellow", disposition: "closed" },78 { id: 75, color: "red", disposition: "closed" },79 { id: 76, color: "red", disposition: "open" },80 { id: 77, color: "blue", disposition: "closed" },81 { id: 78, color: "red", disposition: "closed" },82 { id: 79, color: "blue", disposition: "closed" },83 { id: 80, color: "blue", disposition: "open" },84 { id: 81, color: "brown", disposition: "closed" },85 { id: 82, color: "green", disposition: "closed" },86 { id: 83, color: "blue", disposition: "open" },87 { id: 84, color: "brown", disposition: "open" },88 { id: 85, color: "green", disposition: "open" },89 { id: 86, color: "yellow", disposition: "closed" },90 { id: 87, color: "yellow", disposition: "open" },91 { id: 88, color: "green", disposition: "open" },92 { id: 89, color: "yellow", disposition: "open" },93 { id: 90, color: "blue", disposition: "closed" },94 { id: 91, color: "brown", disposition: "closed" },95 { id: 92, color: "brown", disposition: "closed" },96 { id: 93, color: "brown", disposition: "closed" },97 { id: 94, color: "blue", disposition: "open" },98 { id: 95, color: "green", disposition: "open" },99 { id: 96, color: "green", disposition: "closed" },100 { id: 97, color: "red", disposition: "closed" },101 { id: 98, color: "yellow", disposition: "closed" },102 { id: 99, color: "brown", disposition: "open" },103 { id: 100, color: "red", disposition: "open" },104 { id: 101, color: "yellow", disposition: "closed" },105 { id: 102, color: "yellow", disposition: "closed" },106 { id: 103, color: "blue", disposition: "open" },107 { id: 104, color: "yellow", disposition: "closed" },108 { id: 105, color: "green", disposition: "open" },109 { id: 106, color: "yellow", disposition: "open" },110 { id: 107, color: "brown", disposition: "open" },111 { id: 108, color: "red", disposition: "open" },112 { id: 109, color: "green", disposition: "open" },113 { id: 110, color: "brown", disposition: "closed" },114 { id: 111, color: "brown", disposition: "open" },115 { id: 112, color: "yellow", disposition: "open" },116 { id: 113, color: "blue", disposition: "open" },117 { id: 114, color: "yellow", disposition: "open" },118 { id: 115, color: "green", disposition: "closed" },119 { id: 116, color: "red", disposition: "open" },120 { id: 117, color: "blue", disposition: "open" },121 { id: 118, color: "blue", disposition: "open" },122 { id: 119, color: "yellow", disposition: "closed" },123 { id: 120, color: "brown", disposition: "open" },124 { id: 121, color: "blue", disposition: "open" },125 { id: 122, color: "red", disposition: "open" },126 { id: 123, color: "brown", disposition: "open" },127 { id: 124, color: "red", disposition: "closed" },128 { id: 125, color: "blue", disposition: "open" },129 { id: 126, color: "yellow", disposition: "open" },130 { id: 127, color: "brown", disposition: "closed" },131 { id: 128, color: "red", disposition: "open" },132 { id: 129, color: "green", disposition: "closed" },133 { id: 130, color: "green", disposition: "open" },134 { id: 131, color: "red", disposition: "open" },135 { id: 132, color: "red", disposition: "closed" },136 { id: 133, color: "blue", disposition: "closed" },137 { id: 134, color: "yellow", disposition: "closed" },138 { id: 135, color: "brown", disposition: "closed" },139 { id: 136, color: "red", disposition: "open" },140 { id: 137, color: "blue", disposition: "closed" },141 { id: 138, color: "yellow", disposition: "closed" },142 { id: 139, color: "red", disposition: "open" },143 { id: 140, color: "yellow", disposition: "open" },144 { id: 141, color: "red", disposition: "open" },145 { id: 142, color: "red", disposition: "closed" },146 { id: 143, color: "red", disposition: "closed" },147 { id: 144, color: "green", disposition: "closed" },148 { id: 145, color: "yellow", disposition: "closed" },149 { id: 146, color: "green", disposition: "closed" },150 { id: 147, color: "brown", disposition: "closed" },151 { id: 148, color: "yellow", disposition: "open" },152 { id: 149, color: "red", disposition: "closed" },153 { id: 150, color: "green", disposition: "closed" },154 { id: 151, color: "brown", disposition: "open" },155 { id: 152, color: "yellow", disposition: "open" },156 { id: 153, color: "yellow", disposition: "closed" },157 { id: 154, color: "yellow", disposition: "closed" },158 { id: 155, color: "yellow", disposition: "closed" },159 { id: 156, color: "brown", disposition: "closed" },160 { id: 157, color: "green", disposition: "closed" },161 { id: 158, color: "green", disposition: "closed" },162 { id: 159, color: "brown", disposition: "open" },163 { id: 160, color: "green", disposition: "closed" },164 { id: 161, color: "red", disposition: "closed" },165 { id: 162, color: "blue", disposition: "open" },166 { id: 163, color: "green", disposition: "open" },167 { id: 164, color: "red", disposition: "open" },168 { id: 165, color: "red", disposition: "closed" },169 { id: 166, color: "yellow", disposition: "closed" },170 { id: 167, color: "blue", disposition: "open" },171 { id: 168, color: "green", disposition: "closed" },172 { id: 169, color: "green", disposition: "open" },173 { id: 170, color: "green", disposition: "open" },174 { id: 171, color: "blue", disposition: "open" },175 { id: 172, color: "blue", disposition: "closed" },176 { id: 173, color: "green", disposition: "closed" },177 { id: 174, color: "brown", disposition: "open" },178 { id: 175, color: "red", disposition: "closed" },179 { id: 176, color: "red", disposition: "closed" },180 { id: 177, color: "brown", disposition: "closed" },181 { id: 178, color: "brown", disposition: "open" },182 { id: 179, color: "red", disposition: "open" },183 { id: 180, color: "brown", disposition: "closed" },184 { id: 181, color: "green", disposition: "open" },185 { id: 182, color: "green", disposition: "closed" },186 { id: 183, color: "blue", disposition: "open" },187 { id: 184, color: "blue", disposition: "closed" },188 { id: 185, color: "blue", disposition: "closed" },189 { id: 186, color: "blue", disposition: "closed" },190 { id: 187, color: "brown", disposition: "closed" },191 { id: 188, color: "yellow", disposition: "open" },192 { id: 189, color: "red", disposition: "closed" },193 { id: 190, color: "brown", disposition: "open" },194 { id: 191, color: "green", disposition: "closed" },195 { id: 192, color: "red", disposition: "open" },196 { id: 193, color: "green", disposition: "closed" },197 { id: 194, color: "brown", disposition: "closed" },198 { id: 195, color: "brown", disposition: "closed" },199 { id: 196, color: "yellow", disposition: "closed" },200 { id: 197, color: "blue", disposition: "closed" },201 { id: 198, color: "green", disposition: "closed" },202 { id: 199, color: "yellow", disposition: "closed" },203 { id: 200, color: "green", disposition: "open" },204 { id: 201, color: "brown", disposition: "closed" },205 { id: 202, color: "blue", disposition: "closed" },206 { id: 203, color: "red", disposition: "open" },207 { id: 204, color: "green", disposition: "closed" },208 { id: 205, color: "brown", disposition: "closed" },209 { id: 206, color: "brown", disposition: "open" },210 { id: 207, color: "brown", disposition: "open" },211 { id: 208, color: "blue", disposition: "closed" },212 { id: 209, color: "brown", disposition: "closed" },213 { id: 210, color: "blue", disposition: "open" },214 { id: 211, color: "green", disposition: "closed" },215 { id: 212, color: "yellow", disposition: "open" },216 { id: 213, color: "blue", disposition: "open" },217 { id: 214, color: "red", disposition: "closed" },218 { id: 215, color: "red", disposition: "open" },219 { id: 216, color: "yellow", disposition: "open" },220 { id: 217, color: "yellow", disposition: "open" },221 { id: 218, color: "green", disposition: "open" },222 { id: 219, color: "green", disposition: "open" },223 { id: 220, color: "green", disposition: "open" },224 { id: 221, color: "yellow", disposition: "open" },225 { id: 222, color: "red", disposition: "closed" },226 { id: 223, color: "green", disposition: "closed" },227 { id: 224, color: "blue", disposition: "closed" },228 { id: 225, color: "yellow", disposition: "closed" },229 { id: 226, color: "yellow", disposition: "open" },230 { id: 227, color: "red", disposition: "open" },231 { id: 228, color: "blue", disposition: "open" },232 { id: 229, color: "yellow", disposition: "open" },233 { id: 230, color: "blue", disposition: "closed" },234 { id: 231, color: "green", disposition: "open" },235 { id: 232, color: "blue", disposition: "open" },236 { id: 233, color: "yellow", disposition: "closed" },237 { id: 234, color: "yellow", disposition: "closed" },238 { id: 235, color: "brown", disposition: "open" },239 { id: 236, color: "red", disposition: "closed" },240 { id: 237, color: "blue", disposition: "closed" },241 { id: 238, color: "red", disposition: "closed" },242 { id: 239, color: "yellow", disposition: "open" },243 { id: 240, color: "blue", disposition: "open" },244 { id: 241, color: "red", disposition: "open" },245 { id: 242, color: "yellow", disposition: "closed" },246 { id: 243, color: "blue", disposition: "open" },247 { id: 244, color: "yellow", disposition: "open" },248 { id: 245, color: "yellow", disposition: "open" },249 { id: 246, color: "red", disposition: "closed" },250 { id: 247, color: "yellow", disposition: "open" },251 { id: 248, color: "green", disposition: "open" },252 { id: 249, color: "yellow", disposition: "closed" },253 { id: 250, color: "green", disposition: "open" },254 { id: 251, color: "blue", disposition: "open" },255 { id: 252, color: "blue", disposition: "open" },256 { id: 253, color: "green", disposition: "open" },257 { id: 254, color: "green", disposition: "open" },258 { id: 255, color: "yellow", disposition: "open" },259 { id: 256, color: "red", disposition: "open" },260 { id: 257, color: "blue", disposition: "open" },261 { id: 258, color: "blue", disposition: "open" },262 { id: 259, color: "red", disposition: "open" },263 { id: 260, color: "brown", disposition: "open" },264 { id: 261, color: "yellow", disposition: "open" },265 { id: 262, color: "green", disposition: "closed" },266 { id: 263, color: "green", disposition: "open" },267 { id: 264, color: "blue", disposition: "closed" },268 { id: 265, color: "green", disposition: "closed" },269 { id: 266, color: "yellow", disposition: "open" },270 { id: 267, color: "yellow", disposition: "closed" },271 { id: 268, color: "green", disposition: "closed" },272 { id: 269, color: "red", disposition: "closed" },273 { id: 270, color: "blue", disposition: "closed" },274 { id: 271, color: "red", disposition: "open" },275 { id: 272, color: "yellow", disposition: "open" },276 { id: 273, color: "brown", disposition: "closed" },277 { id: 274, color: "red", disposition: "open" },278 { id: 275, color: "red", disposition: "open" },279 { id: 276, color: "yellow", disposition: "open" },280 { id: 277, color: "red", disposition: "open" },281 { id: 278, color: "blue", disposition: "closed" },282 { id: 279, color: "brown", disposition: "closed" },283 { id: 280, color: "brown", disposition: "open" },284 { id: 281, color: "brown", disposition: "closed" },285 { id: 282, color: "red", disposition: "open" },286 { id: 283, color: "blue", disposition: "closed" },287 { id: 284, color: "red", disposition: "closed" },288 { id: 285, color: "blue", disposition: "closed" },289 { id: 286, color: "red", disposition: "open" },290 { id: 287, color: "blue", disposition: "open" },291 { id: 288, color: "yellow", disposition: "open" },292 { id: 289, color: "red", disposition: "closed" },293 { id: 290, color: "red", disposition: "open" },294 { id: 291, color: "brown", disposition: "open" },295 { id: 292, color: "red", disposition: "closed" },296 { id: 293, color: "brown", disposition: "open" },297 { id: 294, color: "brown", disposition: "open" },298 { id: 295, color: "green", disposition: "closed" },299 { id: 296, color: "red", disposition: "closed" },300 { id: 297, color: "brown", disposition: "closed" },301 { id: 298, color: "green", disposition: "closed" },302 { id: 299, color: "brown", disposition: "closed" },303 { id: 300, color: "blue", disposition: "open" },304 { id: 301, color: "green", disposition: "closed" },305 { id: 302, color: "red", disposition: "closed" },306 { id: 303, color: "red", disposition: "open" },307 { id: 304, color: "yellow", disposition: "open" },308 { id: 305, color: "brown", disposition: "open" },309 { id: 306, color: "green", disposition: "open" },310 { id: 307, color: "brown", disposition: "closed" },311 { id: 308, color: "blue", disposition: "open" },312 { id: 309, color: "yellow", disposition: "open" },313 { id: 310, color: "yellow", disposition: "open" },314 { id: 311, color: "red", disposition: "closed" },315 { id: 312, color: "yellow", disposition: "open" },316 { id: 313, color: "red", disposition: "closed" },317 { id: 314, color: "blue", disposition: "open" },318 { id: 315, color: "green", disposition: "open" },319 { id: 316, color: "blue", disposition: "open" },320 { id: 317, color: "red", disposition: "closed" },321 { id: 318, color: "blue", disposition: "open" },322 { id: 319, color: "green", disposition: "closed" },323 { id: 320, color: "red", disposition: "closed" },324 { id: 321, color: "brown", disposition: "open" },325 { id: 322, color: "green", disposition: "open" },326 { id: 323, color: "yellow", disposition: "open" },327 { id: 324, color: "red", disposition: "closed" },328 { id: 325, color: "green", disposition: "closed" },329 { id: 326, color: "green", disposition: "closed" },330 { id: 327, color: "yellow", disposition: "open" },331 { id: 328, color: "yellow", disposition: "closed" },332 { id: 329, color: "brown", disposition: "open" },333 { id: 330, color: "brown", disposition: "closed" },334 { id: 331, color: "blue", disposition: "closed" },335 { id: 332, color: "brown", disposition: "open" },336 { id: 333, color: "blue", disposition: "closed" },337 { id: 334, color: "green", disposition: "open" },338 { id: 335, color: "brown", disposition: "closed" },339 { id: 336, color: "blue", disposition: "open" },340 { id: 337, color: "green", disposition: "open" },341 { id: 338, color: "green", disposition: "closed" },342 { id: 339, color: "green", disposition: "open" },343 { id: 340, color: "red", disposition: "open" },344 { id: 341, color: "yellow", disposition: "open" },345 { id: 342, color: "brown", disposition: "closed" },346 { id: 343, color: "red", disposition: "open" },347 { id: 344, color: "brown", disposition: "open" },348 { id: 345, color: "blue", disposition: "open" },349 { id: 346, color: "green", disposition: "open" },350 { id: 347, color: "yellow", disposition: "open" },351 { id: 348, color: "blue", disposition: "open" },352 { id: 349, color: "brown", disposition: "closed" },353 { id: 350, color: "green", disposition: "closed" },354 { id: 351, color: "blue", disposition: "closed" },355 { id: 352, color: "brown", disposition: "closed" },356 { id: 353, color: "blue", disposition: "closed" },357 { id: 354, color: "brown", disposition: "open" },358 { id: 355, color: "blue", disposition: "open" },359 { id: 356, color: "red", disposition: "open" },360 { id: 357, color: "green", disposition: "open" },361 { id: 358, color: "blue", disposition: "closed" },362 { id: 359, color: "brown", disposition: "open" },363 { id: 360, color: "red", disposition: "closed" },364 { id: 361, color: "brown", disposition: "open" },365 { id: 362, color: "green", disposition: "open" },366 { id: 363, color: "yellow", disposition: "open" },367 { id: 364, color: "blue", disposition: "open" },368 { id: 365, color: "green", disposition: "closed" },369 { id: 366, color: "blue", disposition: "closed" },370 { id: 367, color: "blue", disposition: "open" },371 { id: 368, color: "red", disposition: "open" },372 { id: 369, color: "green", disposition: "closed" },373 { id: 370, color: "red", disposition: "closed" },374 { id: 371, color: "brown", disposition: "closed" },375 { id: 372, color: "red", disposition: "open" },376 { id: 373, color: "yellow", disposition: "open" },377 { id: 374, color: "blue", disposition: "open" },378 { id: 375, color: "green", disposition: "open" },379 { id: 376, color: "yellow", disposition: "open" },380 { id: 377, color: "blue", disposition: "open" },381 { id: 378, color: "blue", disposition: "closed" },382 { id: 379, color: "green", disposition: "closed" },383 { id: 380, color: "green", disposition: "open" },384 { id: 381, color: "blue", disposition: "open" },385 { id: 382, color: "green", disposition: "open" },386 { id: 383, color: "blue", disposition: "closed" },387 { id: 384, color: "blue", disposition: "closed" },388 { id: 385, color: "brown", disposition: "closed" },389 { id: 386, color: "red", disposition: "closed" },390 { id: 387, color: "red", disposition: "closed" },391 { id: 388, color: "green", disposition: "open" },392 { id: 389, color: "brown", disposition: "open" },393 { id: 390, color: "green", disposition: "open" },394 { id: 391, color: "red", disposition: "closed" },395 { id: 392, color: "blue", disposition: "open" },396 { id: 393, color: "yellow", disposition: "closed" },397 { id: 394, color: "green", disposition: "open" },398 { id: 395, color: "yellow", disposition: "closed" },399 { id: 396, color: "red", disposition: "closed" },400 { id: 397, color: "red", disposition: "open" },401 { id: 398, color: "green", disposition: "open" },402 { id: 399, color: "brown", disposition: "open" },403 { id: 400, color: "yellow", disposition: "closed" },404 { id: 401, color: "brown", disposition: "closed" },405 { id: 402, color: "yellow", disposition: "closed" },406 { id: 403, color: "red", disposition: "closed" },407 { id: 404, color: "blue", disposition: "open" },408 { id: 405, color: "brown", disposition: "open" },409 { id: 406, color: "blue", disposition: "open" },410 { id: 407, color: "blue", disposition: "closed" },411 { id: 408, color: "yellow", disposition: "open" },412 { id: 409, color: "green", disposition: "closed" },413 { id: 410, color: "red", disposition: "open" },414 { id: 411, color: "green", disposition: "open" },415 { id: 412, color: "green", disposition: "open" },416 { id: 413, color: "blue", disposition: "closed" },417 { id: 414, color: "blue", disposition: "open" },418 { id: 415, color: "yellow", disposition: "open" },419 { id: 416, color: "brown", disposition: "closed" },420 { id: 417, color: "red", disposition: "closed" },421 { id: 418, color: "green", disposition: "open" },422 { id: 419, color: "green", disposition: "open" },423 { id: 420, color: "yellow", disposition: "closed" },424 { id: 421, color: "green", disposition: "open" },425 { id: 422, color: "red", disposition: "open" },426 { id: 423, color: "yellow", disposition: "open" },427 { id: 424, color: "green", disposition: "closed" },428 { id: 425, color: "green", disposition: "open" },429 { id: 426, color: "blue", disposition: "closed" },430 { id: 427, color: "red", disposition: "closed" },431 { id: 428, color: "brown", disposition: "closed" },432 { id: 429, color: "green", disposition: "closed" },433 { id: 430, color: "red", disposition: "open" },434 { id: 431, color: "blue", disposition: "open" },435 { id: 432, color: "green", disposition: "open" },436 { id: 433, color: "yellow", disposition: "open" },437 { id: 434, color: "brown", disposition: "closed" },438 { id: 435, color: "yellow", disposition: "closed" },439 { id: 436, color: "red", disposition: "open" },440 { id: 437, color: "yellow", disposition: "closed" },441 { id: 438, color: "yellow", disposition: "closed" },442 { id: 439, color: "green", disposition: "closed" },443 { id: 440, color: "brown", disposition: "closed" },444 { id: 441, color: "blue", disposition: "open" },445 { id: 442, color: "red", disposition: "closed" },446 { id: 443, color: "brown", disposition: "closed" },447 { id: 444, color: "blue", disposition: "closed" },448 { id: 445, color: "red", disposition: "open" },449 { id: 446, color: "green", disposition: "closed" },450 { id: 447, color: "brown", disposition: "open" },451 { id: 448, color: "brown", disposition: "open" },452 { id: 449, color: "blue", disposition: "closed" },453 { id: 450, color: "blue", disposition: "closed" },454 { id: 451, color: "green", disposition: "open" },455 { id: 452, color: "yellow", disposition: "open" },456 { id: 453, color: "yellow", disposition: "closed" },457 { id: 454, color: "green", disposition: "closed" },458 { id: 455, color: "blue", disposition: "open" },459 { id: 456, color: "red", disposition: "closed" },460 { id: 457, color: "green", disposition: "open" },461 { id: 458, color: "blue", disposition: "closed" },462 { id: 459, color: "green", disposition: "open" },463 { id: 460, color: "green", disposition: "open" },464 { id: 461, color: "yellow", disposition: "open" },465 { id: 462, color: "green", disposition: "open" },466 { id: 463, color: "green", disposition: "open" },467 { id: 464, color: "red", disposition: "open" },468 { id: 465, color: "red", disposition: "open" },469 { id: 466, color: "blue", disposition: "closed" },470 { id: 467, color: "yellow", disposition: "open" },471 { id: 468, color: "blue", disposition: "closed" },472 { id: 469, color: "brown", disposition: "closed" },473 { id: 470, color: "green", disposition: "open" },474 { id: 471, color: "yellow", disposition: "closed" },475 { id: 472, color: "red", disposition: "open" },476 { id: 473, color: "red", disposition: "closed" },477 { id: 474, color: "yellow", disposition: "open" },478 { id: 475, color: "brown", disposition: "open" },479 { id: 476, color: "brown", disposition: "closed" },480 { id: 477, color: "red", disposition: "open" },481 { id: 478, color: "brown", disposition: "closed" },482 { id: 479, color: "brown", disposition: "open" },483 { id: 480, color: "blue", disposition: "open" },484 { id: 481, color: "blue", disposition: "open" },485 { id: 482, color: "red", disposition: "open" },486 { id: 483, color: "yellow", disposition: "closed" },487 { id: 484, color: "blue", disposition: "closed" },488 { id: 485, color: "blue", disposition: "closed" },489 { id: 486, color: "yellow", disposition: "open" },490 { id: 487, color: "green", disposition: "closed" },491 { id: 488, color: "brown", disposition: "open" },492 { id: 489, color: "brown", disposition: "closed" },493 { id: 490, color: "brown", disposition: "closed" },494 { id: 491, color: "red", disposition: "open" },495 { id: 492, color: "green", disposition: "closed" },496 { id: 493, color: "green", disposition: "closed" },497 { id: 494, color: "green", disposition: "closed" },498 { id: 495, color: "red", disposition: "closed" },499 { id: 496, color: "red", disposition: "closed" },500 { id: 497, color: "yellow", disposition: "closed" },501 { id: 498, color: "yellow", disposition: "closed" },502 { id: 499, color: "red", disposition: "closed" },503 { id: 500, color: "blue", disposition: "closed" }504 ];505506let pageCount =1;507let total = data.length;508app.get('/manage-records', function (req, res) {509 const pageId = req.query.pageId;510 const pagenumber = (pageId-1)*10;511 const tempData = data.slice(pagenumber,pageId*10);512513 const result={514 Ids: tempData.map(item=>item.id),515 Open:tempData.filter(item=>item.disposition === 'open'),516 ClosedCount:tempData.filter(item=>item.disposition === 'closed' && ['green','blue','red'].includes(item.color)).length,517 PreviousPage:pageId===1 ?null:pageId-1,518 NextPage:pageId===total ?null:parseInt(pageId)+1519 }520 res.send(result);521});522app.get('/records', function (req, res) {523 524 res.send(data);525});526app.listen(3000, function () {527 console.log('Example app listening on port 3000!');
...
ext-sessions.js
Source:ext-sessions.js
1/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */2/* vim: set sts=2 sw=2 et tw=80: */3/* This Source Code Form is subject to the terms of the Mozilla Public4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,5 * You can obtain one at http://mozilla.org/MPL/2.0/. */6"use strict";7var { ExtensionError, promiseObserved } = ExtensionUtils;8ChromeUtils.defineModuleGetter(9 this,10 "AddonManagerPrivate",11 "resource://gre/modules/AddonManager.jsm"12);13ChromeUtils.defineModuleGetter(14 this,15 "SessionStore",16 "resource:///modules/sessionstore/SessionStore.jsm"17);18const SS_ON_CLOSED_OBJECTS_CHANGED = "sessionstore-closed-objects-changed";19const getRecentlyClosed = (maxResults, extension) => {20 let recentlyClosed = [];21 // Get closed windows22 // Closed private windows are not stored in sessionstore, we do23 // not need to check access for that.24 let closedWindowData = SessionStore.getClosedWindowData(false);25 for (let window of closedWindowData) {26 recentlyClosed.push({27 lastModified: window.closedAt,28 window: Window.convertFromSessionStoreClosedData(extension, window),29 });30 }31 // Get closed tabs32 // Private closed tabs are in sessionstore if the owning window is still open .33 for (let window of windowTracker.browserWindows()) {34 if (!extension.canAccessWindow(window)) {35 continue;36 }37 let closedTabData = SessionStore.getClosedTabData(window, false);38 for (let tab of closedTabData) {39 recentlyClosed.push({40 lastModified: tab.closedAt,41 tab: Tab.convertFromSessionStoreClosedData(extension, tab, window),42 });43 }44 }45 // Sort windows and tabs46 recentlyClosed.sort((a, b) => b.lastModified - a.lastModified);47 return recentlyClosed.slice(0, maxResults);48};49const createSession = async function createSession(50 restored,51 extension,52 sessionId53) {54 if (!restored) {55 throw new ExtensionError(56 `Could not restore object using sessionId ${sessionId}.`57 );58 }59 let sessionObj = { lastModified: Date.now() };60 if (restored instanceof Ci.nsIDOMChromeWindow) {61 await promiseObserved(62 "sessionstore-single-window-restored",63 subject => subject == restored64 );65 sessionObj.window = extension.windowManager.convert(restored, {66 populate: true,67 });68 return sessionObj;69 }70 sessionObj.tab = extension.tabManager.convert(restored);71 return sessionObj;72};73const getEncodedKey = function getEncodedKey(extensionId, key) {74 // Throw if using a temporary extension id.75 if (AddonManagerPrivate.isTemporaryInstallID(extensionId)) {76 let message =77 "Sessions API storage methods will not work with a temporary addon ID. " +78 "Please add an explicit addon ID to your manifest.";79 throw new ExtensionError(message);80 }81 return `extension:${extensionId}:${key}`;82};83this.sessions = class extends ExtensionAPI {84 getAPI(context) {85 let { extension } = context;86 function getTabParams(key, id) {87 let encodedKey = getEncodedKey(extension.id, key);88 let tab = tabTracker.getTab(id);89 if (!context.canAccessWindow(tab.ownerGlobal)) {90 throw new ExtensionError(`Invalid tab ID: ${id}`);91 }92 return { encodedKey, tab };93 }94 function getWindowParams(key, id) {95 let encodedKey = getEncodedKey(extension.id, key);96 let win = windowTracker.getWindow(id, context);97 return { encodedKey, win };98 }99 return {100 sessions: {101 async getRecentlyClosed(filter) {102 await SessionStore.promiseInitialized;103 let maxResults =104 filter.maxResults == undefined105 ? this.MAX_SESSION_RESULTS106 : filter.maxResults;107 return getRecentlyClosed(maxResults, extension);108 },109 async forgetClosedTab(windowId, sessionId) {110 await SessionStore.promiseInitialized;111 let window = windowTracker.getWindow(windowId, context);112 let closedTabData = SessionStore.getClosedTabData(window, false);113 let closedTabIndex = closedTabData.findIndex(closedTab => {114 return closedTab.closedId === parseInt(sessionId, 10);115 });116 if (closedTabIndex < 0) {117 throw new ExtensionError(118 `Could not find closed tab using sessionId ${sessionId}.`119 );120 }121 SessionStore.forgetClosedTab(window, closedTabIndex);122 },123 async forgetClosedWindow(sessionId) {124 await SessionStore.promiseInitialized;125 let closedWindowData = SessionStore.getClosedWindowData(false);126 let closedWindowIndex = closedWindowData.findIndex(closedWindow => {127 return closedWindow.closedId === parseInt(sessionId, 10);128 });129 if (closedWindowIndex < 0) {130 throw new ExtensionError(131 `Could not find closed window using sessionId ${sessionId}.`132 );133 }134 SessionStore.forgetClosedWindow(closedWindowIndex);135 },136 async restore(sessionId) {137 await SessionStore.promiseInitialized;138 let session, closedId;139 if (sessionId) {140 closedId = sessionId;141 session = SessionStore.undoCloseById(142 closedId,143 extension.privateBrowsingAllowed144 );145 } else if (SessionStore.lastClosedObjectType == "window") {146 // If the most recently closed object is a window, just undo closing the most recent window.147 session = SessionStore.undoCloseWindow(0);148 } else {149 // It is a tab, and we cannot call SessionStore.undoCloseTab without a window,150 // so we must find the tab in which case we can just use its closedId.151 let recentlyClosedTabs = [];152 for (let window of windowTracker.browserWindows()) {153 let closedTabData = SessionStore.getClosedTabData(window, false);154 for (let tab of closedTabData) {155 recentlyClosedTabs.push(tab);156 }157 }158 if (recentlyClosedTabs.length) {159 // Sort the tabs.160 recentlyClosedTabs.sort((a, b) => b.closedAt - a.closedAt);161 // Use the closedId of the most recently closed tab to restore it.162 closedId = recentlyClosedTabs[0].closedId;163 session = SessionStore.undoCloseById(164 closedId,165 extension.privateBrowsingAllowed166 );167 }168 }169 return createSession(session, extension, closedId);170 },171 setTabValue(tabId, key, value) {172 let { tab, encodedKey } = getTabParams(key, tabId);173 SessionStore.setCustomTabValue(174 tab,175 encodedKey,176 JSON.stringify(value)177 );178 },179 async getTabValue(tabId, key) {180 let { tab, encodedKey } = getTabParams(key, tabId);181 let value = SessionStore.getCustomTabValue(tab, encodedKey);182 if (value) {183 return JSON.parse(value);184 }185 return undefined;186 },187 removeTabValue(tabId, key) {188 let { tab, encodedKey } = getTabParams(key, tabId);189 SessionStore.deleteCustomTabValue(tab, encodedKey);190 },191 setWindowValue(windowId, key, value) {192 let { win, encodedKey } = getWindowParams(key, windowId);193 SessionStore.setCustomWindowValue(194 win,195 encodedKey,196 JSON.stringify(value)197 );198 },199 async getWindowValue(windowId, key) {200 let { win, encodedKey } = getWindowParams(key, windowId);201 let value = SessionStore.getCustomWindowValue(win, encodedKey);202 if (value) {203 return JSON.parse(value);204 }205 return undefined;206 },207 removeWindowValue(windowId, key) {208 let { win, encodedKey } = getWindowParams(key, windowId);209 SessionStore.deleteCustomWindowValue(win, encodedKey);210 },211 onChanged: new EventManager({212 context,213 name: "sessions.onChanged",214 register: fire => {215 let observer = () => {216 fire.async();217 };218 Services.obs.addObserver(observer, SS_ON_CLOSED_OBJECTS_CHANGED);219 return () => {220 Services.obs.removeObserver(221 observer,222 SS_ON_CLOSED_OBJECTS_CHANGED223 );224 };225 },226 }).api(),227 },228 };229 }...
browser_cleaner.js
Source:browser_cleaner.js
1/* Any copyright is dedicated to the Public Domain.2 * http://creativecommons.org/publicdomain/zero/1.0/ */3/*4 * This test ensures that Session Restore eventually forgets about5 * tabs and windows that have been closed a long time ago.6 */7"use strict";8ChromeUtils.import("resource://gre/modules/Services.jsm", this);9ChromeUtils.import("resource://gre/modules/osfile.jsm", this);10const LONG_TIME_AGO = 1;11const URL_TAB1 =12 "http://example.com/browser_cleaner.js?newtab1=" + Math.random();13const URL_TAB2 =14 "http://example.com/browser_cleaner.js?newtab2=" + Math.random();15const URL_NEWWIN =16 "http://example.com/browser_cleaner.js?newwin=" + Math.random();17function isRecent(stamp) {18 is(typeof stamp, "number", "This is a timestamp");19 return Date.now() - stamp <= 60000;20}21function promiseCleanup() {22 info("Cleaning up browser");23 return promiseBrowserState(getClosedState());24}25function getClosedState() {26 return Cu.cloneInto(CLOSED_STATE, {});27}28var CLOSED_STATE;29add_task(async function init() {30 forgetClosedWindows();31 while (ss.getClosedTabCount(window) > 0) {32 ss.forgetClosedTab(window, 0);33 }34});35add_task(async function test_open_and_close() {36 let newTab1 = BrowserTestUtils.addTab(gBrowser, URL_TAB1);37 await promiseBrowserLoaded(newTab1.linkedBrowser);38 let newTab2 = BrowserTestUtils.addTab(gBrowser, URL_TAB2);39 await promiseBrowserLoaded(newTab2.linkedBrowser);40 let newWin = await promiseNewWindowLoaded();41 let tab = BrowserTestUtils.addTab(newWin.gBrowser, URL_NEWWIN);42 await promiseBrowserLoaded(tab.linkedBrowser);43 await TabStateFlusher.flushWindow(window);44 await TabStateFlusher.flushWindow(newWin);45 info("1. Making sure that before closing, we don't have closedAt");46 // For the moment, no "closedAt"47 let state = JSON.parse(ss.getBrowserState());48 is(49 state.windows[0].closedAt || false,50 false,51 "1. Main window doesn't have closedAt"52 );53 is(54 state.windows[1].closedAt || false,55 false,56 "1. Second window doesn't have closedAt"57 );58 is(59 state.windows[0].tabs[0].closedAt || false,60 false,61 "1. First tab doesn't have closedAt"62 );63 is(64 state.windows[0].tabs[1].closedAt || false,65 false,66 "1. Second tab doesn't have closedAt"67 );68 info("2. Making sure that after closing, we have closedAt");69 // Now close stuff, this should add closeAt70 await BrowserTestUtils.closeWindow(newWin);71 await promiseRemoveTabAndSessionState(newTab1);72 await promiseRemoveTabAndSessionState(newTab2);73 state = CLOSED_STATE = JSON.parse(ss.getBrowserState());74 is(75 state.windows[0].closedAt || false,76 false,77 "2. Main window doesn't have closedAt"78 );79 ok(80 isRecent(state._closedWindows[0].closedAt),81 "2. Second window was closed recently"82 );83 ok(84 isRecent(state.windows[0]._closedTabs[0].closedAt),85 "2. First tab was closed recently"86 );87 ok(88 isRecent(state.windows[0]._closedTabs[1].closedAt),89 "2. Second tab was closed recently"90 );91});92add_task(async function test_restore() {93 info("3. Making sure that after restoring, we don't have closedAt");94 await promiseBrowserState(CLOSED_STATE);95 let newWin = ss.undoCloseWindow(0);96 await promiseDelayedStartupFinished(newWin);97 let newTab2 = ss.undoCloseTab(window, 0);98 await promiseTabRestored(newTab2);99 let newTab1 = ss.undoCloseTab(window, 0);100 await promiseTabRestored(newTab1);101 let state = JSON.parse(ss.getBrowserState());102 is(103 state.windows[0].closedAt || false,104 false,105 "3. Main window doesn't have closedAt"106 );107 is(108 state.windows[1].closedAt || false,109 false,110 "3. Second window doesn't have closedAt"111 );112 is(113 state.windows[0].tabs[0].closedAt || false,114 false,115 "3. First tab doesn't have closedAt"116 );117 is(118 state.windows[0].tabs[1].closedAt || false,119 false,120 "3. Second tab doesn't have closedAt"121 );122 await BrowserTestUtils.closeWindow(newWin);123 gBrowser.removeTab(newTab1);124 gBrowser.removeTab(newTab2);125});126add_task(async function test_old_data() {127 info(128 "4. Removing closedAt from the sessionstore, making sure that it is added upon idle-daily"129 );130 let state = getClosedState();131 delete state._closedWindows[0].closedAt;132 delete state.windows[0]._closedTabs[0].closedAt;133 delete state.windows[0]._closedTabs[1].closedAt;134 await promiseBrowserState(state);135 info("Sending idle-daily");136 Services.obs.notifyObservers(null, "idle-daily");137 info("Sent idle-daily");138 state = JSON.parse(ss.getBrowserState());139 is(140 state.windows[0].closedAt || false,141 false,142 "4. Main window doesn't have closedAt"143 );144 ok(145 isRecent(state._closedWindows[0].closedAt),146 "4. Second window was closed recently"147 );148 ok(149 isRecent(state.windows[0]._closedTabs[0].closedAt),150 "4. First tab was closed recently"151 );152 ok(153 isRecent(state.windows[0]._closedTabs[1].closedAt),154 "4. Second tab was closed recently"155 );156 await promiseCleanup();157});158add_task(async function test_cleanup() {159 info(160 "5. Altering closedAt to an old date, making sure that stuff gets collected, eventually"161 );162 await promiseCleanup();163 let state = getClosedState();164 state._closedWindows[0].closedAt = LONG_TIME_AGO;165 state.windows[0]._closedTabs[0].closedAt = LONG_TIME_AGO;166 state.windows[0]._closedTabs[1].closedAt = Date.now();167 let url = state.windows[0]._closedTabs[1].state.entries[0].url;168 await promiseBrowserState(state);169 info("Sending idle-daily");170 Services.obs.notifyObservers(null, "idle-daily");171 info("Sent idle-daily");172 state = JSON.parse(ss.getBrowserState());173 is(state._closedWindows[0], undefined, "5. Second window was forgotten");174 is(state.windows[0]._closedTabs.length, 1, "5. Only one closed tab left");175 is(176 state.windows[0]._closedTabs[0].state.entries[0].url,177 url,178 "5. The second tab is still here"179 );180 await promiseCleanup();...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5 if (err) return console.error(err);6 console.log('Test status:', data.statusText);7 if (data.statusCode === 200) {8 console.log('Test completed in', data.data.average.firstView.loadTime, 'ms');9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test results:', data.data);12 });13 }14});15 at IncomingMessage. (/home/rahul/Downloads/wpt-master/node_modules/webpagetest/lib/webpagetest.js:84:33)16 at IncomingMessage.emit (events.js:107:17)17 at process._tickCallback (node.js:355:11)
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.close();5});6var wpt = require('wpt');7var wpt = new WebPageTest('www.webpagetest.org');8 if (err) return console.error(err);9 wpt.close();10});11var wpt = require('wpt');12var wpt = new WebPageTest('www.webpagetest.org');13 if (err) return console.error(err);14 wpt.close();15});16var wpt = require('wpt');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) return console.error(err);19 wpt.close();20});21var wpt = require('wpt');22var wpt = new WebPageTest('www.webpagetest.org');23 if (err) return console.error(err);24 wpt.close();25});26var wpt = require('wpt');27var wpt = new WebPageTest('www.webpagetest.org');28 if (err) return console.error(err);29 wpt.close();30});31var wpt = require('wpt');
Using AI Code Generation
1var wpt = require('webpagetest');2var api = new wpt('API_KEY');3var options = {4 videoParams: {5 },6};7api.runTest(url, options, function(err, data) {8 if (err) return console.error(err);9 console.log(data.data.runs);10 api.getTestResults(data.data.testId, function(err, data) {11 if (err) return console.error(err);12 console.log(data);13 });14});15[ { firstView: { TTFB: 119, startRender: 196, SpeedIndex: 196, visualComplete: 196, lastVisualChange: 0, run: 1, cached: 0, fullyLoaded: 196, docTime: 196, fullyLoadedCPUms: 170, bytesIn: 0, bytesOut: 0, requests: 0, responses_200: 0, responses_404: 0, responses_other: 0, result: 99999, render: 0, SpeedIndex: 196, TTFB: 119, visualComplete: 196, firstPaint: 0, domContentLoadedEventStart: 0, domContentLoadedEventEnd: 0, domInteractive: 0, domLoading: 0, domainLookupEnd: 0, domainLookupStart: 0, loadEventEnd: 0, loadEventStart: 0, redirectEnd: 0, redirectStart: 0, requestStart: 0, responseEnd: 0, responseStart: 0, secureConnectionStart: 0, unloadEventEnd: 0, unloadEventStart: 0, aft: 0, basePageCDN: '', browser_name: 'Chrome', browser_version: '41.0.2272.118', bytesInDoc:
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2 if (err) {3 console.log('error: ', err);4 } else {5 console.log('data: ', data);6 }7}); 8var wptoolkit = require('wptoolkit');9 if (err) {10 console.log('error: ', err);11 } else {12 console.log('data: ', data);13 }14});15var wptoolkit = require('wptoolkit');16 if (err) {17 console.log('error: ', err);18 } else {19 console.log('data: ', data);20 }21});22var wptoolkit = require('wptoolkit');23 if (err) {24 console.log('error: ', err);25 } else {26 console.log('data: ', data);27 }28});29var wptoolkit = require('wptoolkit');30 if (err) {31 console.log('error: ', err);32 } else {33 console.log('data: ', data);34 }35});36var wptoolkit = require('wptoolkit');37 if (err) {38 console.log('error: ', err);39 } else {40 console.log('data: ', data);41 }42});43var wptoolkit = require('wptoolkit');
Using AI Code Generation
1var wpt = require('wpt-api');2var wpt = new wpt('API_KEY');3wpt.closed(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt-api');11var wpt = new wpt('API_KEY');12var options = {13};14wpt.closed(url, options, function(err, data) {15 if (err) {16 console.log(err);17 } else {18 console.log(data);19 }20});
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var webpagetest = new wpt(options);5webpagetest.runTest(url, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPagetest for %s', url);8 console.log('Test ID: %s', data.data.testId);9 webpagetest.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test completed for %s', url);12 console.log('First View (i.e. Load Time): %d ms', data.data.average.firstView.loadTime);13 console.log('Repeat View (i.e. Load Time): %d ms', data.data.average.repeatView.loadTime);14 });15});16var wpt = require('webpagetest');17var options = {18};19var webpagetest = new wpt(options);20webpagetest.runTest(url, function(err, data) {21 if (err) return console.error(err);22 console.log('Test submitted to WebPagetest for %s', url);23 console.log('Test ID: %s', data.data.testId);24 webpagetest.getTestResults(data.data.testId, function(err, data) {25 if (err) return console.error(err);26 console.log('Test completed for %s', url);27 console.log('First View (i.e. Load Time): %d ms', data.data.average.firstView.loadTime);28 console.log('Repeat View (i.e. Load Time): %d ms',
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!!