Best JavaScript code snippet using best
main.js
Source:main.js
1/* global __dirname */2var express = require('express');3var app = express();4var fs = require("fs");5// Add headers6app.use(function (req, res, next) {7 // Website you wish to allow to connect8 res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8383');9 // Request methods you wish to allow10 res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');11 // Request headers you wish to allow12 res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');13 // Set to true if you need the website to include cookies in the requests sent14 // to the API (e.g. in case you use sessions)15 res.setHeader('Access-Control-Allow-Credentials', true);16 // Pass to next layer of middleware17 next();18});19app.get('/PM10/2014', function (req, res , next) {20 fs.readFile( __dirname + "/" + "data/PM10/pm102014.json", 'utf8', function (err, data) {21 22 res.end( data );23 });24});25app.get('/PM10/2013', function (req, res , next) {26 fs.readFile( __dirname + "/" + "data/PM10/pm102013.json", 'utf8', function (err, data) {27 28 res.end( data );29 });30});31app.get('/PM10/2012', function (req, res , next) {32 fs.readFile( __dirname + "/" + "data/PM10/pm102012.json", 'utf8', function (err, data) {33 34 res.end( data );35 });36});37app.get('/PM10/2011', function (req, res , next) {38 fs.readFile( __dirname + "/" + "data/PM10/pm102011.json", 'utf8', function (err, data) {39 40 res.end( data );41 });42});43app.get('/PM10/2010', function (req, res , next) {44 fs.readFile( __dirname + "/" + "data/PM10/pm102010.json", 'utf8', function (err, data) {45 46 res.end( data );47 });48});49app.get('/PM10/2009', function (req, res , next) {50 fs.readFile( __dirname + "/" + "data/PM10/pm102009.json", 'utf8', function (err, data) {51 52 res.end( data );53 });54});55app.get('/PM10/2008', function (req, res , next) {56 fs.readFile( __dirname + "/" + "data/PM10/pm102008.json", 'utf8', function (err, data) {57 58 res.end( data );59 });60});61app.get('/PM10/2007', function (req, res , next) {62 fs.readFile( __dirname + "/" + "data/PM10/pm102007.json", 'utf8', function (err, data) {63 64 res.end( data );65 });66});67app.get('/PM10/2006', function (req, res , next) {68 fs.readFile( __dirname + "/" + "data/PM10/pm102006.json", 'utf8', function (err, data) {69 70 res.end( data );71 });72});73app.get('/PM10/2005', function (req, res , next) {74 fs.readFile( __dirname + "/" + "data/PM10/pm102005.json", 'utf8', function (err, data) {75 76 res.end( data );77 });78});79app.get('/PM10/2004', function (req, res , next) {80 fs.readFile( __dirname + "/" + "data/PM10/pm102004.json", 'utf8', function (err, data) {81 82 res.end( data );83 });84});85app.get('/PM10/2003', function (req, res , next) {86 fs.readFile( __dirname + "/" + "data/PM10/pm102003.json", 'utf8', function (err, data) {87 88 res.end( data );89 });90});91app.get('/PM10/2002', function (req, res , next) {92 fs.readFile( __dirname + "/" + "data/PM10/pm102002.json", 'utf8', function (err, data) {93 94 res.end( data );95 });96});97app.get('/PM10/2001', function (req, res , next) {98 fs.readFile( __dirname + "/" + "data/PM10/pm102001.json", 'utf8', function (err, data) {99 100 res.end( data );101 });102});103app.get('/PM10/2000', function (req, res , next) {104 fs.readFile( __dirname + "/" + "data/PM10/pm102000.json", 'utf8', function (err, data) {105 106 res.end( data );107 });108});109app.get('/PM10/1999', function (req, res , next) {110 fs.readFile( __dirname + "/" + "data/PM10/pm101999.json", 'utf8', function (err, data) {111 112 res.end( data );113 });114});115app.get('/PM2_5/2014', function (req, res , next) {116 fs.readFile( __dirname + "/" + "data/PM25/pm252014.json", 'utf8', function (err, data) {117 118 res.end( data );119 });120});121app.get('/PM2_5/2013', function (req, res , next) {122 fs.readFile( __dirname + "/" + "data/PM25/pm252013.json", 'utf8', function (err, data) {123 124 res.end( data );125 });126});127app.get('/PM2_5/2012', function (req, res , next) {128 fs.readFile( __dirname + "/" + "data/PM25/pm252012.json", 'utf8', function (err, data) {129 130 res.end( data );131 });132});133app.get('/PM2_5/2011', function (req, res , next) {134 fs.readFile( __dirname + "/" + "data/PM25/pm252011.json", 'utf8', function (err, data) {135 136 res.end( data );137 });138});139app.get('/PM2_5/2010', function (req, res , next) {140 fs.readFile( __dirname + "/" + "data/PM25/pm252010.json", 'utf8', function (err, data) {141 142 res.end( data );143 });144});145app.get('/PM2_5/2009', function (req, res , next) {146 fs.readFile( __dirname + "/" + "data/PM25/pm252009.json", 'utf8', function (err, data) {147 148 res.end( data );149 });150});151app.get('/PM2_5/2008', function (req, res , next) {152 fs.readFile( __dirname + "/" + "data/PM25/pm252008.json", 'utf8', function (err, data) {153 154 res.end( data );155 });156});157app.get('/PM2_5/2007', function (req, res , next) {158 fs.readFile( __dirname + "/" + "data/PM25/pm252007.json", 'utf8', function (err, data) {159 160 res.end( data );161 });162});163app.get('/PM2_5/2006', function (req, res , next) {164 fs.readFile( __dirname + "/" + "data/PM25/pm252006.json", 'utf8', function (err, data) {165 166 res.end( data );167 });168});169app.get('/PM2_5/2005', function (req, res , next) {170 fs.readFile( __dirname + "/" + "data/PM25/pm252005.json", 'utf8', function (err, data) {171 172 res.end( data );173 });174});175app.get('/PM2_5/2004', function (req, res , next) {176 fs.readFile( __dirname + "/" + "data/PM25/pm252004.json", 'utf8', function (err, data) {177 178 res.end( data );179 });180});181app.get('/PM2_5/2003', function (req, res , next) {182 fs.readFile( __dirname + "/" + "data/PM25/pm252003.json", 'utf8', function (err, data) {183 184 res.end( data );185 });186});187app.get('/PM2_5/2002', function (req, res , next) {188 fs.readFile( __dirname + "/" + "data/PM25/pm252002.json", 'utf8', function (err, data) {189 190 res.end( data );191 });192});193app.get('/PM2_5/2001', function (req, res , next) {194 fs.readFile( __dirname + "/" + "data/PM25/pm252001.json", 'utf8', function (err, data) {195 196 res.end( data );197 });198});199app.get('/PM2_5/2000', function (req, res , next) {200 fs.readFile( __dirname + "/" + "data/PM25/pm252000.json", 'utf8', function (err, data) {201 202 res.end( data );203 });204});205app.get('/PM25/1999', function (req, res , next) {206 fs.readFile( __dirname + "/" + "data/PM25/pm251999.json", 'utf8', function (err, data) {207 208 res.end( data );209 });210});211app.get('/NH3/2014', function (req, res , next) {212 fs.readFile( __dirname + "/" + "data/NH3/NH32014.json", 'utf8', function (err, data) {213 214 res.end( data );215 });216});217app.get('/NH3/2013', function (req, res , next) {218 fs.readFile( __dirname + "/" + "data/NH3/NH32013.json", 'utf8', function (err, data) {219 220 res.end( data );221 });222});223app.get('/NH3/2012', function (req, res , next) {224 fs.readFile( __dirname + "/" + "data/NH3/NH32012.json", 'utf8', function (err, data) {225 226 res.end( data );227 });228});229app.get('/NH3/2011', function (req, res , next) {230 fs.readFile( __dirname + "/" + "data/PNH3/NH32011.json", 'utf8', function (err, data) {231 232 res.end( data );233 });234});235app.get('/NH3/2010', function (req, res , next) {236 fs.readFile( __dirname + "/" + "data/NH3/NH32010.json", 'utf8', function (err, data) {237 238 res.end( data );239 });240});241app.get('/NH3/2009', function (req, res , next) {242 fs.readFile( __dirname + "/" + "data/NH3/NH32009.json", 'utf8', function (err, data) {243 244 res.end( data );245 });246});247app.get('/NH3/2008', function (req, res , next) {248 fs.readFile( __dirname + "/" + "data/NH3/NH32008.json", 'utf8', function (err, data) {249 250 res.end( data );251 });252});253app.get('/NH3/2007', function (req, res , next) {254 fs.readFile( __dirname + "/" + "data/NH3/NH32007.json", 'utf8', function (err, data) {255 256 res.end( data );257 });258});259app.get('/NH3/2006', function (req, res , next) {260 fs.readFile( __dirname + "/" + "data/NH3/NH32006.json", 'utf8', function (err, data) {261 262 res.end( data );263 });264});265app.get('/NH3/2005', function (req, res , next) {266 fs.readFile( __dirname + "/" + "data/NH3/NH32005.json", 'utf8', function (err, data) {267 268 res.end( data );269 });270});271app.get('/NH3/2004', function (req, res , next) {272 fs.readFile( __dirname + "/" + "data/NH3/NH32004.json", 'utf8', function (err, data) {273 274 res.end( data );275 });276});277app.get('/NH3/2003', function (req, res , next) {278 fs.readFile( __dirname + "/" + "data/NH3/NH32003.json", 'utf8', function (err, data) {279 280 res.end( data );281 });282});283app.get('/NH3/2002', function (req, res , next) {284 fs.readFile( __dirname + "/" + "data/NH3/NH32002.json", 'utf8', function (err, data) {285 286 res.end( data );287 });288});289app.get('/NH3/2001', function (req, res , next) {290 fs.readFile( __dirname + "/" + "data/NH3/NH32001.json", 'utf8', function (err, data) {291 292 res.end( data );293 });294});295app.get('/NH3/2000', function (req, res , next) {296 fs.readFile( __dirname + "/" + "data/NH3/NH32000.json", 'utf8', function (err, data) {297 298 res.end( data );299 });300});301app.get('/NH3/1999', function (req, res , next) {302 fs.readFile( __dirname + "/" + "data/NH3/NH31999.json", 'utf8', function (err, data) {303 304 res.end( data );305 });306});307app.get('/NMVOC/2014', function (req, res , next) {308 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2014.json", 'utf8', function (err, data) {309 310 res.end( data );311 });312});313app.get('/NMVOC/2013', function (req, res , next) {314 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2013.json", 'utf8', function (err, data) {315 316 res.end( data );317 });318});319app.get('/NMVOC/2012', function (req, res , next) {320 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2012.json", 'utf8', function (err, data) {321 322 res.end( data );323 });324});325app.get('/NMVOC/2011', function (req, res , next) {326 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2011.json", 'utf8', function (err, data) {327 328 res.end( data );329 });330});331app.get('/NMVOC/2010', function (req, res , next) {332 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2010.json", 'utf8', function (err, data) {333 334 res.end( data );335 });336});337app.get('/NMVOC/2009', function (req, res , next) {338 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2009.json", 'utf8', function (err, data) {339 340 res.end( data );341 });342});343app.get('/NMVOC/2008', function (req, res , next) {344 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2008.json", 'utf8', function (err, data) {345 346 res.end( data );347 });348});349app.get('/NMVOC/2007', function (req, res , next) {350 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2007.json", 'utf8', function (err, data) {351 352 res.end( data );353 });354});355app.get('/NMVOC/2006', function (req, res , next) {356 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2006.json", 'utf8', function (err, data) {357 358 res.end( data );359 });360});361app.get('/NMVOC/2005', function (req, res , next) {362 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2005.json", 'utf8', function (err, data) {363 364 res.end( data );365 });366});367app.get('/NMVOC/2004', function (req, res , next) {368 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2004.json", 'utf8', function (err, data) {369 370 res.end( data );371 });372});373app.get('/NMVOC/2003', function (req, res , next) {374 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2003.json", 'utf8', function (err, data) {375 376 res.end( data );377 });378});379app.get('/NMVOC/2002', function (req, res , next) {380 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2002.json", 'utf8', function (err, data) {381 382 res.end( data );383 });384});385app.get('/NMVOC/2001', function (req, res , next) {386 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2001.json", 'utf8', function (err, data) {387 388 res.end( data );389 });390});391app.get('/NMVOC/2000', function (req, res , next) {392 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC2000.json", 'utf8', function (err, data) {393 394 res.end( data );395 });396});397app.get('/NMVOC/1999', function (req, res , next) {398 fs.readFile( __dirname + "/" + "data/NMVOC/NMVOC1999.json", 'utf8', function (err, data) {399 400 res.end( data );401 });402});403app.get('/NOX/2014', function (req, res , next) {404 fs.readFile( __dirname + "/" + "data/NOX/NOX2014.json", 'utf8', function (err, data) {405 406 res.end( data );407 });408});409app.get('/NOX/2013', function (req, res , next) {410 fs.readFile( __dirname + "/" + "data/NOX/NOX2013.json", 'utf8', function (err, data) {411 412 res.end( data );413 });414});415app.get('/NOX/2012', function (req, res , next) {416 fs.readFile( __dirname + "/" + "data/NOX/NOX2012.json", 'utf8', function (err, data) {417 418 res.end( data );419 });420});421app.get('/NOX/2011', function (req, res , next) {422 fs.readFile( __dirname + "/" + "data/NOX/NOX2011.json", 'utf8', function (err, data) {423 424 res.end( data );425 });426});427app.get('/NOX/2010', function (req, res , next) {428 fs.readFile( __dirname + "/" + "data/NOX/NOX2010.json", 'utf8', function (err, data) {429 430 res.end( data );431 });432});433app.get('/NOX/2009', function (req, res , next) {434 fs.readFile( __dirname + "/" + "data/NOX/NOX2009.json", 'utf8', function (err, data) {435 436 res.end( data );437 });438});439app.get('/NOX/2008', function (req, res , next) {440 fs.readFile( __dirname + "/" + "data/NOX/NOX2008.json", 'utf8', function (err, data) {441 442 res.end( data );443 });444});445app.get('/NOX/2007', function (req, res , next) {446 fs.readFile( __dirname + "/" + "data/NOX/NOX2007.json", 'utf8', function (err, data) {447 448 res.end( data );449 });450});451app.get('/NOX/2006', function (req, res , next) {452 fs.readFile( __dirname + "/" + "data/NOX/NOX2006.json", 'utf8', function (err, data) {453 454 res.end( data );455 });456});457app.get('/NOX/2005', function (req, res , next) {458 fs.readFile( __dirname + "/" + "data/NOX/NOX2005.json", 'utf8', function (err, data) {459 460 res.end( data );461 });462});463app.get('/NOX/2004', function (req, res , next) {464 fs.readFile( __dirname + "/" + "data/NOX/NOX2004.json", 'utf8', function (err, data) {465 466 res.end( data );467 });468});469app.get('/NOX/2003', function (req, res , next) {470 fs.readFile( __dirname + "/" + "data/NOX/NOX2003.json", 'utf8', function (err, data) {471 472 res.end( data );473 });474});475app.get('/NOX/2002', function (req, res , next) {476 fs.readFile( __dirname + "/" + "data/NOX/NOX2002.json", 'utf8', function (err, data) {477 478 res.end( data );479 });480});481app.get('/NOX/2001', function (req, res , next) {482 fs.readFile( __dirname + "/" + "data/NOX/NOX2001.json", 'utf8', function (err, data) {483 484 res.end( data );485 });486});487app.get('/NOX/2000', function (req, res , next) {488 fs.readFile( __dirname + "/" + "data/NOX/NOX2000.json", 'utf8', function (err, data) {489 490 res.end( data );491 });492});493app.get('/NOX/1999', function (req, res , next) {494 fs.readFile( __dirname + "/" + "data/NOX/NOX1999.json", 'utf8', function (err, data) {495 496 res.end( data );497 });498});499app.get('/SOX/2014', function (req, res , next) {500 fs.readFile( __dirname + "/" + "data/SOX/SOX2014.json", 'utf8', function (err, data) {501 502 res.end( data );503 });504});505app.get('/SOX/2013', function (req, res , next) {506 fs.readFile( __dirname + "/" + "data/SOX/SOX2013.json", 'utf8', function (err, data) {507 508 res.end( data );509 });510});511app.get('/SOX/2012', function (req, res , next) {512 fs.readFile( __dirname + "/" + "data/SOX/SOX2012.json", 'utf8', function (err, data) {513 514 res.end( data );515 });516});517app.get('/SOX/2011', function (req, res , next) {518 fs.readFile( __dirname + "/" + "data/SOX/SOX2011.json", 'utf8', function (err, data) {519 520 res.end( data );521 });522});523app.get('/SOX/2010', function (req, res , next) {524 fs.readFile( __dirname + "/" + "data/SOX/SOX2010.json", 'utf8', function (err, data) {525 526 res.end( data );527 });528});529app.get('/SOX/2009', function (req, res , next) {530 fs.readFile( __dirname + "/" + "data/SOX/SOX2009.json", 'utf8', function (err, data) {531 532 res.end( data );533 });534});535app.get('/SOX/2008', function (req, res , next) {536 fs.readFile( __dirname + "/" + "data/SOX/SOX2008.json", 'utf8', function (err, data) {537 538 res.end( data );539 });540});541app.get('/SOX/2007', function (req, res , next) {542 fs.readFile( __dirname + "/" + "data/SOX/SOX2007.json", 'utf8', function (err, data) {543 544 res.end( data );545 });546});547app.get('/SOX/2006', function (req, res , next) {548 fs.readFile( __dirname + "/" + "data/SOX/SOX2006.json", 'utf8', function (err, data) {549 550 res.end( data );551 });552});553app.get('/SOX/2005', function (req, res , next) {554 fs.readFile( __dirname + "/" + "data/SOX/SOX2005.json", 'utf8', function (err, data) {555 556 res.end( data );557 });558});559app.get('/SOX/2004', function (req, res , next) {560 fs.readFile( __dirname + "/" + "data/SOX/SOX2004.json", 'utf8', function (err, data) {561 562 res.end( data );563 });564});565app.get('/SOX/2003', function (req, res , next) {566 fs.readFile( __dirname + "/" + "data/SOX/SOX2003.json", 'utf8', function (err, data) {567 568 res.end( data );569 });570});571app.get('/SOX/2002', function (req, res , next) {572 fs.readFile( __dirname + "/" + "data/SOX/SOX2002.json", 'utf8', function (err, data) {573 574 res.end( data );575 });576});577app.get('/SOX/2001', function (req, res , next) {578 fs.readFile( __dirname + "/" + "data/SOX/SOX2001.json", 'utf8', function (err, data) {579 580 res.end( data );581 });582});583app.get('/SOX/2000', function (req, res , next) {584 fs.readFile( __dirname + "/" + "data/SOX/SOX2000.json", 'utf8', function (err, data) {585 586 res.end( data );587 });588});589app.get('/SOX/1999', function (req, res , next) {590 fs.readFile( __dirname + "/" + "data/SOX/SOX1999.json", 'utf8', function (err, data) {591 592 res.end( data );593 });594});595app.get('/country/UK', function (req, res , next) {596 fs.readFile( __dirname + "/" + "data/Countries/UK.json", 'utf8', function (err, data) {597 598 res.end( data );599 });600});601app.get('/country/AT', function (req, res , next) {602 fs.readFile( __dirname + "/" + "data/Countries/AT.json", 'utf8', function (err, data) {603 604 res.end( data );605 });606});607app.get('/country/BE', function (req, res , next) {608 fs.readFile( __dirname + "/" + "data/Countries/BE.json", 'utf8', function (err, data) {609 610 res.end( data );611 });612});app.get('/country/BG', function (req, res , next) {613 fs.readFile( __dirname + "/" + "data/Countries/BG.json", 'utf8', function (err, data) {614 615 res.end( data );616 });617});app.get('/country/CH', function (req, res , next) {618 fs.readFile( __dirname + "/" + "data/Countries/CH.json", 'utf8', function (err, data) {619 620 res.end( data );621 });622});app.get('/country/CY', function (req, res , next) {623 fs.readFile( __dirname + "/" + "data/Countries/CY.json", 'utf8', function (err, data) {624 625 res.end( data );626 });627});app.get('/country/CZ', function (req, res , next) {628 fs.readFile( __dirname + "/" + "data/Countries/CZ.json", 'utf8', function (err, data) {629 630 res.end( data );631 });632});app.get('/country/DE', function (req, res , next) {633 fs.readFile( __dirname + "/" + "data/Countries/DE.json", 'utf8', function (err, data) {634 635 res.end( data );636 });637});app.get('/country/DK', function (req, res , next) {638 fs.readFile( __dirname + "/" + "data/Countries/DK.json", 'utf8', function (err, data) {639 640 res.end( data );641 });642});app.get('/country/EE', function (req, res , next) {643 fs.readFile( __dirname + "/" + "data/Countries/EE.json", 'utf8', function (err, data) {644 645 res.end( data );646 });647});app.get('/country/ES', function (req, res , next) {648 fs.readFile( __dirname + "/" + "data/Countries/ES.json", 'utf8', function (err, data) {649 650 res.end( data );651 });652});app.get('/country/FI', function (req, res , next) {653 fs.readFile( __dirname + "/" + "data/Countries/FI.json", 'utf8', function (err, data) {654 655 res.end( data );656 });657});app.get('/country/FR', function (req, res , next) {658 fs.readFile( __dirname + "/" + "data/Countries/FR.json", 'utf8', function (err, data) {659 660 res.end( data );661 });662});app.get('/country/HR', function (req, res , next) {663 fs.readFile( __dirname + "/" + "data/Countries/HR.json", 'utf8', function (err, data) {664 665 res.end( data );666 });667});app.get('/country/HU', function (req, res , next) {668 fs.readFile( __dirname + "/" + "data/Countries/HU.json", 'utf8', function (err, data) {669 670 res.end( data );671 });672});app.get('/country/IE', function (req, res , next) {673 fs.readFile( __dirname + "/" + "data/Countries/IE.json", 'utf8', function (err, data) {674 675 res.end( data );676 });677});app.get('/country/IT', function (req, res , next) {678 fs.readFile( __dirname + "/" + "data/Countries/IT.json", 'utf8', function (err, data) {679 680 res.end( data );681 });682});app.get('/country/LI', function (req, res , next) {683 fs.readFile( __dirname + "/" + "data/Countries/LI.json", 'utf8', function (err, data) {684 685 res.end( data );686 });687});app.get('/country/LT', function (req, res , next) {688 fs.readFile( __dirname + "/" + "data/Countries/LT.json", 'utf8', function (err, data) {689 690 res.end( data );691 });692});app.get('/country/LU', function (req, res , next) {693 fs.readFile( __dirname + "/" + "data/Countries/LU.json", 'utf8', function (err, data) {694 695 res.end( data );696 });697});app.get('/country/LV', function (req, res , next) {698 fs.readFile( __dirname + "/" + "data/Countries/LV.json", 'utf8', function (err, data) {699 700 res.end( data );701 });702});app.get('/country/NL', function (req, res , next) {703 fs.readFile( __dirname + "/" + "data/Countries/NL.json", 'utf8', function (err, data) {704 705 res.end( data );706 });707});app.get('/country/NO', function (req, res , next) {708 fs.readFile( __dirname + "/" + "data/Countries/NO.json", 'utf8', function (err, data) {709 710 res.end( data );711 });712});app.get('/country/PL', function (req, res , next) {713 fs.readFile( __dirname + "/" + "data/Countries/PL.json", 'utf8', function (err, data) {714 715 res.end( data );716 });717});app.get('/country/PT', function (req, res , next) {718 fs.readFile( __dirname + "/" + "data/Countries/PT.json", 'utf8', function (err, data) {719 720 res.end( data );721 });722});app.get('/country/RO', function (req, res , next) {723 fs.readFile( __dirname + "/" + "data/Countries/RO.json", 'utf8', function (err, data) {724 725 res.end( data );726 });727});app.get('/country/SE', function (req, res , next) {728 fs.readFile( __dirname + "/" + "data/Countries/SE.json", 'utf8', function (err, data) {729 730 res.end( data );731 });732});app.get('/country/SI', function (req, res , next) {733 fs.readFile( __dirname + "/" + "data/Countries/SI.json", 'utf8', function (err, data) {734 735 res.end( data );736 });737});app.get('/country/SK', function (req, res , next) {738 fs.readFile( __dirname + "/" + "data/Countries/SK.json", 'utf8', function (err, data) {739 740 res.end( data );741 });742});app.get('/raw/PM10', function (req, res , next) {743 fs.readFile( __dirname + "/" + "data/rawdata/PM10.json", 'utf8', function (err, data) {744 745 res.end( data );746 });747});app.get('/raw/PM2_5', function (req, res , next) {748 fs.readFile( __dirname + "/" + "data/rawdata/PM2_5.json", 'utf8', function (err, data) {749 750 res.end( data );751 });752});app.get('/raw/NH3', function (req, res , next) {753 fs.readFile( __dirname + "/" + "data/rawdata/NH3.json", 'utf8', function (err, data) {754 755 res.end( data );756 });757});app.get('/raw/NMVOC', function (req, res , next) {758 fs.readFile( __dirname + "/" + "data/rawdata/NMVOC.json", 'utf8', function (err, data) {759 760 res.end( data );761 });762});app.get('/raw/NOX', function (req, res , next) {763 fs.readFile( __dirname + "/" + "data/rawdata/NOX.json", 'utf8', function (err, data) {764 765 res.end( data );766 });767});app.get('/raw/SOX', function (req, res , next) {768 fs.readFile( __dirname + "/" + "data/rawdata/SOX.json", 'utf8', function (err, data) {769 770 res.end( data );771 });772});773app.get('/rawdata/UK', function (req, res , next) {774 fs.readFile( __dirname + "/" + "data/rawdata/Countries/UK.json", 'utf8', function (err, data) {775 776 res.end( data );777 });778});779app.get('/rawdata/AT', function (req, res , next) {780 fs.readFile( __dirname + "/" + "data/rawdata/Countries/AT.json", 'utf8', function (err, data) {781 782 res.end( data );783 });784});785app.get('/rawdata/BE', function (req, res , next) {786 fs.readFile( __dirname + "/" + "data/rawdata/Countries/BE.json", 'utf8', function (err, data) {787 788 res.end( data );789 });790});app.get('/rawdata/BG', function (req, res , next) {791 fs.readFile( __dirname + "/" + "data/rawdata/Countries/BG.json", 'utf8', function (err, data) {792 793 res.end( data );794 });795});app.get('/rawdata/CH', function (req, res , next) {796 fs.readFile( __dirname + "/" + "data/rawdata/Countries/CH.json", 'utf8', function (err, data) {797 798 res.end( data );799 });800});app.get('/rawdata/CY', function (req, res , next) {801 fs.readFile( __dirname + "/" + "data/rawdata/Countries/CY.json", 'utf8', function (err, data) {802 803 res.end( data );804 });805});app.get('/rawdata/CZ', function (req, res , next) {806 fs.readFile( __dirname + "/" + "data/rawdata/Countries/CZ.json", 'utf8', function (err, data) {807 808 res.end( data );809 });810});app.get('/rawdata/DE', function (req, res , next) {811 fs.readFile( __dirname + "/" + "data/rawdata/Countries/DE.json", 'utf8', function (err, data) {812 813 res.end( data );814 });815});app.get('/rawdata/DK', function (req, res , next) {816 fs.readFile( __dirname + "/" + "data/rawdata/Countries/DK.json", 'utf8', function (err, data) {817 818 res.end( data );819 });820});app.get('/rawdata/EE', function (req, res , next) {821 fs.readFile( __dirname + "/" + "data/rawdata/Countries/EE.json", 'utf8', function (err, data) {822 823 res.end( data );824 });825});app.get('/rawdata/ES', function (req, res , next) {826 fs.readFile( __dirname + "/" + "data/rawdata/Countries/ES.json", 'utf8', function (err, data) {827 828 res.end( data );829 });830});app.get('/rawdata/FI', function (req, res , next) {831 fs.readFile( __dirname + "/" + "data/rawdata/Countries/FI.json", 'utf8', function (err, data) {832 833 res.end( data );834 });835});app.get('/rawdata/FR', function (req, res , next) {836 fs.readFile( __dirname + "/" + "data/rawdata/Countries/FR.json", 'utf8', function (err, data) {837 838 res.end( data );839 });840});app.get('/rawdata/HR', function (req, res , next) {841 fs.readFile( __dirname + "/" + "data/rawdata/Countries/HR.json", 'utf8', function (err, data) {842 843 res.end( data );844 });845});app.get('/rawdata/HU', function (req, res , next) {846 fs.readFile( __dirname + "/" + "data/rawdata/Countries/HU.json", 'utf8', function (err, data) {847 848 res.end( data );849 });850});app.get('/rawdata/IE', function (req, res , next) {851 fs.readFile( __dirname + "/" + "data/rawdata/Countries/IE.json", 'utf8', function (err, data) {852 853 res.end( data );854 });855});app.get('/rawdata/IT', function (req, res , next) {856 fs.readFile( __dirname + "/" + "data/rawdata/Countries/IT.json", 'utf8', function (err, data) {857 858 res.end( data );859 });860});app.get('/rawdata/LI', function (req, res , next) {861 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LI.json", 'utf8', function (err, data) {862 863 res.end( data );864 });865});app.get('/rawdata/LT', function (req, res , next) {866 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LT.json", 'utf8', function (err, data) {867 868 res.end( data );869 });870});app.get('/rawdata/LU', function (req, res , next) {871 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LU.json", 'utf8', function (err, data) {872 873 res.end( data );874 });875});app.get('/rawdata/LV', function (req, res , next) {876 fs.readFile( __dirname + "/" + "data/rawdata/Countries/LV.json", 'utf8', function (err, data) {877 878 res.end( data );879 });880});app.get('/rawdata/NL', function (req, res , next) {881 fs.readFile( __dirname + "/" + "data/rawdata/Countries/NL.json", 'utf8', function (err, data) {882 883 res.end( data );884 });885});app.get('/rawdata/NO', function (req, res , next) {886 fs.readFile( __dirname + "/" + "data/rawdata/Countries/NO.json", 'utf8', function (err, data) {887 888 res.end( data );889 });890});app.get('/rawdata/PL', function (req, res , next) {891 fs.readFile( __dirname + "/" + "data/rawdata/Countries/PL.json", 'utf8', function (err, data) {892 893 res.end( data );894 });895});app.get('/rawdata/PT', function (req, res , next) {896 fs.readFile( __dirname + "/" + "data/rawdata/Countries/PT.json", 'utf8', function (err, data) {897 898 res.end( data );899 });900});app.get('/rawdata/RO', function (req, res , next) {901 fs.readFile( __dirname + "/" + "data/rawdata/Countries/RO.json", 'utf8', function (err, data) {902 903 res.end( data );904 });905});app.get('/rawdata/SE', function (req, res , next) {906 fs.readFile( __dirname + "/" + "data/rawdata/Countries/SE.json", 'utf8', function (err, data) {907 908 res.end( data );909 });910});app.get('/rawdata/SI', function (req, res , next) {911 fs.readFile( __dirname + "/" + "data/rawdata/Countries/SI.json", 'utf8', function (err, data) {912 913 res.end( data );914 });915});app.get('/rawdata/SK', function (req, res , next) {916 fs.readFile( __dirname + "/" + "data/rawdata/Countries/SK.json", 'utf8', function (err, data) {917 918 res.end( data );919 });920 });921var server = app.listen(8081, function () {922 var host = server.address().address;923 var port = server.address().port;924 console.log("Example app listening at http://%s:%s", host, port);...
functionality.js
Source:functionality.js
1var temp = "";2var wordsArr = [];//Array to store my words3//arrays for checking word breakers4const lineChangeBreaker = ['\n', '\r']5const wordBreakersArr = ['[', ']', '(', ')', ' ', '+', '-', '/', '*', '%', '{', '}', '!', ',', '=', ':', '\n', '\r\n', '#', '@', '&', '-', '_','\\', '"', '^', '`', '|', '>', '<'];6const arithematicOperatorsArr = ['+', '-', '/', '*', '%'];7const relationalOperatorsArr = ['!', '|', '&'];8const isEqualArr = ['=']9const greaterThan = ['>', '<']10const spaceArr = [' '];11const stringArr = ['"'];12const multiLineCommentArr = ['/', '*'];13const BracketsArr=['(',')','[',']','{','}'];14const newLineBreakerArr=['\r'];15const otherBreakersArr=[':','#','@','_','^']16// const dotArr=['.'];17// const newLineReg= /\r?\n|\r/;18// var newLineFlag=true;19//A function to read a txt file as a string.20//This function breaks a word from string on the basis of spaces and word breakers21//Plus it stores the words in wordsArr as well as the symbols.22//We are treating symbols as word breakers and words as well23exports.wordBreak = (readFile) => {24 for (var i = 0; i <= readFile.length; i++) {25 // console.log(readFile[i])26 var flag = false;27 // console.log(readFile[i])28 // This was saving spaces as well29 // if(wordBreakersArr.includes(temp)){30 // wordsArr.push(temp);31 // temp=""32 // }33 // Will check if the string contains a word breaker34 if (wordBreakersArr.includes(readFile[i])) {35 //if yes then checks which word breaker is it.36 // Checking if temp is empty37 if (temp !== "") {38 // if (temp === ' ') {39 // wordsArr.push(temp);40 // temp = "";41 // } else {42 wordsArr.push(temp);43 temp = "";44 // }45 }46 //Using multiple arrays to check the word breaker47 if (isEqualArr.includes(readFile[i])) {48 // console.log("isEquals",readFile[i])49 // if (!readFile[i - 1] === '+' || !readFile[i - 1] === '*') {50 temp += readFile[i]51 if(readFile[i+1]==="=" && readFile[i+2]==="=" ){52 temp+=readFile[i+1];53 temp+=readFile[i+2];54 wordsArr.push(temp);55 temp=""56 i=i+2;57 }58 if(readFile[i+1]==="=" && readFile[i+2]!=="=" ){59 temp+=readFile[i+1];60 // temp+=readFile[i+2];61 wordsArr.push(temp);62 temp=""63 i=i+1;64 }65 if(readFile[i+1]!=="="){66 wordsArr.push(temp);67 temp=""68 }69 // Verifying how many = are written.70 // Local flag to verify if = count is finshied71 // var localflag = true72 // Looping73 // for (var p = i + 1; localflag; p++) {74 // if (readFile[p] === '=') {75 // temp += readFile[p]76 // } else {77 // wordsArr.push(temp);78 // temp = ""79 // i = p - 180 // break81 // }82 // }83 // }84 }85 if (arithematicOperatorsArr.includes(readFile[i])) {86 // Checking if +87 if (readFile[i] === '+') {88 temp += readFile[i];89 if (readFile[i + 1] === '+' || readFile[i + 1] === '=') {90 temp += readFile[i + 1];91 i = i + 1;92 wordsArr.push(temp)93 temp = ""94 }95 } else if (readFile[i] === '-') {96 temp += readFile[i]97 if (readFile[i + 1] === '-' || readFile[i + 1] === '=') {98 temp += readFile[i + 1];99 i = i + 1;100 wordsArr.push(temp)101 temp = ""102 }103 // if ((readFile[i] === '-') && (readFile[i + 1] === '-')) {104 // temp += readFile[i]105 // temp += readFile[i + 1]106 // wordsArr.push(temp)107 // temp = "";108 // i = i + 2;109 // // console.log(i)110 // }111 // if ((readFile[i] === '-') && (readFile[i + 1] !== '-')) {112 // temp += readFile[i]113 // console.log('SingleMinus', temp)114 // wordsArr.push(temp)115 // temp = "";116 // i++;117 // }118 } else if (readFile[i] === '*') {119 // Multiline comments120 if ((readFile[i + 1] === '/') || (readFile[i - 1] === '/')) {121 temp += readFile[i];122 temp = ""123 }124 // Multiplication125 if (readFile[i + 1] === '=') {126 temp += readFile[i]127 temp += readFile[i + 1]128 i = i + 1;129 wordsArr.push(temp)130 temp = ""131 }132 } else if (readFile[i] === '/') {133 if (readFile[i + 1] === '/') {134 // Single line comment135 for (var p = i + 2; true; p++) {136 if (lineBreaker.includes(readFile[p])) {137 // Remove all138 temp = ""139 // Set index, p-1 because i will be incremented at for loop140 i = p - 1141 break;142 }143 }144 } else if ((readFile[i + 1] === '=')) {145 temp += readFile[i]146 temp += readFile[i + 1]147 i = i + 1;148 wordsArr.push(temp)149 temp = ""150 } else {151 temp += readFile[i]152 wordsArr.push(temp)153 temp = ""154 }155 } else if (readFile[i] === '%') {156 if (readFile[i + 1] === '=') {157 temp += readFile[i]158 temp += readFile[i + 1]159 i = i + 1;160 wordsArr.push(temp)161 temp = ""162 } else {163 temp += readFile[i]164 wordsArr.push(temp)165 temp = ""166 }167 }168 }169 if (relationalOperatorsArr.includes(readFile[i])) {170 if (readFile[i] === '!') {171 temp += readFile[i]172 if (readFile[i + 1] === '=') {173 console.log(readFile[i + 1], i + 1)174 temp += readFile[i + 1]175 i = i + 1;176 }177 } else if (readFile[i] === '|') {178 temp += readFile[i]179 if (readFile[i + 1] === '|') {180 temp += readFile[i + 1]181 i = i + 1;182 }183 } else if (readFile[i] === '&') {184 temp += readFile[i]185 // console.log(temp)186 if (readFile[i + 1] === '&') {187 temp += readFile[i + 1]188 i = i + 1;189 }190 }191 }192 if (greaterThan.includes(readFile[i])) {193 temp += readFile[i]194 // console.log(temp)195 if (readFile[i + 1] === '=') {196 temp += readFile[i + 1]197 // console.log(temp)198 i++;199 // console.log(temp)200 }201 var flag = true;202 }203 if (spaceArr.includes(readFile[i])) {204 // console.log('spaceARr')205 // console.log(readFile[i],i)206 // temp += readFile[i]207 // var flag = true;208 }209 if (stringArr.includes(readFile[i])) {210 temp+=readFile[i]211 // console.log("temp",temp)212 // var u=i;213 for(var u=i+1;u<=readFile.length;u++){214 if(stringArr[0]===readFile[u]){215 temp+=readFile[u]216 break;217 }218 temp+=readFile[u]219 }220 wordsArr.push(temp)221 i=u;222 temp="";223 }224 if(BracketsArr.includes(readFile[i])){225 temp+=readFile[i]226 wordsArr.push(temp);227 temp=""228 }229 if(otherBreakersArr.includes(readFile[i])){230 temp+=readFile[i]231 wordsArr.push(temp);232 temp=""233 }234 235 //if there is not a word breaker236 } else if (!flag) {237 //finishing comments and then dumping them238 if ((readFile[i - 1] === '*') && (readFile[i - 2] === '/')) {239 var flagcom = false240 // temp=""241 while (!flagcom) {242 temp += readFile[i];243 temp = "";244 i++;245 if ((readFile[i + 1] === '*') && (readFile[i + 2] === '/')) {246 flagcom = true;247 }248 }249 } 250 //storing alphabets and number in temp251 else {252 // console.log("temp",temp)253 // var result=newLineReg.test(word)254 255 temp += readFile[i];256 // temp.replace('\r','');257 // console.log(temp)258 // if(temp.includes("\r")){259 // console.log("word22",temp)260 // }261 // if(temp.includes("\r")){262 // console.log("temp",temp)263 // temp.replace('\r','');264 // console.log()265 // }266 // temp.replace('\r','');267 // console.log("temp",temp)268 // temporary+=temp;269 // if(newLineReg.test(temp)){270 // console.log("true",temp)271 // temp="";272 // console.log("secondTemp",temp)273 // }274 // if(readFile[i+1]==="\r"){275 276 // }277 // console.log("temp",temp)278 }279 }280 }281 //returning words arr to index.js where the words are further categorized and tokens are generated.282 return wordsArr...
gulp.js
Source:gulp.js
1import '../src'2import bufferEqual from 'buffer-equal'3import convert from 'convert-source-map'4import gulp from 'gulp'5import timeout from 'timeout-then'6import rump from 'rump'7import {colors} from 'gulp-util'8import {exists, readFile, writeFile} from 'mz/fs'9import {resolve, sep} from 'path'10import {spy} from 'sinon'11const protocol = process.platform === 'win32' ? 'file:///' : 'file://',12 {stripColor} = colors13describe('tasks', function() {14 this.timeout(0)15 afterEach(() => {16 rump.configure({environment: 'development', paths: {17 source: {root: 'test/fixtures', styles: ''},18 destination: {root: 'tmp', styles: '', images: 'images'},19 }})20 })21 it('are added and defined', () => {22 const callback = spy()23 rump.on('gulp:main', callback)24 rump.on('gulp:styles', callback)25 rump.addGulpTasks({prefix: 'spec'})26 callback.should.be.calledTwice()27 gulp.tasks['spec:info:styles'].should.be.ok()28 gulp.tasks['spec:build:styles'].should.be.ok()29 gulp.tasks['spec:watch:styles'].should.be.ok()30 })31 it('displays correct information in info task', () => {32 const logs = [],33 {log} = console34 console.log = newLog35 gulp.start('spec:info')36 console.log = log37 logs.slice(-9).should.eql([38 '',39 '--- Styles v0.8.1',40 `Processed CSS files from test${sep}fixtures are copied with source maps to tmp`,41 'Affected files:',42 'index.css',43 'less.less',44 'sass.scss',45 'stylus.styl',46 '',47 ])48 logs.length = 049 console.log = newLog50 gulp.start('spec:info:prod')51 console.log = log52 logs.slice(-9).should.eql([53 '',54 '--- Styles v0.8.1',55 `Processed CSS files from test${sep}fixtures are minified and copied to tmp`,56 'Affected files:',57 'index.css',58 'less.less',59 'sass.scss',60 'stylus.styl',61 '',62 ])63 rump.reconfigure({paths: {source: {styles: 'nonexistant'}}})64 logs.length = 065 console.log = newLog66 gulp.start('spec:info')67 console.log = log68 logs.length.should.not.be.above(4)69 function newLog(...args) {70 logs.push(stripColor(args.join(' ')))71 }72 })73 it('for building', async() => {74 await new Promise(resolve => {75 gulp.task('postbuild', ['spec:build'], resolve)76 gulp.start('postbuild')77 })78 const filesExists = await Promise.all([79 exists('tmp/index.css'),80 exists('tmp/less.css'),81 exists('tmp/sass.css'),82 exists('tmp/stylus.css'),83 ])84 filesExists.forEach(x => x.should.be.true())85 })86 describe('for watching', () => {87 let originals88 before(async() => {89 originals = await Promise.all([90 readFile('test/fixtures/index.css'),91 readFile('test/fixtures/lib/variables.css'),92 readFile('test/fixtures/less.less'),93 readFile('test/fixtures/lib/variables.less'),94 readFile('test/fixtures/sass.scss'),95 readFile('test/fixtures/lib/variables.scss'),96 readFile('test/fixtures/stylus.styl'),97 readFile('test/fixtures/lib/variables.styl'),98 ])99 await new Promise(resolve => {100 gulp.task('postwatch', ['spec:watch'], resolve)101 gulp.start('postwatch')102 })103 })104 beforeEach(() => timeout(1000))105 afterEach(() => Promise.all([106 writeFile('test/fixtures/index.css', originals[0]),107 writeFile('test/fixtures/lib/variables.css', originals[1]),108 writeFile('test/fixtures/less.less', originals[2]),109 writeFile('test/fixtures/lib/variables.less', originals[3]),110 writeFile('test/fixtures/sass.scss', originals[4]),111 writeFile('test/fixtures/lib/variables.scss', originals[5]),112 writeFile('test/fixtures/stylus.styl', originals[6]),113 writeFile('test/fixtures/lib/variables.styl', originals[7]),114 ]))115 it('handles image paths for Sass', async() => {116 const content = await readFile('tmp/sass.css')117 content118 .toString()119 .should120 .containEql('background-image: url("images/sample.png")')121 })122 it('handles updates', async() => {123 const firstContents = await Promise.all([124 readFile('tmp/index.css'),125 readFile('tmp/less.css'),126 readFile('tmp/sass.css'),127 readFile('tmp/stylus.css'),128 ])129 let secondContents130 await timeout(1000)131 await Promise.all([132 writeFile('test/fixtures/lib/variables.css', ':root{--color:black}'),133 writeFile('test/fixtures/lib/variables.less', '@color: black;'),134 writeFile('test/fixtures/lib/variables.scss', '$color: black;'),135 writeFile('test/fixtures/lib/variables.styl', 'color = black'),136 ])137 await timeout(1000)138 secondContents = await Promise.all([139 readFile('tmp/index.css'),140 readFile('tmp/less.css'),141 readFile('tmp/sass.css'),142 readFile('tmp/stylus.css'),143 ])144 firstContents.forEach((firstContent, index) => {145 bufferEqual(firstContent, secondContents[index]).should.be.false()146 })147 })148 it('handles autoprefix', async() => {149 const contents = await Promise.all([150 readFile('tmp/index.css'),151 readFile('tmp/less.css'),152 readFile('tmp/sass.css'),153 readFile('tmp/stylus.css'),154 ])155 contents.map(content => {156 content.toString().should.containEql('display: flex')157 content.toString().should.containEql('display: -webkit-flex')158 })159 })160 it('handles source maps in development', async() => {161 const css = readFile('tmp/index.css'),162 less = readFile('tmp/less.css'),163 sass = readFile('tmp/sass.css'),164 stylus = readFile('tmp/stylus.css'),165 contents = await Promise.all([css, less, sass, stylus]),166 pathSet = contents167 .map(x => convert.fromSource(x.toString()))168 .map(x => x.getProperty('sources').sort()),169 paths = [].concat(...pathSet)170 .filter(x => x)171 .map(x => x.replace(protocol, '').split('/').join(sep))172 paths.should.eql([173 resolve('node_modules/normalize.css/normalize.css'),174 resolve('test/fixtures/index.css'),175 resolve('node_modules/bootstrap/less/buttons.less'),176 resolve('node_modules/bootstrap/less/mixins/buttons.less'),177 resolve('node_modules/bootstrap/less/mixins/opacity.less'),178 resolve('node_modules/bootstrap/less/mixins/tab-focus.less'),179 resolve('node_modules/bootstrap/less/mixins/vendor-prefixes.less'),180 resolve('node_modules/normalize.css/normalize.css'),181 resolve('test/fixtures/less.less'),182 resolve('node_modules/normalize-compass/normalize.scss'),183 resolve('test/fixtures/sass.scss'),184 resolve('node_modules/normalize.css/normalize.css'),185 resolve('test/fixtures/stylus.styl'),186 ])187 })188 it('handles minification in production', async() => {189 const firstContents = await Promise.all([190 readFile('tmp/index.css'),191 readFile('tmp/less.css'),192 readFile('tmp/sass.css'),193 readFile('tmp/stylus.css'),194 ])195 let secondContents196 rump.reconfigure({environment: 'production'})197 await timeout(1000)198 await Promise.all([199 writeFile('test/fixtures/lib/variables.css', ':root{--color:orange}'),200 writeFile('test/fixtures/lib/variables.less', '@color: orange;'),201 writeFile('test/fixtures/lib/variables.scss', '$color: orange;'),202 writeFile('test/fixtures/lib/variables.styl', 'color = orange'),203 ])204 await timeout(1000)205 secondContents = await Promise.all([206 readFile('tmp/index.css'),207 readFile('tmp/less.css'),208 readFile('tmp/sass.css'),209 readFile('tmp/stylus.css'),210 ])211 firstContents.forEach((firstContent, index) => {212 firstContent.length.should.be.above(secondContents[index].length)213 })214 })215 })...
nulls.js
Source:nulls.js
1import fs from 'fs-extra';2import readFile from '../read-file.js';3import cordovaSetVersion from '../../index.js';4import {5 temporaryConfigFile,6 temporaryProvidedConfigFile,7 entryConfigFiles,8 expectedXmlFiles,9} from '../configs/index.js';10import { temporaryPackageFile, entryPackageFiles } from '../packages/index.js';11function nullsTest() {12 describe('nulls', () => {13 beforeEach(() => {14 fs.copySync(entryConfigFiles.VERSION_AND_BUILD, temporaryConfigFile);15 fs.copySync(16 entryConfigFiles.VERSION_AND_BUILD,17 temporaryProvidedConfigFile,18 );19 fs.copySync(entryPackageFiles.GOOD, temporaryPackageFile);20 });21 test('({})', async () => {22 await cordovaSetVersion({});23 expect(readFile(temporaryConfigFile)).toBe(24 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),25 );26 });27 test('({ buildNumber: null })', async () => {28 await cordovaSetVersion({ buildNumber: null });29 expect(readFile(temporaryConfigFile)).toBe(30 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),31 );32 });33 test('({ version: null })', async () => {34 await cordovaSetVersion({ buildNumber: null });35 expect(readFile(temporaryConfigFile)).toBe(36 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),37 );38 });39 test('({ version: null, buildNumber: null })', async () => {40 await cordovaSetVersion({ version: null, buildNumber: null });41 expect(readFile(temporaryConfigFile)).toBe(42 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),43 );44 });45 test('({ version: null, buildNumber: 86 })', async () => {46 await cordovaSetVersion({ version: null, buildNumber: 86 });47 expect(readFile(temporaryConfigFile)).toBe(48 readFile(expectedXmlFiles.BUILD_TO_VERSION_AND_BUILD),49 );50 });51 test("({ version: '2.4.9', buildNumber: null })", async () => {52 await cordovaSetVersion({ version: '2.4.9', buildNumber: null });53 expect(readFile(temporaryConfigFile)).toBe(54 readFile(expectedXmlFiles.VERSION_TO_VERSION_AND_BUILD),55 );56 });57 test('({ configPath: null })', async () => {58 await cordovaSetVersion({ configPath: null });59 expect(readFile(temporaryConfigFile)).toBe(60 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),61 );62 });63 test('({ configPath: null, buildNumber: null })', async () => {64 await cordovaSetVersion({ configPath: null, buildNumber: null });65 expect(readFile(temporaryConfigFile)).toBe(66 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),67 );68 });69 test('({ configPath: null, buildNumber: 86 })', async () => {70 await cordovaSetVersion({ configPath: null, buildNumber: 86 });71 expect(readFile(temporaryConfigFile)).toBe(72 readFile(expectedXmlFiles.BUILD_TO_VERSION_AND_BUILD),73 );74 });75 test('({ configPath: null, version: null })', async () => {76 await cordovaSetVersion({ configPath: null, version: null });77 expect(readFile(temporaryConfigFile)).toBe(78 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),79 );80 });81 test('({ configPath: null, version: null, buildNumber: null })', async () => {82 await cordovaSetVersion({83 configPath: null,84 version: null,85 buildNumber: null,86 });87 expect(readFile(temporaryConfigFile)).toBe(88 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),89 );90 });91 test('({ configPath: null, version: null, buildNumber: 86 })', async () => {92 await cordovaSetVersion({93 configPath: null,94 version: null,95 buildNumber: 86,96 });97 expect(readFile(temporaryConfigFile)).toBe(98 readFile(expectedXmlFiles.BUILD_TO_VERSION_AND_BUILD),99 );100 });101 test("({ configPath: null, version: '2.4.9' })", async () => {102 await cordovaSetVersion({ configPath: null, version: '2.4.9' });103 expect(readFile(temporaryConfigFile)).toBe(104 readFile(expectedXmlFiles.VERSION_TO_VERSION_AND_BUILD),105 );106 });107 test("({ configPath: null, version: '2.4.9', buildNumber: null })", async () => {108 await cordovaSetVersion({109 configPath: null,110 version: '2.4.9',111 buildNumber: null,112 });113 expect(readFile(temporaryConfigFile)).toBe(114 readFile(expectedXmlFiles.VERSION_TO_VERSION_AND_BUILD),115 );116 });117 test("({ configPath: null, version: '2.4.9', buildNumber: 86 })", async () => {118 await cordovaSetVersion({119 configPath: null,120 version: '2.4.9',121 buildNumber: 86,122 });123 expect(readFile(temporaryConfigFile)).toBe(124 readFile(expectedXmlFiles.VERSION_AND_BUILD_TO_VERSION_AND_BUILD),125 );126 });127 test('({ configPath: temporaryProvidedConfigFile, buildNumber: null })', async () => {128 await cordovaSetVersion({129 configPath: temporaryProvidedConfigFile,130 buildNumber: null,131 });132 expect(readFile(temporaryProvidedConfigFile)).toBe(133 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),134 );135 });136 test('({ configPath: temporaryProvidedConfigFile, version: null })', async () => {137 await cordovaSetVersion({138 configPath: temporaryProvidedConfigFile,139 version: null,140 });141 expect(readFile(temporaryProvidedConfigFile)).toBe(142 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),143 );144 });145 test('({ configPath: temporaryProvidedConfigFile, version: null, buildNumber: null })', async () => {146 await cordovaSetVersion({147 configPath: temporaryProvidedConfigFile,148 version: null,149 buildNumber: null,150 });151 expect(readFile(temporaryProvidedConfigFile)).toBe(152 readFile(expectedXmlFiles.PACKAGE_VERSION_TO_VERSION_AND_BUILD),153 );154 });155 test('({ configPath: temporaryProvidedConfigFile, version: null, buildNumber: 86 })', async () => {156 await cordovaSetVersion({157 configPath: temporaryProvidedConfigFile,158 version: null,159 buildNumber: 86,160 });161 expect(readFile(temporaryProvidedConfigFile)).toBe(162 readFile(expectedXmlFiles.BUILD_TO_VERSION_AND_BUILD),163 );164 });165 test("({ configPath: temporaryProvidedConfigFile, version: '2.4.9', buildNumber: null })", async () => {166 await cordovaSetVersion({167 configPath: temporaryProvidedConfigFile,168 version: '2.4.9',169 buildNumber: null,170 });171 expect(readFile(temporaryProvidedConfigFile)).toBe(172 readFile(expectedXmlFiles.VERSION_TO_VERSION_AND_BUILD),173 );174 });175 });176}...
help.js
Source:help.js
1/**2 * New node file3 */4var logger = require("../lib/logger");5var androidgcm = require("../controllers/androidpush");6var fs = require('fs'); 7exports.help = function(req,res,next) {8 9 function tableData(APIInfo,route,method,jsondata,headers)10 {11 this.APIInfo = APIInfo;12 this.route= route;13 this.method = method;14 this.jsondata = jsondata;15 this.headers = headers;16 }17 var values = [];18 fs.readFile('./payload/Register.json', handleFile);19 fs.readFile('./payload/Login.json', handleFile);20 fs.readFile('./payload/check userlogin on registration.json', handleFile);21 fs.readFile('./payload/check phone on registration.json', handleFile);22 fs.readFile('./payload/List Auth.json', handleFile);23 fs.readFile('./payload/Update Auth.json', handleFile);24 fs.readFile('./payload/resetpassword.json', handleFile);25 fs.readFile('./payload/List User.json', handleFile);26 fs.readFile('./payload/Update User.json', handleFile); 27 fs.readFile('./payload/List Address.json', handleFile);28 fs.readFile('./payload/Update Address.json', handleFile);29 fs.readFile('./payload/Add Address.json', handleFile);30 fs.readFile('./payload/List Vehicle.json', handleFile);31 fs.readFile('./payload/Update Vehicle.json', handleFile);32 fs.readFile('./payload/Add Vehicle.json', handleFile);33 fs.readFile('./payload/Add a ride request.json', handleFile);34 fs.readFile('./payload/uRides.json', handleFile);35 fs.readFile('./payload/Reply to ride request.json', handleFile); 36 fs.readFile('./payload/Confirm ride request.json', handleFile);37 fs.readFile('./payload/uRideHistory.json', handleFile);38 fs.readFile('./payload/TrackRides.json', handleFile);39 fs.readFile('./payload/cancelConfimedRideByRider.json', handleFile);40 fs.readFile('./payload/uDrives.json', handleFile);41 fs.readFile('./payload/uDriveHistory.json', handleFile);42 fs.readFile('./payload/cancelConfimedRideByDriver.json', handleFile);43 fs.readFile('./payload/listContactsToAddGroupMembers.json', handleFile);44 fs.readFile('./payload/DeleteContact.json', handleFile);45 fs.readFile('./payload/List contacts during ride request.json', handleFile);46 fs.readFile('./payload/List app using phone contacts.json', handleFile);47 fs.readFile('./payload/Change status to invited.json', handleFile); 48 fs.readFile('./payload/Schedule - get.json', handleFile);49 fs.readFile('./payload/Schedule - Add.json', handleFile);50 fs.readFile('./payload/Schedule - update.json', handleFile);51 fs.readFile('./payload/Schdeule - delete.json', handleFile);52 fs.readFile('./payload/save registration id for GCM.json', handleFile);53 fs.readFile('./payload/create group.json', handleFile);54 fs.readFile('./payload/update group.json', handleFile); 55 fs.readFile('./payload/delete group.json', handleFile);56 fs.readFile('./payload/List groups for a user.json', handleFile);57 58 59 60 61 fs.readFile('./payload/List All User.json', handleFile); 62 63 fs.readFile('./payload/add members to group.json', handleFile);64 65 66 fs.readFile('./payload/delete members in group.json', handleFile);67 fs.readFile('./payload/list app using contacts.json', handleFile);68 69 70 fs.readFile('./payload/List app using phone contacts.json', handleFile); 71 72 73 74 75 76 fs.readFile('./payload/Get tracking details.json', handleFile);77 fs.readFile('./payload/Update tracking details.json', handleFile);78 79 80 81 82 83 84 function handleFile(err, data) {85 if (err) throw err86 obj = JSON.parse(data);87 console.log(obj);88 if(obj.jsondata != "NA") // if it is JSON data89 values.push(new tableData(obj.APIInfo,obj.route,obj.method,JSON.stringify(obj.jsondata),obj.headers));90 else // If value is NA 91 values.push(new tableData(obj.APIInfo,obj.route,obj.method,obj.jsondata,obj.headers));92 console.log(values.length);Â 93 if(values.length == 32)94 res.render("help",{data : values}); 95 } ...
test-esm-live-binding.mjs
Source:test-esm-live-binding.mjs
1// Flags: --experimental-modules2import '../common';3import assert from 'assert';4import fs, { readFile, readFileSync } from 'fs';5import events, { defaultMaxListeners } from 'events';6import util from 'util';7const readFileDescriptor = Reflect.getOwnPropertyDescriptor(fs, 'readFile');8const readFileSyncDescriptor =9 Reflect.getOwnPropertyDescriptor(fs, 'readFileSync');10const s = Symbol();11const fn = () => s;12Reflect.deleteProperty(fs, 'readFile');13assert.deepStrictEqual([fs.readFile, readFile], [undefined, undefined]);14fs.readFile = fn;15assert.deepStrictEqual([fs.readFile(), readFile()], [s, s]);16Reflect.defineProperty(fs, 'readFile', {17 value: fn,18 configurable: true,19 writable: true,20});21assert.deepStrictEqual([fs.readFile(), readFile()], [s, s]);22Reflect.deleteProperty(fs, 'readFile');23assert.deepStrictEqual([fs.readFile, readFile], [undefined, undefined]);24let count = 0;25Reflect.defineProperty(fs, 'readFile', {26 get() { return count; },27 configurable: true,28});29count++;30assert.deepStrictEqual([readFile, fs.readFile, readFile], [0, 1, 1]);31let otherValue;32Reflect.defineProperty(fs, 'readFile', { // eslint-disable-line accessor-pairs33 set(value) {34 Reflect.deleteProperty(fs, 'readFile');35 otherValue = value;36 },37 configurable: true,38});39Reflect.defineProperty(fs, 'readFileSync', {40 get() {41 return otherValue;42 },43 configurable: true,44});45fs.readFile = 2;46assert.deepStrictEqual([readFile, readFileSync], [undefined, 2]);47Reflect.defineProperty(fs, 'readFile', readFileDescriptor);48Reflect.defineProperty(fs, 'readFileSync', readFileSyncDescriptor);49const originDefaultMaxListeners = events.defaultMaxListeners;50const utilProto = util.__proto__; // eslint-disable-line no-proto51count = 0;52Reflect.defineProperty(Function.prototype, 'defaultMaxListeners', {53 configurable: true,54 enumerable: true,55 get: function() { return ++count; },56 set: function(v) {57 Reflect.defineProperty(this, 'defaultMaxListeners', {58 configurable: true,59 enumerable: true,60 writable: true,61 value: v,62 });63 },64});65assert.strictEqual(defaultMaxListeners, originDefaultMaxListeners);66assert.strictEqual(events.defaultMaxListeners, originDefaultMaxListeners);67assert.strictEqual(++events.defaultMaxListeners,68 originDefaultMaxListeners + 1);69assert.strictEqual(defaultMaxListeners, originDefaultMaxListeners + 1);70assert.strictEqual(Function.prototype.defaultMaxListeners, 1);71Function.prototype.defaultMaxListeners = 'foo';72assert.strictEqual(Function.prototype.defaultMaxListeners, 'foo');73assert.strictEqual(events.defaultMaxListeners, originDefaultMaxListeners + 1);74assert.strictEqual(defaultMaxListeners, originDefaultMaxListeners + 1);75count = 0;76const p = {77 get foo() { return ++count; },78 set foo(v) {79 Reflect.defineProperty(this, 'foo', {80 configurable: true,81 enumerable: true,82 writable: true,83 value: v,84 });85 },86};87util.__proto__ = p; // eslint-disable-line no-proto88assert.strictEqual(util.foo, 1);89util.foo = 'bar';90assert.strictEqual(count, 1);91assert.strictEqual(util.foo, 'bar');92assert.strictEqual(p.foo, 2);93p.foo = 'foo';94assert.strictEqual(p.foo, 'foo');95events.defaultMaxListeners = originDefaultMaxListeners;96util.__proto__ = utilProto; // eslint-disable-line no-proto97Reflect.deleteProperty(util, 'foo');98Reflect.deleteProperty(Function.prototype, 'defaultMaxListeners');99assert.throws(100 () => Object.defineProperty(events, 'defaultMaxListeners', { value: 3 }),101 /TypeError: Cannot redefine/...
posthtml.config.js
Source:posthtml.config.js
1module.exports = {2 plugins: {3 '@ut-essentials/posthtml-pipeline': {4 pipelinePlugins: [5 require('@ut-essentials/posthtml-extends').default(),6 require('@ut-essentials/posthtml-tokens').default({7 tokens: {8 global: {9 '[[title]]': 'Template Project',10 '[[page_name]]': 'Content Header',11 '[phone]': '1-800-922-2488',12 '[license number]': 'Contractor License #826234',13 '[[city_scroll:50]]': ({ readFile }) =>14 readFile('./src/tokens/city_scroll.html'),15 '[[breadcrumbs]]': ({ readFile }) =>16 readFile('./src/tokens/breadcrumbs.html'),17 '[[breadcrumbs]]': ({ readFile }) =>18 readFile('./src/tokens/breadcrumbs.html'),19 '[[single_silo_nav]]': ({ readFile }) =>20 readFile('./src/tokens/single_silo_nav.html'),21 '[[content]]': ({ readFile }) =>22 readFile('./src/tokens/content.html'),23 '[[top_nav]]': ({ readFile }) =>24 readFile('./src/tokens/top_nav.html'),25 '[[bottom_nav]]': ({ readFile }) =>26 readFile('./src/tokens/bottom_nav.html'),27 '[[display_addresses]]': ({ readFile }) =>28 readFile('./src/tokens/display_addresses.html'),29 },30 },31 }),32 ],33 plugins: [require('posthtml-expressions')()],34 },35 },...
sync.js
Source:sync.js
1var fs = require('fs');2function readfile( fileName ) {3 return fs.readFileSync( fileName , 'utf8');4}5var start = Date.now();6console.log(start, 'start');7readfile('largeFile.tgz');8readfile('largeFile.tgz');9readfile('largeFile.tgz');10readfile('largeFile.tgz');11readfile('largeFile.tgz');12readfile('largeFile.tgz');13readfile('largeFile.tgz');14readfile('largeFile.tgz');15readfile('largeFile.tgz');16readfile('largeFile.tgz');17readfile('largeFile.tgz');18readfile('largeFile.tgz');19readfile('largeFile.tgz');20readfile('largeFile.tgz');21readfile('largeFile.tgz');22readfile('largeFile.tgz');23readfile('largeFile.tgz');24readfile('largeFile.tgz');25readfile('largeFile.tgz');26readfile('largeFile.tgz');27readfile('largeFile.tgz');28readfile('largeFile.tgz');29readfile('largeFile.tgz');30readfile('largeFile.tgz');31readfile('largeFile.tgz');32readfile('largeFile.tgz');...
Using AI Code Generation
1var fs = require('fs');2fs.readFile('test3.js', function(err, data){3 if(err) throw err;4 console.log(data);5});6var fs = require('fs');7fs.readFile('test3.js', function(err, data){8 if(err) throw err;9 console.log(data.toString());10});11var fs = require('fs');12fs.readFile('test3.js', function(err, data){13 if(err) throw err;14 console.log(data.toString().split(' '));15});16var fs = require('fs');17fs.readFile('test3.js', function(err, data){18 if(err) throw err;19 console.log(data.toString().split(' ').length);20});21var fs = require('fs');22fs.readFile('test3.js', function(err, data){23 if(err) throw err;24 console.log(data.toString().split(' ').length);25});26var fs = require('fs');27fs.readFile('test3.js', function(err, data){28 if(err) throw err;29 console.log(data.toString().split(' ').length);30});31var fs = require('fs');32fs.readFile('test3.js', function(err, data){33 if(err) throw err;34 console.log(data.toString().split(' ').length);35});
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!!