How to use encode method in Karma

Best JavaScript code snippet using karma

ProductFactory.js

Source:ProductFactory.js Github

copy

Full Screen

1app.factory('ProductFactory', function($http, $location){2 var factory = {};3 4 factory.get_user = function(data){5 var promise = $http({6 url:'./FUNCTIONS/Users/get_user.php', 7 method: 'POST',8 headers: {'Content-Type': 'application/x-www-form-urlencoded'},9 transformRequest: function(obj) {10 var str = [];11 for(var p in obj)12 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));13 return str.join("&");14 },15 data : data16 }) 17 return promise;18 };19 factory.exchange_item = function(data){20 var promise = $http({21 url:'./FUNCTIONS/Admin/exchange_item.php', 22 method: 'POST',23 headers: {'Content-Type': 'application/x-www-form-urlencoded'},24 transformRequest: function(obj) {25 var str = [];26 for(var p in obj)27 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));28 return str.join("&");29 },30 data : data31 }) 32 return promise;33 };34 factory.get_barcode = function(data){35 var promise = $http({36 url:'./FUNCTIONS/Product/get_barcode.php', 37 method: 'POST',38 headers: {'Content-Type': 'application/x-www-form-urlencoded'},39 transformRequest: function(obj) {40 var str = [];41 for(var p in obj)42 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));43 return str.join("&");44 },45 data : data46 }) 47 return promise;48 };49 factory.upload_inventory = function(data){50 var promise = $http({51 url:'./FUNCTIONS/Uploads/upload_inventory.php', 52 method: 'POST',53 headers: {'Content-Type': 'application/x-www-form-urlencoded'},54 transformRequest: function(obj) {55 var str = [];56 for(var p in obj)57 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));58 return str.join("&");59 },60 data : data61 }) 62 return promise;63 };64 factory.tender_product_final_down_payment = function(data){65 var promise = $http({66 url:'./FUNCTIONS/Product/tender_product_final_down_payment.php', 67 method: 'POST',68 headers: {'Content-Type': 'application/x-www-form-urlencoded'},69 transformRequest: function(obj) {70 var str = [];71 for(var p in obj)72 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));73 return str.join("&");74 },75 data : data76 }) 77 return promise;78 };79 factory.refund_item = function(data){80 var promise = $http({81 url:'./FUNCTIONS/Product/refund_item.php', 82 method: 'POST',83 headers: {'Content-Type': 'application/x-www-form-urlencoded'},84 transformRequest: function(obj) {85 var str = [];86 for(var p in obj)87 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));88 return str.join("&");89 },90 data : data91 }) 92 return promise;93 };94 factory.get_customer_payment_filter = function(data){95 var promise = $http({96 url:'./FUNCTIONS/Customer/get_customer_payment_filter.php', 97 method: 'POST',98 headers: {'Content-Type': 'application/x-www-form-urlencoded'},99 transformRequest: function(obj) {100 var str = [];101 for(var p in obj)102 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));103 return str.join("&");104 },105 data : data106 }) 107 return promise;108 };109 factory.payment = function(data){110 var promise = $http({111 url:'./FUNCTIONS/Customer/payment.php', 112 method: 'POST',113 headers: {'Content-Type': 'application/x-www-form-urlencoded'},114 transformRequest: function(obj) {115 var str = [];116 for(var p in obj)117 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));118 return str.join("&");119 },120 data : data121 }) 122 return promise;123 };124 factory.get_customer_payment = function(data){125 var promise = $http({126 url:'./FUNCTIONS/Customer/get_customer_payment.php', 127 method: 'POST',128 headers: {'Content-Type': 'application/x-www-form-urlencoded'},129 transformRequest: function(obj) {130 var str = [];131 for(var p in obj)132 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));133 return str.join("&");134 },135 data : data136 }) 137 return promise;138 };139 factory.update_pin = function(data){140 var promise = $http({141 url:'./FUNCTIONS/Users/update_pin.php', 142 method: 'POST',143 headers: {'Content-Type': 'application/x-www-form-urlencoded'},144 transformRequest: function(obj) {145 var str = [];146 for(var p in obj)147 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));148 return str.join("&");149 },150 data : data151 }) 152 return promise;153 };154 factory.add_branch = function(data){155 var promise = $http({156 url:'./FUNCTIONS/Admin/add_branch.php', 157 method: 'POST',158 headers: {'Content-Type': 'application/x-www-form-urlencoded'},159 transformRequest: function(obj) {160 var str = [];161 for(var p in obj)162 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));163 return str.join("&");164 },165 data : data166 }) 167 return promise;168 };169 170 factory.edit_article_data = function(data){171 var promise = $http({172 url:'./FUNCTIONS/Newsfeed/edit_article_data.php', 173 method: 'POST',174 headers: {'Content-Type': 'application/x-www-form-urlencoded'},175 transformRequest: function(obj) {176 var str = [];177 for(var p in obj)178 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));179 return str.join("&");180 },181 data : data182 }) 183 return promise;184 };185 factory.get_news_flash = function(data){186 var promise = $http({187 url:'./FUNCTIONS/Newsfeed/get_news_flash.php', 188 method: 'POST',189 headers: {'Content-Type': 'application/x-www-form-urlencoded'},190 transformRequest: function(obj) {191 var str = [];192 for(var p in obj)193 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));194 return str.join("&");195 },196 data : data197 }) 198 return promise;199 };200 factory.add_articles = function(data){201 var promise = $http({202 url:'./FUNCTIONS/Newsfeed/add_articles.php', 203 method: 'POST',204 headers: {'Content-Type': 'application/x-www-form-urlencoded'},205 transformRequest: function(obj) {206 var str = [];207 for(var p in obj)208 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));209 return str.join("&");210 },211 data : data212 }) 213 return promise;214 };215 factory.edit_ads_data = function(data){216 var promise = $http({217 url:'./FUNCTIONS/Newsfeed/edit_ads_data.php', 218 method: 'POST',219 headers: {'Content-Type': 'application/x-www-form-urlencoded'},220 transformRequest: function(obj) {221 var str = [];222 for(var p in obj)223 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));224 return str.join("&");225 },226 data : data227 }) 228 return promise;229 };230 231 factory.add_ads = function(data){232 var promise = $http({233 url:'./FUNCTIONS/Newsfeed/add_ads.php', 234 method: 'POST',235 headers: {'Content-Type': 'application/x-www-form-urlencoded'},236 transformRequest: function(obj) {237 var str = [];238 for(var p in obj)239 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));240 return str.join("&");241 },242 data : data243 }) 244 return promise;245 };246 247 factory.delete_news_feed_data = function(data){248 var promise = $http({249 url:'./FUNCTIONS/Newsfeed/delete_news_feed_data.php', 250 method: 'POST',251 headers: {'Content-Type': 'application/x-www-form-urlencoded'},252 transformRequest: function(obj) {253 var str = [];254 for(var p in obj)255 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));256 return str.join("&");257 },258 data : data259 }) 260 return promise;261 };262 factory.edit_news_feed_data = function(data){263 var promise = $http({264 url:'./FUNCTIONS/Newsfeed/edit_news_feed_data.php', 265 method: 'POST',266 headers: {'Content-Type': 'application/x-www-form-urlencoded'},267 transformRequest: function(obj) {268 var str = [];269 for(var p in obj)270 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));271 return str.join("&");272 },273 data : data274 }) 275 return promise;276 };277 factory.get_news_feed = function(data){278 var promise = $http({279 url:'./FUNCTIONS/Newsfeed/get_news_feed.php', 280 method: 'POST',281 headers: {'Content-Type': 'application/x-www-form-urlencoded'},282 transformRequest: function(obj) {283 var str = [];284 for(var p in obj)285 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));286 return str.join("&");287 },288 data : data289 }) 290 return promise;291 };292 factory.get_news_feed_ads = function(data){293 var promise = $http({294 url:'./FUNCTIONS/Newsfeed/get_news_feed_ads.php', 295 method: 'POST',296 headers: {'Content-Type': 'application/x-www-form-urlencoded'},297 transformRequest: function(obj) {298 var str = [];299 for(var p in obj)300 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));301 return str.join("&");302 },303 data : data304 }) 305 return promise;306 };307 factory.get_news_feed_gif = function(data){308 var promise = $http({309 url:'./FUNCTIONS/Newsfeed/get_news_feed_gif.php', 310 method: 'POST',311 headers: {'Content-Type': 'application/x-www-form-urlencoded'},312 transformRequest: function(obj) {313 var str = [];314 for(var p in obj)315 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));316 return str.join("&");317 },318 data : data319 }) 320 return promise;321 };322 323 factory.add_newsflash = function(data){324 var promise = $http({325 url:'./FUNCTIONS/Newsfeed/add_newsflash.php', 326 method: 'POST',327 headers: {'Content-Type': 'application/x-www-form-urlencoded'},328 transformRequest: function(obj) {329 var str = [];330 for(var p in obj)331 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));332 return str.join("&");333 },334 data : data335 }) 336 return promise;337 };338 factory.update_this = function(data){339 var promise = $http({340 url:'./FUNCTIONS/Admin/update_this.php', 341 method: 'POST',342 headers: {'Content-Type': 'application/x-www-form-urlencoded'},343 transformRequest: function(obj) {344 var str = [];345 for(var p in obj)346 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));347 return str.join("&");348 },349 data : data350 }) 351 return promise;352 };353 factory.edit_permission = function(data){354 var promise = $http({355 url:'./FUNCTIONS/Users/edit_permission.php', 356 method: 'POST',357 headers: {'Content-Type': 'application/x-www-form-urlencoded'},358 transformRequest: function(obj) {359 var str = [];360 for(var p in obj)361 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));362 return str.join("&");363 },364 data : data365 }) 366 return promise;367 };368 factory.get_storage = function(data){369 var promise = $http({370 url:'./FUNCTIONS/Product/get_storage.php', 371 method: 'POST',372 headers: {'Content-Type': 'application/x-www-form-urlencoded'},373 transformRequest: function(obj) {374 var str = [];375 for(var p in obj)376 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));377 return str.join("&");378 },379 data : data380 }) 381 return promise;382 };383 factory.get_aomos_discount_list = function(data){384 var promise = $http({385 url:'./FUNCTIONS/Discount/get_aomos_discount_list.php', 386 method: 'POST',387 headers: {'Content-Type': 'application/x-www-form-urlencoded'},388 transformRequest: function(obj) {389 var str = [];390 for(var p in obj)391 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));392 return str.join("&");393 },394 data : data395 }) 396 return promise;397 };398 factory.get_aomos_payment_filter = function(data){399 var promise = $http({400 url:'./FUNCTIONS/Discount/get_aomos_payment_filter.php', 401 method: 'POST',402 headers: {'Content-Type': 'application/x-www-form-urlencoded'},403 transformRequest: function(obj) {404 var str = [];405 for(var p in obj)406 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));407 return str.join("&");408 },409 data : data410 }) 411 return promise;412 };413 factory.edit_branch = function(data){414 var promise = $http({415 url:'./FUNCTIONS/Admin/edit_branch.php', 416 method: 'POST',417 headers: {'Content-Type': 'application/x-www-form-urlencoded'},418 transformRequest: function(obj) {419 var str = [];420 for(var p in obj)421 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));422 return str.join("&");423 },424 data : data425 }) 426 return promise;427 };428 factory.delete_branch = function(data){429 var promise = $http({430 url:'./FUNCTIONS/Admin/delete_branch.php', 431 method: 'POST',432 headers: {'Content-Type': 'application/x-www-form-urlencoded'},433 transformRequest: function(obj) {434 var str = [];435 for(var p in obj)436 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));437 return str.join("&");438 },439 data : data440 }) 441 return promise;442 };443 factory.add_customer = function(data){444 var promise = $http({445 url:'./FUNCTIONS/Admin/add_customer.php', 446 method: 'POST',447 headers: {'Content-Type': 'application/x-www-form-urlencoded'},448 transformRequest: function(obj) {449 var str = [];450 for(var p in obj)451 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));452 return str.join("&");453 },454 data : data455 }) 456 return promise;457 };458 factory.get_branch_data = function(data){459 var promise = $http({460 url:'./FUNCTIONS/Admin/get_branch_data.php', 461 method: 'POST',462 headers: {'Content-Type': 'application/x-www-form-urlencoded'},463 transformRequest: function(obj) {464 var str = [];465 for(var p in obj)466 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));467 return str.join("&");468 },469 data : data470 }) 471 return promise;472 };473 factory.edit_customer = function(data){474 var promise = $http({475 url:'./FUNCTIONS/Admin/edit_customer.php', 476 method: 'POST',477 headers: {'Content-Type': 'application/x-www-form-urlencoded'},478 transformRequest: function(obj) {479 var str = [];480 for(var p in obj)481 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));482 return str.join("&");483 },484 data : data485 }) 486 return promise;487 };488 factory.get_customer_data = function(data){489 var promise = $http({490 url:'./FUNCTIONS/Admin/get_customer_data.php', 491 method: 'POST',492 headers: {'Content-Type': 'application/x-www-form-urlencoded'},493 transformRequest: function(obj) {494 var str = [];495 for(var p in obj)496 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));497 return str.join("&");498 },499 data : data500 }) 501 return promise;502 };503 factory.delete_customer = function(data){504 var promise = $http({505 url:'./FUNCTIONS/Admin/delete_customer.php', 506 method: 'POST',507 headers: {'Content-Type': 'application/x-www-form-urlencoded'},508 transformRequest: function(obj) {509 var str = [];510 for(var p in obj)511 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));512 return str.join("&");513 },514 data : data515 }) 516 return promise;517 };518 factory.get_product_data_search = function(data){519 var promise = $http({520 url:'./FUNCTIONS/Users/get_product_data_search.php', 521 method: 'POST',522 headers: {'Content-Type': 'application/x-www-form-urlencoded'},523 transformRequest: function(obj) {524 var str = [];525 for(var p in obj)526 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));527 return str.join("&");528 },529 data : data530 }) 531 return promise;532 };533 factory.get_history_logs = function(data){534 var promise = $http({535 url:'./FUNCTIONS/Management/get_history_logs.php', 536 method: 'POST',537 headers: {'Content-Type': 'application/x-www-form-urlencoded'},538 transformRequest: function(obj) {539 var str = [];540 for(var p in obj)541 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));542 return str.join("&");543 },544 data : data545 }) 546 return promise;547 };548 factory.get_accounts_logs = function(data){549 var promise = $http({550 url:'./FUNCTIONS/Management/get_accounts_logs.php', 551 method: 'POST',552 headers: {'Content-Type': 'application/x-www-form-urlencoded'},553 transformRequest: function(obj) {554 var str = [];555 for(var p in obj)556 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));557 return str.join("&");558 },559 data : data560 }) 561 return promise;562 };563 factory.get_check_bar_code_item = function(data){564 var promise = $http({565 url:'./FUNCTIONS/Product/get_check_bar_code_item.php', 566 method: 'POST',567 headers: {'Content-Type': 'application/x-www-form-urlencoded'},568 transformRequest: function(obj) {569 var str = [];570 for(var p in obj)571 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));572 return str.join("&");573 },574 data : data575 }) 576 return promise;577 };578 factory.get_po_data_search = function(data){579 var promise = $http({580 url:'./FUNCTIONS/Users/get_po_data_search.php', 581 method: 'POST',582 headers: {'Content-Type': 'application/x-www-form-urlencoded'},583 transformRequest: function(obj) {584 var str = [];585 for(var p in obj)586 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));587 return str.join("&");588 },589 data : data590 }) 591 return promise;592 };593 factory.get_product_data_search_expire = function(data){594 var promise = $http({595 url:'./FUNCTIONS/Product/get_product_data_search_expire.php', 596 method: 'POST',597 headers: {'Content-Type': 'application/x-www-form-urlencoded'},598 transformRequest: function(obj) {599 var str = [];600 for(var p in obj)601 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));602 return str.join("&");603 },604 data : data605 }) 606 return promise;607 };608 factory.get_product_data_checker = function(data){609 var promise = $http({610 url:'./FUNCTIONS/Product/get_product_data_checker.php', 611 method: 'POST',612 headers: {'Content-Type': 'application/x-www-form-urlencoded'},613 transformRequest: function(obj) {614 var str = [];615 for(var p in obj)616 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));617 return str.join("&");618 },619 data : data620 }) 621 return promise;622 };623 factory.get_product_data_expire = function(data){624 var promise = $http({625 url:'./FUNCTIONS/Product/get_product_data_expire.php', 626 method: 'POST',627 headers: {'Content-Type': 'application/x-www-form-urlencoded'},628 transformRequest: function(obj) {629 var str = [];630 for(var p in obj)631 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));632 return str.join("&");633 },634 data : data635 }) 636 return promise;637 };638 factory.get_data_or = function(data){639 var promise = $http({640 url:'./FUNCTIONS/Product/get_data_or.php', 641 method: 'POST',642 headers: {'Content-Type': 'application/x-www-form-urlencoded'},643 transformRequest: function(obj) {644 var str = [];645 for(var p in obj)646 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));647 return str.join("&");648 },649 data : data650 }) 651 return promise;652 };653 factory.get_product_data_or = function(data){654 var promise = $http({655 url:'./FUNCTIONS/Product/get_product_data_or.php', 656 method: 'POST',657 headers: {'Content-Type': 'application/x-www-form-urlencoded'},658 transformRequest: function(obj) {659 var str = [];660 for(var p in obj)661 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));662 return str.join("&");663 },664 data : data665 }) 666 return promise;667 };668 factory.get_check_item = function(data){669 var promise = $http({670 url:'./FUNCTIONS/Product/get_check_item.php', 671 method: 'POST',672 headers: {'Content-Type': 'application/x-www-form-urlencoded'},673 transformRequest: function(obj) {674 var str = [];675 for(var p in obj)676 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));677 return str.join("&");678 },679 data : data680 }) 681 return promise;682 };683 factory.get_supplier_data_search = function(data){684 var promise = $http({685 url:'./FUNCTIONS/Users/get_supplier_data_search.php', 686 method: 'POST',687 headers: {'Content-Type': 'application/x-www-form-urlencoded'},688 transformRequest: function(obj) {689 var str = [];690 for(var p in obj)691 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));692 return str.join("&");693 },694 data : data695 }) 696 return promise;697 };698 factory.get_rule_data = function(data){699 var promise = $http({700 url:'./FUNCTIONS/Users/get_rule_data.php', 701 method: 'POST',702 headers: {'Content-Type': 'application/x-www-form-urlencoded'},703 transformRequest: function(obj) {704 var str = [];705 for(var p in obj)706 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));707 return str.join("&");708 },709 data : data710 }) 711 return promise;712 };713 factory.upload_picture = function(data){714 var promise = $http({715 url:'./FUNCTIONS/Users/upload_picture.php', 716 method: 'POST',717 headers: {'Content-Type': 'application/x-www-form-urlencoded'},718 transformRequest: function(obj) {719 var str = [];720 for(var p in obj)721 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));722 return str.join("&");723 },724 data : data725 }) 726 727 return promise;728 };729 factory.add_rule = function(data){730 var promise = $http({731 url:'./FUNCTIONS/Users/add_rule.php', 732 method: 'POST',733 headers: {'Content-Type': 'application/x-www-form-urlencoded'},734 transformRequest: function(obj) {735 var str = [];736 for(var p in obj)737 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));738 return str.join("&");739 },740 data : data741 }) 742 return promise;743 };744 factory.delete_rule = function(data){745 var promise = $http({746 url:'./FUNCTIONS/Users/delete_rule.php', 747 method: 'POST',748 headers: {'Content-Type': 'application/x-www-form-urlencoded'},749 transformRequest: function(obj) {750 var str = [];751 for(var p in obj)752 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));753 return str.join("&");754 },755 data : data756 }) 757 return promise;758 };759 factory.edit_rule_data = function(data){760 var promise = $http({761 url:'./FUNCTIONS/Users/edit_rule_data.php', 762 method: 'POST',763 headers: {'Content-Type': 'application/x-www-form-urlencoded'},764 transformRequest: function(obj) {765 var str = [];766 for(var p in obj)767 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));768 return str.join("&");769 },770 data : data771 }) 772 return promise;773 };774 factory.add_product = function(data){775 var promise = $http({776 url:'./FUNCTIONS/Product/add_product.php', 777 method: 'POST',778 headers: {'Content-Type': 'application/x-www-form-urlencoded'},779 transformRequest: function(obj) {780 var str = [];781 for(var p in obj)782 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));783 return str.join("&");784 },785 data : data786 }) 787 return promise;788 };789 factory.send_remarks = function(data){790 var promise = $http({791 url:'./FUNCTIONS/Product/send_remarks.php', 792 method: 'POST',793 headers: {'Content-Type': 'application/x-www-form-urlencoded'},794 transformRequest: function(obj) {795 var str = [];796 for(var p in obj)797 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));798 return str.join("&");799 },800 data : data801 }) 802 return promise;803 };804 factory.add_user = function(data){805 var promise = $http({806 url:'./FUNCTIONS/Users/add_user.php', 807 method: 'POST',808 headers: {'Content-Type': 'application/x-www-form-urlencoded'},809 transformRequest: function(obj) {810 var str = [];811 for(var p in obj)812 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));813 return str.join("&");814 },815 data : data816 }) 817 return promise;818 };819 factory.edit_user = function(data){820 var promise = $http({821 url:'./FUNCTIONS/Users/edit_user.php', 822 method: 'POST',823 headers: {'Content-Type': 'application/x-www-form-urlencoded'},824 transformRequest: function(obj) {825 var str = [];826 for(var p in obj)827 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));828 return str.join("&");829 },830 data : data831 }) 832 return promise;833 };834 factory.delete_user = function(data){835 var promise = $http({836 url:'./FUNCTIONS/Users/delete_user.php', 837 method: 'POST',838 headers: {'Content-Type': 'application/x-www-form-urlencoded'},839 transformRequest: function(obj) {840 var str = [];841 for(var p in obj)842 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));843 return str.join("&");844 },845 data : data846 }) 847 return promise;848 };849 factory.get_added_user_data = function(data){850 var promise = $http({851 url:'./FUNCTIONS/Users/get_added_user_data.php', 852 method: 'POST',853 headers: {'Content-Type': 'application/x-www-form-urlencoded'},854 transformRequest: function(obj) {855 var str = [];856 for(var p in obj)857 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));858 return str.join("&");859 },860 data : data861 }) 862 return promise;863 };864 factory.submit_toemail = function(data){865 var promise = $http({866 url:'./FUNCTIONS/Product/submit_toemail.php', 867 method: 'POST',868 headers: {'Content-Type': 'application/x-www-form-urlencoded'},869 transformRequest: function(obj) {870 var str = [];871 for(var p in obj)872 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));873 return str.join("&");874 },875 data : data876 }) 877 return promise;878 };879 factory.update_stocks = function(data){880 var promise = $http({881 url:'./FUNCTIONS/Product/update_stocks.php', 882 method: 'POST',883 headers: {'Content-Type': 'application/x-www-form-urlencoded'},884 transformRequest: function(obj) {885 var str = [];886 for(var p in obj)887 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));888 return str.join("&");889 },890 data : data891 }) 892 return promise;893 };894 factory.gift_certificate_data = function(data){895 var promise = $http({896 url:'./FUNCTIONS/Product/gift_certificate_data.php', 897 method: 'POST',898 headers: {'Content-Type': 'application/x-www-form-urlencoded'},899 transformRequest: function(obj) {900 var str = [];901 for(var p in obj)902 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));903 return str.join("&");904 },905 data : data906 }) 907 return promise;908 };909 factory.add_supplier = function(data){910 var promise = $http({911 url:'./FUNCTIONS/Product/add_supplier.php', 912 method: 'POST',913 headers: {'Content-Type': 'application/x-www-form-urlencoded'},914 transformRequest: function(obj) {915 var str = [];916 for(var p in obj)917 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));918 return str.join("&");919 },920 data : data921 }) 922 return promise;923 };924 factory.edit_product_data = function(data){925 var promise = $http({926 url:'./FUNCTIONS/Product/edit_product_data.php', 927 method: 'POST',928 headers: {'Content-Type': 'application/x-www-form-urlencoded'},929 transformRequest: function(obj) {930 var str = [];931 for(var p in obj)932 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));933 return str.join("&");934 },935 data : data936 }) 937 return promise;938 };939 factory.edit_product_data_bc = function(data){940 var promise = $http({941 url:'./FUNCTIONS/Product/edit_product_data_bc.php', 942 method: 'POST',943 headers: {'Content-Type': 'application/x-www-form-urlencoded'},944 transformRequest: function(obj) {945 var str = [];946 for(var p in obj)947 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));948 return str.join("&");949 },950 data : data951 }) 952 return promise;953 };954 factory.edit_supplier_data = function(data){955 var promise = $http({956 url:'./FUNCTIONS/Product/edit_supplier_data.php', 957 method: 'POST',958 headers: {'Content-Type': 'application/x-www-form-urlencoded'},959 transformRequest: function(obj) {960 var str = [];961 for(var p in obj)962 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));963 return str.join("&");964 },965 data : data966 }) 967 return promise;968 };969 factory.delete_product_data = function(data){970 var promise = $http({971 url:'./FUNCTIONS/Product/delete_product_data.php', 972 method: 'POST',973 headers: {'Content-Type': 'application/x-www-form-urlencoded'},974 transformRequest: function(obj) {975 var str = [];976 for(var p in obj)977 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));978 return str.join("&");979 },980 data : data981 }) 982 return promise;983 };984 factory.delete_supplier_data = function(data){985 var promise = $http({986 url:'./FUNCTIONS/Product/delete_supplier_data.php', 987 method: 'POST',988 headers: {'Content-Type': 'application/x-www-form-urlencoded'},989 transformRequest: function(obj) {990 var str = [];991 for(var p in obj)992 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));993 return str.join("&");994 },995 data : data996 }) 997 return promise;998 };999 factory.request_product_order = function(data){1000 var promise = $http({1001 url:'./FUNCTIONS/Product/request_product_order.php', 1002 method: 'POST',1003 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1004 transformRequest: function(obj) {1005 var str = [];1006 for(var p in obj)1007 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1008 return str.join("&");1009 },1010 data : data1011 }) 1012 return promise;1013 };1014 factory.complete_request = function(data){1015 var promise = $http({1016 url:'./FUNCTIONS/Product/complete_request.php', 1017 method: 'POST',1018 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1019 transformRequest: function(obj) {1020 var str = [];1021 for(var p in obj)1022 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1023 return str.join("&");1024 },1025 data : data1026 }) 1027 return promise; 1028 }1029 factory.approve_order_request = function(data){1030 var promise = $http({1031 url:'./FUNCTIONS/Product/approve_order_request.php', 1032 method: 'POST',1033 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1034 transformRequest: function(obj) {1035 var str = [];1036 for(var p in obj)1037 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1038 return str.join("&");1039 },1040 data : data1041 }) 1042 return promise;1043 };1044 factory.disapprove_order_request = function(data){1045 var promise = $http({1046 url:'./FUNCTIONS/Product/disapprove_order_request.php', 1047 method: 'POST',1048 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1049 transformRequest: function(obj) {1050 var str = [];1051 for(var p in obj)1052 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1053 return str.join("&");1054 },1055 data : data1056 }) 1057 return promise;1058 };1059 factory.tender_product = function(data){1060 var promise = $http({1061 url:'./FUNCTIONS/Product/tender_product.php', 1062 method: 'POST',1063 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1064 transformRequest: function(obj) {1065 var str = [];1066 for(var p in obj)1067 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1068 return str.join("&");1069 },1070 data : data1071 }) 1072 return promise;1073 };1074 factory.submit_toemailreceipt = function(data){1075 var promise = $http({1076 url:'./FUNCTIONS/Product/submit_toemailreceipt.php', 1077 method: 'POST',1078 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1079 transformRequest: function(obj) {1080 var str = [];1081 for(var p in obj)1082 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1083 return str.join("&");1084 },1085 data : data1086 }) 1087 return promise;1088 };1089 factory.get_product_data = function(data){1090 var promise = $http({1091 url:'./FUNCTIONS/Product/get_product_data.php', 1092 method: 'POST',1093 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1094 transformRequest: function(obj) {1095 var str = [];1096 for(var p in obj)1097 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1098 return str.join("&");1099 },1100 data : data1101 }) 1102 return promise;1103 };1104 factory.get_receiptsback = function(data){1105 var promise = $http({1106 url:'./FUNCTIONS/Product/get_receiptsback.php', 1107 method: 'POST',1108 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1109 transformRequest: function(obj) {1110 var str = [];1111 for(var p in obj)1112 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1113 return str.join("&");1114 },1115 data : data1116 }) 1117 return promise;1118 };1119 factory.get_best_selling = function(data){1120 var promise = $http({1121 url:'./FUNCTIONS/Product/get_best_selling.php', 1122 method: 'POST',1123 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1124 transformRequest: function(obj) {1125 var str = [];1126 for(var p in obj)1127 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1128 return str.join("&");1129 },1130 data : data1131 }) 1132 return promise;1133 };1134 factory.get_receipts = function(data){1135 var promise = $http({1136 url:'./FUNCTIONS/Product/get_receipts.php', 1137 method: 'POST',1138 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1139 transformRequest: function(obj) {1140 var str = [];1141 for(var p in obj)1142 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1143 return str.join("&");1144 },1145 data : data1146 }) 1147 return promise;1148 };1149 factory.get_reports = function(data){1150 console.log(data);1151 var promise = $http({1152 url:'./FUNCTIONS/Product/get_reports.php', 1153 method: 'POST',1154 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1155 transformRequest: function(obj) {1156 var str = [];1157 for(var p in obj)1158 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1159 return str.join("&");1160 },1161 data : data1162 }) 1163 return promise;1164 };1165 factory.get_customers = function(data){1166 var promise = $http({1167 url:'./FUNCTIONS/Customer/get_customers.php', 1168 method: 'POST',1169 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1170 transformRequest: function(obj) {1171 var str = [];1172 for(var p in obj)1173 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1174 return str.join("&");1175 },1176 data : data1177 }) 1178 return promise;1179 };1180 factory.get_request_order_data = function(data){1181 var promise = $http({1182 url:'./FUNCTIONS/Product/get_request_order_data.php', 1183 method: 'POST',1184 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1185 transformRequest: function(obj) {1186 var str = [];1187 for(var p in obj)1188 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1189 return str.join("&");1190 },1191 data : data1192 }) 1193 return promise;1194 };1195 factory.get_all_products = function(data){1196 var promise = $http({1197 url:'./FUNCTIONS/Product/get_all_products.php', 1198 method: 'POST',1199 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1200 transformRequest: function(obj) {1201 var str = [];1202 for(var p in obj)1203 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1204 return str.join("&");1205 },1206 data : data1207 }) 1208 return promise;1209 };1210 factory.get_supplier_data = function(data){1211 var promise = $http({1212 url:'./FUNCTIONS/Product/get_supplier_data.php', 1213 method: 'POST',1214 headers: {'Content-Type': 'application/x-www-form-urlencoded'},1215 transformRequest: function(obj) {1216 var str = [];1217 for(var p in obj)1218 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));1219 return str.join("&");1220 },1221 data : data1222 }) 1223 return promise;1224 };1225 return factory;...

Full Screen

Full Screen

encoder.js

Source:encoder.js Github

copy

Full Screen

1const impl = require("./encoder_impl.js");2const protocol = require("satel-integra-integration-protocol");3module.exports = function (RED) {4 function Encoder(config) {5 RED.nodes.createNode(this, config);6 const node = this;7 node.userNode = RED.nodes.getNode(config.user);8 node.prefixNode = RED.nodes.getNode(config.prefix);9 node.on("input", function (msg, send, done) {10 try {11 if (!msg.topic) {12 throw new Error("message without topic");13 }14 if (msg.topic == "new_data") {15 msg.payload = protocol.encodeNewDataCommand();16 } else if (msg.topic == "outputs_state") {17 msg.payload = protocol.encodeOutputsStateCommand();18 } else if (msg.topic == "outputs_state_256") {19 msg.payload = protocol.encodeOutputsState256Command();20 } else if (msg.topic == "zones_tamper") {21 msg.payload = protocol.encodeZonesTamperCommand();22 } else if (msg.topic == "zones_tamper_256") {23 msg.payload = protocol.encodeZonesTamper256Command();24 } else if (msg.topic == "zones_violation") {25 msg.payload = protocol.encodeZonesViolationCommand();26 } else if (msg.topic == "zones_violation_256") {27 msg.payload = protocol.encodeZonesViolation256Command();28 } else if (msg.topic == "zones_alarm") {29 msg.payload = protocol.encodeZonesAlarmCommand();30 } else if (msg.topic == "zones_alarm_256") {31 msg.payload = protocol.encodeZonesAlarm256Command();32 } else if (msg.topic == "zones_tamper_alarm") {33 msg.payload = protocol.encodeZonesTamperAlarmCommand();34 } else if (msg.topic == "zones_tamper_alarm_256") {35 msg.payload = protocol.encodeZonesTamperAlarm256Command();36 } else if (msg.topic == "zones_alarm_memory") {37 msg.payload = protocol.encodeZonesAlarmMemoryCommand();38 } else if (msg.topic == "zones_alarm_memory_256") {39 msg.payload = protocol.encodeZonesAlarmMemory256Command();40 } else if (msg.topic == "zones_tamper_alarm_memory") {41 msg.payload = protocol.encodeZonesTamperAlarmMemoryCommand();42 } else if (msg.topic == "zones_tamper_alarm_memory_256") {43 msg.payload = protocol.encodeZonesTamperAlarmMemory256Command();44 } else if (msg.topic == "zones_bypass_status") {45 msg.payload = protocol.encodeZonesBypassStatusCommand();46 } else if (msg.topic == "zones_bypass_status_256") {47 msg.payload = protocol.encodeZonesBypassStatus256Command();48 } else if (msg.topic == "zones_no_violation_trouble") {49 msg.payload = protocol.encodeZonesNoViolationTroubleCommand();50 } else if (msg.topic == "zones_no_violation_trouble_256") {51 msg.payload = protocol.encodeZonesNoViolationTrouble256Command();52 } else if (msg.topic == "zones_long_violation_trouble") {53 msg.payload = protocol.encodeZonesLongViolationTroubleCommand();54 } else if (msg.topic == "zones_long_violation_trouble_256") {55 msg.payload = protocol.encodeZonesLongViolationTrouble256Command();56 } else if (msg.topic == "armed_partitions_suppressed") {57 msg.payload = protocol.encodeArmedPartitionsSuppressedCommand();58 } else if (msg.topic == "armed_partitions_really") {59 msg.payload = protocol.encodeArmedPartitionsReallyCommand();60 } else if (msg.topic == "partitions_armed_in_mode_2") {61 msg.payload = protocol.encodePartitionsArmedInMode2Command();62 } else if (msg.topic == "partitions_armed_in_mode_3") {63 msg.payload = protocol.encodePartitionsArmedInMode3Command();64 } else if (msg.topic == "partitions_with_1st_code_entered") {65 msg.payload = protocol.encodePartitionsWith1stCodeEnteredCommand();66 } else if (msg.topic == "partitions_entry_time") {67 msg.payload = protocol.encodePartitionsEntryTimeCommand();68 } else if (msg.topic == "partitions_exit_time_more_then_10s") {69 msg.payload = protocol.encodePartitionsExitTimeMoreThen10sCommand();70 } else if (msg.topic == "partitions_exit_time_less_then_10s") {71 msg.payload = protocol.encodePartitionsExitTimeLessThen10sCommand();72 } else if (msg.topic == "partitions_temporary_blocked") {73 msg.payload = protocol.encodePartitionsTemporaryBlockedCommand();74 } else if (msg.topic == "partitions_blocked_for_guard_round") {75 msg.payload = protocol.encodePartitionsBlockedForGuardRoundCommand();76 } else if (msg.topic == "partitions_alarm") {77 msg.payload = protocol.encodePartitionsAlarmCommand();78 } else if (msg.topic == "partitions_fire_alarm") {79 msg.payload = protocol.encodePartitionsFireAlarmCommand();80 } else if (msg.topic == "partitions_alarm_memory") {81 msg.payload = protocol.encodePartitionsAlarmMemoryCommand();82 } else if (msg.topic == "partitions_fire_alarm_memory") {83 msg.payload = protocol.encodePartitionsFireAlarmMemoryCommand();84 } else if (msg.topic == "zones_isolate_state") {85 msg.payload = protocol.encodeZonesIsolateStateCommand();86 } else if (msg.topic == "zones_isolate_state_256") {87 msg.payload = protocol.encodeZonesIsolateState256Command();88 } else if (msg.topic == "zones_masked") {89 msg.payload = protocol.encodeZonesMaskedCommand();90 } else if (msg.topic == "zones_masked_256") {91 msg.payload = protocol.encodeZonesMasked256Command();92 } else if (msg.topic == "zones_masked_memory") {93 msg.payload = protocol.encodeZonesMaskedMemoryCommand();94 } else if (msg.topic == "zones_masked_memory_256") {95 msg.payload = protocol.encodeZonesMaskedMemory256Command();96 } else if (msg.topic == "outputs_off") {97 impl.encodeOutputsChangeCommand(98 msg,99 protocol.encodeOutputsOffCommand,100 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)101 );102 } else if (msg.topic == "outputs_on") {103 impl.encodeOutputsChangeCommand(104 msg,105 protocol.encodeOutputsOnCommand,106 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)107 );108 } else if (msg.topic == "outputs_switch") {109 impl.encodeOutputsChangeCommand(110 msg,111 protocol.encodeOutputsSwitchCommand,112 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)113 );114 } else if (msg.topic == "zones_bypass") {115 impl.encodeZonesChangeCommand(116 msg,117 protocol.encodeZonesBypassCommand,118 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)119 );120 } else if (msg.topic == "zones_unbypass") {121 impl.encodeZonesChangeCommand(122 msg,123 protocol.encodeZonesUnbypassCommand,124 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)125 );126 } else if (msg.topic == "zones_isolate") {127 impl.encodeZonesChangeCommand(128 msg,129 protocol.encodeZonesIsolateCommand,130 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)131 );132 } else if (msg.topic == "arm_in_mode_0") {133 impl.encodePartitionsChangeCommand(134 msg,135 protocol.encodeArmInMode0Command,136 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)137 );138 } else if (msg.topic == "arm_in_mode_1") {139 impl.encodePartitionsChangeCommand(140 msg,141 protocol.encodeArmInMode1Command,142 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)143 );144 } else if (msg.topic == "arm_in_mode_2") {145 impl.encodePartitionsChangeCommand(146 msg,147 protocol.encodeArmInMode2Command,148 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)149 );150 } else if (msg.topic == "arm_in_mode_3") {151 impl.encodePartitionsChangeCommand(152 msg,153 protocol.encodeArmInMode3Command,154 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)155 );156 } else if (msg.topic == "disarm") {157 impl.encodePartitionsChangeCommand(158 msg,159 protocol.encodeDisarmCommand,160 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)161 );162 } else if (msg.topic == "clear_alarm") {163 impl.encodePartitionsChangeCommand(164 msg,165 protocol.encodeClearAlarmCommand,166 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)167 );168 } else if (msg.topic == "force_arm_in_mode_0") {169 impl.encodePartitionsChangeCommand(170 msg,171 protocol.encodeForceArmInMode0Command,172 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)173 );174 } else if (msg.topic == "force_arm_in_mode_1") {175 impl.encodePartitionsChangeCommand(176 msg,177 protocol.encodeForceArmInMode1Command,178 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)179 );180 } else if (msg.topic == "force_arm_in_mode_2") {181 impl.encodePartitionsChangeCommand(182 msg,183 protocol.encodeForceArmInMode2Command,184 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)185 );186 } else if (msg.topic == "force_arm_in_mode_3") {187 impl.encodePartitionsChangeCommand(188 msg,189 protocol.encodeForceArmInMode3Command,190 impl.getPrefixAndUserCode(node.userNode, node.prefixNode)191 );192 } else {193 throw new Error("unsupported message topic: '" + msg.topic + "'");194 }195 /* istanbul ignore else: the else path can be reached with old node-red versions only */196 if (send) {197 send(msg);198 } else {199 node.send(msg);200 }201 /* istanbul ignore else: the else path can be reached with old node-red versions only */202 if (done) {203 done();204 }205 } catch (error) {206 /* istanbul ignore else: the else path can be reached with old node-red versions only */207 if (done) {208 done(error);209 } else {210 node.error(error, msg);211 }212 }213 });214 }215 RED.nodes.registerType("satel-integra-encoder", Encoder);...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...78 }79 return parseInt(byte, 10);80}81function encodeUTF8Vec(str) {82 return encodeVec(utf8.encode(str));83}84function encodeLimits(n) {85 var out = [];86 if (typeof n.max === "number") {87 out.push(0x01);88 out.push.apply(out, _toConsumableArray(encodeU32(n.min))); // $FlowIgnore: ensured by the typeof89 out.push.apply(out, _toConsumableArray(encodeU32(n.max)));90 } else {91 out.push(0x00);92 out.push.apply(out, _toConsumableArray(encodeU32(n.min)));93 }94 return out;95}96function encodeModuleImport(n) {...

Full Screen

Full Screen

JSON.js

Source:JSON.js Github

copy

Full Screen

...10 describe("encode", function() {11 var encode = Ext.JSON.encode;12 describe("numbers encoding", function() {13 it("should convert integer to string", function() {14 expect(encode(15)).toEqual("15");15 });16 it("should convert float to string", function() {17 expect(encode(14.7)).toEqual("14.7");18 });19 it("should convert Infinity to null string", function() {20 expect(encode(Infinity)).toEqual("null");21 });22 it("should convert NaN to null string", function() {23 expect(encode(NaN)).toEqual("null");24 });25 });26 describe("encoding of not defined values", function() {27 it("should convert undefined to null string", function() {28 expect(encode(undefined)).toEqual("null");29 });30 it("should convert null to null string", function() {31 expect(encode(null)).toEqual("null");32 });33 });34 describe("encoding function", function() {35 it("should convert function to null string", function() {36 expect(encode(Ext.emptyFn)).toEqual("null");37 });38 });39 describe("boolean encoding", function() {40 it("should convert true to 'true'' string", function() {41 expect(encode(true)).toEqual("true");42 });43 it("should convert null to 'false' string", function() {44 expect(encode(false)).toEqual("false");45 });46 });47 describe("array encoding", function() {48 it("should convert empty array", function() {49 expect(encode([])).toEqual("[]");50 });51 it("should convert array of numbers to string", function() {52 expect(encode([1, 2, 3])).toEqual("[1,2,3]");53 });54 it("should convert array of strings to string", function() {55 expect(encode(["a", "b", "c"])).toEqual("[\"a\",\"b\",\"c\"]");56 });57 it("should encode array including function member to string", function() {58 expect(encode([1, Ext.emptyFn, 3])).toEqual("[1,null,3]");59 });60 it("should convert array including undefined member to string", function() {61 expect(encode([1, undefined, 3])).toEqual("[1,null,3]");62 });63 it("should convert array including null member to string", function() {64 expect(encode([1, null, 3])).toEqual("[1,null,3]");65 });66 });67 describe("string encoding", function() {68 it("should convert string", function() {69 expect(encode("You're fired!")).toEqual("\"You're fired!\"");70 });71 it("should convert string with international character", function() {72 expect(encode("You're fired!")).toEqual("\"You're fired!\"");73 });74 it("should convert string with tab character", function() {75 expect(encode("a\tb")).toEqual("\"a\\tb\"");76 });77 it("should convert string with carriage return character", function() {78 expect(encode("a\rb")).toEqual("\"a\\rb\"");79 });80 it("should convert string with form feed character", function() {81 expect(encode("a\fb")).toEqual("\"a\\fb\"");82 });83 it("should convert string with new line character", function() {84 expect(encode("a\nb")).toEqual("\"a\\nb\"");85 });86 it("should convert string with vertical tab character", function() {87 expect(encode("a\x0bb")).toEqual("\"a\\u000bb\"");88 });89 it("should convert string with backslash character", function() {90 expect(encode("a\\b")).toEqual("\"a\\\\b\"");91 });92 });93 describe("object encoding", function() {94 it("should convert empty object", function() {95 expect(encode({})).toEqual("{}");96 });97 it("should ignore undefined properties", function() {98 expect(encode({99 foo: "bar",100 bar: undefined101 })).toEqual("{\"foo\":\"bar\"}");102 });103 it("should convert empty object with null property", function() {104 expect(encode({105 foo: "bar",106 bar: null107 })).toEqual("{\"foo\":\"bar\",\"bar\":null}");108 });109 it("should ignore function properties", function() {110 expect(encode({111 foo: "bar",112 bar: Ext.emptyFn113 })).toEqual("{\"foo\":\"bar\"}");114 });115 it("should not encode dom object", function() {116 expect(encode(document.body)).toBe('undefined');117 });118 it("should handle encoding unknown child objects", function() {119 expect(encode({120 prop: document.body121 })).toBe('{"prop":undefined}');122 });123 });124 describe("toJSON", function() {125 it("should not call toJSON property if it is not a function", function() {126 expect(function() {127 encode({128 toJSON: 'foo'129 });130 }).not.toThrow();131 });132 it("should call toJSON property if it is a function", function() {133 expect(encode({134 toJSON: function() {135 return '{blerg:"throbbe"}';136 }137 })).toBe('"{blerg:\\"throbbe\\"}"');138 });139 it("should encode values returned by toJSON property", function() {140 expect(encode({141 toJSON: function() {142 return {143 foo: {144 bar: 'qux'145 }146 };147 }148 })).toBe('{"foo":{"bar":"qux"}}');149 });150 });151 describe('encodeDate', function() {152 var date;153 it("should encode a date object", function() {154 date = new Date("October 13, 1983 04:04:00");155 expect(encode(date)).toEqual("\"1983-10-13T04:04:00\"");156 });157 it("should format integers to have at least two digits", function() {158 date = new Date("August 9, 1983 06:03:02");159 expect(encode(date)).toEqual("\"1983-08-09T06:03:02\"");160 });161 });162 describe("mix all possibilities", function() {163 it("should encode data", function() {164 expect(encode({165 arr: [1, Ext.emptyFn, undefined, 2, [1, 2, 3], { a: 1, b: null }],166 foo: "bar",167 woo: {168 chu: "a\tb"169 }170 })).toEqual("{\"arr\":[1,null,null,2,[1,2,3],{\"a\":1,\"b\":null}],\"foo\":\"bar\",\"woo\":{\"chu\":\"a\\tb\"}}");171 });172 });173 });174 describe("decode", function() {175 it("should decode data", function() {176 expect(Ext.decode("{\"arr\":[1,null,null,2,[1,2,3],{\"a\":1,\"b\":null}],\"foo\":\"bar\",\"woo\":{\"chu\":\"a\\tb\"}}")).toEqual({177 arr: [1, null, null, 2, [1, 2, 3], { a: 1, b: null }],178 foo: "bar",179 woo: {180 chu: "a\tb"181 }182 });183 });184 it("should raise an Ext.Error with invalid data", function() {185 expect(function() {186 Ext.decode('{foo:"bar", x}');187 }).toThrow();188 });189 describe("with safe param", function() {190 it("should decode valid data", function() {191 expect(Ext.decode("{\"foo\":\"bar\"}", true)).toEqual({192 foo: "bar"193 });194 });195 it("should return null with invalid data", function() {196 expect(Ext.decode('{foo+"bar"}', true)).toBeNull();197 });198 });199 });200 it('should encode and decode an object', function() {201 var object = {202 a: [0, 1, 2],203 s: "It's-me-Jacky!!",204 ss: "!@#$%^&*()~=_-+][{};:?/.,<>'\"",205 u: '\x01',206 i: 1,207 f: 3.14,208 b: false,209 n: null,210 tree: {211 sub: {212 subMore: {213 subEvenMore: {214 arr: [5, 6, 7, {215 complex: true216 }]217 }218 }219 }220 }221 };222 expect(Ext.JSON.decode(Ext.JSON.encode(object))).toEqual(object);223 });224 describe("aliases", function() {225 it("should alias Ext.JSON.decode with Ext.decode", function() {226 expect(Ext.decode).toBe(Ext.JSON.decode);227 });228 it("should alias Ext.JSON.encode with Ext.encode", function() {229 expect(Ext.encode).toBe(Ext.JSON.encode);230 });231 });...

Full Screen

Full Screen

percent-encoding.js

Source:percent-encoding.js Github

copy

Full Screen

1"use strict";2const { isASCIIHex } = require("./infra");3const { utf8Encode } = require("./encoding");4function p(char) {5 return char.codePointAt(0);6}7// https://url.spec.whatwg.org/#percent-encode8function percentEncode(c) {9 let hex = c.toString(16).toUpperCase();10 if (hex.length === 1) {11 hex = `0${hex}`;12 }13 return `%${hex}`;14}15// https://url.spec.whatwg.org/#percent-decode16function percentDecodeBytes(input) {17 const output = new Uint8Array(input.byteLength);18 let outputIndex = 0;19 for (let i = 0; i < input.byteLength; ++i) {20 const byte = input[i];21 if (byte !== 0x25) {22 output[outputIndex++] = byte;23 } else if (byte === 0x25 && (!isASCIIHex(input[i + 1]) || !isASCIIHex(input[i + 2]))) {24 output[outputIndex++] = byte;25 } else {26 const bytePoint = parseInt(String.fromCodePoint(input[i + 1], input[i + 2]), 16);27 output[outputIndex++] = bytePoint;28 i += 2;29 }30 }31 return output.slice(0, outputIndex);32}33// https://url.spec.whatwg.org/#string-percent-decode34function percentDecodeString(input) {35 const bytes = utf8Encode(input);36 return percentDecodeBytes(bytes);37}38// https://url.spec.whatwg.org/#c0-control-percent-encode-set39function isC0ControlPercentEncode(c) {40 return c <= 0x1F || c > 0x7E;41}42// https://url.spec.whatwg.org/#fragment-percent-encode-set43const extraFragmentPercentEncodeSet = new Set([p(" "), p("\""), p("<"), p(">"), p("`")]);44function isFragmentPercentEncode(c) {45 return isC0ControlPercentEncode(c) || extraFragmentPercentEncodeSet.has(c);46}47// https://url.spec.whatwg.org/#query-percent-encode-set48const extraQueryPercentEncodeSet = new Set([p(" "), p("\""), p("#"), p("<"), p(">")]);49function isQueryPercentEncode(c) {50 return isC0ControlPercentEncode(c) || extraQueryPercentEncodeSet.has(c);51}52// https://url.spec.whatwg.org/#special-query-percent-encode-set53function isSpecialQueryPercentEncode(c) {54 return isQueryPercentEncode(c) || c === p("'");55}56// https://url.spec.whatwg.org/#path-percent-encode-set57const extraPathPercentEncodeSet = new Set([p("?"), p("`"), p("{"), p("}")]);58function isPathPercentEncode(c) {59 return isQueryPercentEncode(c) || extraPathPercentEncodeSet.has(c);60}61// https://url.spec.whatwg.org/#userinfo-percent-encode-set62const extraUserinfoPercentEncodeSet =63 new Set([p("/"), p(":"), p(";"), p("="), p("@"), p("["), p("\\"), p("]"), p("^"), p("|")]);64function isUserinfoPercentEncode(c) {65 return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);66}67// https://url.spec.whatwg.org/#component-percent-encode-set68const extraComponentPercentEncodeSet = new Set([p("$"), p("%"), p("&"), p("+"), p(",")]);69function isComponentPercentEncode(c) {70 return isUserinfoPercentEncode(c) || extraComponentPercentEncodeSet.has(c);71}72// https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set73const extraURLEncodedPercentEncodeSet = new Set([p("!"), p("'"), p("("), p(")"), p("~")]);74function isURLEncodedPercentEncode(c) {75 return isComponentPercentEncode(c) || extraURLEncodedPercentEncodeSet.has(c);76}77// https://url.spec.whatwg.org/#code-point-percent-encode-after-encoding78// https://url.spec.whatwg.org/#utf-8-percent-encode79// Assuming encoding is always utf-8 allows us to trim one of the logic branches. TODO: support encoding.80// The "-Internal" variant here has code points as JS strings. The external version used by other files has code points81// as JS numbers, like the rest of the codebase.82function utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate) {83 const bytes = utf8Encode(codePoint);84 let output = "";85 for (const byte of bytes) {86 // Our percentEncodePredicate operates on bytes, not code points, so this is slightly different from the spec.87 if (!percentEncodePredicate(byte)) {88 output += String.fromCharCode(byte);89 } else {90 output += percentEncode(byte);91 }92 }93 return output;94}95function utf8PercentEncodeCodePoint(codePoint, percentEncodePredicate) {96 return utf8PercentEncodeCodePointInternal(String.fromCodePoint(codePoint), percentEncodePredicate);97}98// https://url.spec.whatwg.org/#string-percent-encode-after-encoding99// https://url.spec.whatwg.org/#string-utf-8-percent-encode100function utf8PercentEncodeString(input, percentEncodePredicate, spaceAsPlus = false) {101 let output = "";102 for (const codePoint of input) {103 if (spaceAsPlus && codePoint === " ") {104 output += "+";105 } else {106 output += utf8PercentEncodeCodePointInternal(codePoint, percentEncodePredicate);107 }108 }109 return output;110}111module.exports = {112 isC0ControlPercentEncode,113 isFragmentPercentEncode,114 isQueryPercentEncode,115 isSpecialQueryPercentEncode,116 isPathPercentEncode,117 isUserinfoPercentEncode,118 isURLEncodedPercentEncode,119 percentDecodeString,120 percentDecodeBytes,121 utf8PercentEncodeString,122 utf8PercentEncodeCodePoint...

Full Screen

Full Screen

encoder-test.js

Source:encoder-test.js Github

copy

Full Screen

1var assert = require('assert');2var hpack = require('../');3describe('hpack/encoder', function() {4 var encoder;5 beforeEach(function() {6 encoder = hpack.encoder.create();7 });8 function expect(arr, enc) {9 function isNumber(num) {10 return typeof num === 'number';11 }12 var out = Buffer.concat(encoder.render()).toString('hex');13 if (Array.isArray(arr) && !arr.every(isNumber)) {14 arr = arr.map(function(item) {15 return new Buffer(item, enc);16 });17 arr = Buffer.concat(arr);18 } else {19 arr = new Buffer(arr, enc);20 }21 var actual = arr.toString('hex');22 assert.equal(out, actual);23 }24 describe('bit', function() {25 it('should encode number bit-by-bit', function() {26 [ 1, 1, 1, 0, 1, 0, 1, 0,27 1, 0, 1, 0, 1, 1, 1, 1 ].forEach(function(bit) {28 encoder.encodeBit(bit);29 });30 expect([31 0b11101010,32 0b1010111133 ]);34 });35 it('should encode number using multiple bits', function() {36 for (var i = 0; i < 8; i++)37 encoder.encodeBits(0b1011010, 7);38 expect([39 0b10110101,40 0b01101010,41 0b11010101,42 0b10101011,43 0b01010110,44 0b10101101,45 0b0101101046 ]);47 });48 });49 describe('integer', function() {50 it('should encode 10 in prefix-5 (C.1.1)', function() {51 encoder.skipBits(3);52 encoder.encodeInt(10);53 expect([ 0x0a ]);54 });55 it('should decode 1337 in prefix-5 (C.1.2)', function() {56 encoder.skipBits(3);57 encoder.encodeInt(1337);58 expect([59 0b00011111,60 0b10011010,61 0b0000101062 ]);63 });64 it('should decode 42 at octect boundary (C.1.3)', function() {65 encoder.encodeInt(42);66 expect([ 0b00101010 ]);67 });68 it('should regression 6-bit test', function() {69 encoder.skipBits(2);70 encoder.encodeInt(63);71 expect([ 0b00111111, 0b00000000 ]);72 });73 });74 describe('string', function() {75 it('should encode literal from (C.2.1)', function() {76 encoder.encodeStr(new Buffer('custom-key'), false);77 expect([ [ 0x0a ], 'custom-key' ]);78 });79 it('should encode literal from (C.4.1)', function() {80 encoder.encodeStr(new Buffer('www.example.com'), true);81 expect('8c' +82 'f1e3 c2e5 f23a 6ba0 ab90 f4ff'.replace(/ /g, ''),83 'hex');84 });85 it('should decode literal from (C.4.2)', function() {86 encoder.encodeStr(new Buffer('no-cache'), true);87 expect(88 '86' +89 'a8eb 1064 9cbf'.replace(/ /g, ''),90 'hex');91 });92 it('should encode literal from (C.4.3) #1', function() {93 encoder.encodeStr(new Buffer('custom-key'), true);94 expect(95 '88' +96 '25a8 49e9 5ba9 7d7f'.replace(/ /g, ''),97 'hex');98 });99 it('should encode literal from (C.4.3) #2', function() {100 encoder.encodeStr(new Buffer('custom-value'), true);101 expect(102 '89' +103 '25a8 49e9 5bb8 e8b4 bf'.replace(/ /g, ''),104 'hex');105 });106 it('should encode literal from (C.6.1) #1', function() {107 encoder.encodeStr(new Buffer('Mon, 21 Oct 2013 20:13:21 GMT'), true);108 expect(109 ('96' +110 'd07a be94 1054 d444 a820 0595 040b 8166' +111 'e082 a62d 1bff').replace(/ /g, ''),112 'hex');113 });114 it('should encode literal from (C.6.1) #2', function() {115 encoder.encodeStr(new Buffer('https://www.example.com'), true);116 expect(117 ('91' +118 '9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43' +119 'd3').replace(/ /g, ''),120 'hex');121 });122 it('should encode many 5 bit chars', function() {123 encoder.encodeStr(new Buffer('eeeeeeee'), true);124 // e = 00101, 0x294A5294A5 = 00101 x 8125 expect('85294A5294A5', 'hex');126 });127 it('should encode many 5 bit chars with 3-bit EOS', function() {128 // e = 00101, EOS=111,129 // 0x294A5294A52F = 00101 x 9 + 111130 encoder.encodeStr(new Buffer('eeeeeeeee'), true);131 expect('86294A5294A52F', 'hex');132 });133 it('should decode many 5 bit chars with 2-bit EOS', function() {134 // e = 00101, EOS=11,135 // 0x294A5297 = 00101 x 6 + 11136 encoder.encodeStr(new Buffer('eeeeee'), true);137 expect('84294A5297', 'hex');138 });139 it('should decode many multi-octet chars', function() {140 encoder.encodeStr([ 1, 1, 1, 1, 1, 1, 1, 1 ], true);141 expect('97ffffb1ffff63fffec7fffd8ffffb1ffff63fffec7fffd8',142 'hex');143 });144 });...

Full Screen

Full Screen

encode_decode_uri.js

Source:encode_decode_uri.js Github

copy

Full Screen

1// --------------------------------------------------------------------------------2var resolution = 251; // set to 1 for 100% coverage3function checkEncodeException(encodeFunctionName,c1,c2)4{5 if (c2 == undefined)6 shouldThrow(encodeFunctionName7 + "(String.fromCharCode(" + c1 + "))");8 else9 shouldThrow(encodeFunctionName10 + "(String.fromCharCode(" + c1 + ") + String.fromCharCode(" + c2 + "))");11}12function checkEncodeDecode(encodeFunctionName, decodeFunctionName, c1, c2)13{14 if (c2 == undefined)15 shouldBe(decodeFunctionName + "(" + encodeFunctionName16 + "(String.fromCharCode(" + c1 + ")))",17 "String.fromCharCode(" + c1 + ")");18 else19 shouldBe(decodeFunctionName + "(" + encodeFunctionName20 + "(String.fromCharCode(" + c1 + ") + String.fromCharCode(" + c2 + ")))",21 "String.fromCharCode(" + c1 + ") + String.fromCharCode(" + c2 + ")");22}23function checkWithFunctions(encodeFunction, decodeFunction)24{25 checkEncodeDecode(encodeFunction, decodeFunction, 0);26 checkEncodeDecode(encodeFunction, decodeFunction, 0xD7FF);27 checkEncodeDecode(encodeFunction, decodeFunction, 0xE000);28 checkEncodeDecode(encodeFunction, decodeFunction, 0xFFFD);29 checkEncodeDecode(encodeFunction, decodeFunction, 0xFFFE);30 checkEncodeDecode(encodeFunction, decodeFunction, 0xFFFF);31 checkEncodeException(encodeFunction, 0xDC00);32 checkEncodeException(encodeFunction, 0xDFFF);33 checkEncodeDecode(encodeFunction, decodeFunction, 0xD800, 0xDC00);34 checkEncodeDecode(encodeFunction, decodeFunction, 0xDBFF, 0xDC00);35 checkEncodeDecode(encodeFunction, decodeFunction, 0xD800, 0xDFFF);36 checkEncodeDecode(encodeFunction, decodeFunction, 0xDBFF, 0xDFFF);37 checkEncodeException(encodeFunction, 0xD800, 0);38 checkEncodeException(encodeFunction, 0xD800, 0xD7FF);39 checkEncodeException(encodeFunction, 0xD800, 0xD800);40 checkEncodeException(encodeFunction, 0xD800, 0xDBFF);41 checkEncodeException(encodeFunction, 0xD800, 0xE000);42 checkEncodeException(encodeFunction, 0xD800, 0xE000);43 checkEncodeException(encodeFunction, 0xD800, 0xFFFD);44 checkEncodeException(encodeFunction, 0xD800, 0xFFFE);45 checkEncodeException(encodeFunction, 0xD800, 0xFFFF);46 for (var charcode = 1; charcode < 0xD7FF; charcode += resolution)47 checkEncodeDecode(encodeFunction, decodeFunction, charcode);48 for (var charcode = 0xE001; charcode < 0xFFFD; charcode += resolution)49 checkEncodeDecode(encodeFunction, decodeFunction, charcode);50 for (var charcode = 0xDC01; charcode < 0xDFFF; charcode += resolution)51 checkEncodeException(encodeFunction, charcode);52 for (var charcode = 0xD801; charcode < 0xDBFF; charcode += resolution)53 checkEncodeDecode(encodeFunction, decodeFunction, charcode, 0xDC00);54 for (var charcode = 0xDC01; charcode < 0xDFFF; charcode += resolution)55 checkEncodeDecode(encodeFunction, decodeFunction, 0xD800, charcode);56 for (var charcode = 1; charcode < 0xDBFF; charcode += resolution)57 checkEncodeException(encodeFunction, 0xD800, charcode);58 for (var charcode = 0xE001; charcode < 0xFFFD; charcode += resolution)59 checkEncodeException(encodeFunction, 0xD800, charcode);60}61checkWithFunctions("encodeURI", "decodeURI");62checkWithFunctions("encodeURIComponent", "decodeURIComponent");...

Full Screen

Full Screen

encodemessage.js

Source:encodemessage.js Github

copy

Full Screen

1// Copyright 2012 Selenium committers2// Copyright 2012 Software Freedom Conservancy3//4// Licensed under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.15/**16 * @fileoverview Defines the encode message type.17 */18goog.provide('safaridriver.inject.message.Encode');19goog.require('safaridriver.message');20/**21 * A {@link safaridriver.message.Type.ENCODE} message.22 * @param {string} id The ID from the command this is a response to.23 * @param {string} css The CSS locator for the element to encode.24 * @constructor25 * @extends {safaridriver.message.Message}26 */27safaridriver.inject.message.Encode = function(id, css) {28 goog.base(this, safaridriver.inject.message.Encode.TYPE);29 this.setField(safaridriver.inject.message.Encode.Field_.ID, id);30 this.setField(safaridriver.inject.message.Encode.Field_.CSS, css);31};32goog.inherits(safaridriver.inject.message.Encode,33 safaridriver.message.Message);34/**35 * @type {string}36 * @const37 */38safaridriver.inject.message.Encode.TYPE = 'encode';39/**40 * @enum {string}41 * @private42 */43safaridriver.inject.message.Encode.Field_ = {44 ID: 'id',45 CSS: 'css'46};47/**48 * @param {!Object.<*>} data The data object to convert.49 * @return {!safaridriver.inject.message.Encode} The new message.50 * @throws {Error} If the data object does not define a valid message.51 * @private52 */53safaridriver.inject.message.Encode.fromData_ = function(data) {54 var id = data[safaridriver.inject.message.Encode.Field_.ID];55 var css = data[safaridriver.inject.message.Encode.Field_.CSS];56 if (!goog.isString(id) || !goog.isString(css)) {57 throw safaridriver.message.throwInvalidMessageError(data);58 }59 return new safaridriver.inject.message.Encode(id, css);60};61/** @return {string} This response's ID. */62safaridriver.inject.message.Encode.prototype.getId = function() {63 return /** @type {string} */ (this.getField(64 safaridriver.inject.message.Encode.Field_.ID));65};66/** @return {string} The CSS locator of the element to encode. */67safaridriver.inject.message.Encode.prototype.getLocator = function() {68 return /** @type {string} */ (this.getField(69 safaridriver.inject.message.Encode.Field_.CSS));70};71safaridriver.message.registerMessageType(72 safaridriver.inject.message.Encode.TYPE,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var karma = require('karma');2var karmaServer = new karma.Server({3}, function(exitCode) {4 console.log('Karma has exited with ' + exitCode);5 process.exit(exitCode);6}).start();7module.exports = function(config) {8 config.set({9 });10};11PhantomJS 1.9.8 (Mac OS X) INFO: 'Connected on socket /#jV7ZuJ4r5r5r5r5r5r5r with id 1534697'12PhantomJS 1.9.8 (Mac OS X): Executed 1 of 1 SUCCESS (0.004 secs / 0.004 secs)13PhantomJS 1.9.8 (Mac OS X) INFO: 'Connected on socket /#jV7ZuJ4r5r5r5r5r5r5r with id 1534697'14PhantomJS 1.9.8 (Mac OS X): Executed 1 of 1 SUCCESS (0.004 secs / 0.004 secs)

Full Screen

Using AI Code Generation

copy

Full Screen

1var karmaEncoder = require('karma-encoder');2var karma = karmaEncoder.encode("karma");3console.log(karma);4var karmaEncoder = require('karma-encoder');5var karma = karmaEncoder.decode("karma");6console.log(karma);7var karmaEncoder = require('karma-encoder');8var karma = karmaEncoder.encode("karma");9console.log(karma);10var karmaEncoder = require('karma-encoder');11var karma = karmaEncoder.decode("karma");12console.log(karma);13var karmaEncoder = require('karma-encoder');14var karma = karmaEncoder.encode("karma");15console.log(karma);16var karmaEncoder = require('karma-encoder');17var karma = karmaEncoder.decode("karma");18console.log(karma);19var karmaEncoder = require('karma-encoder');20var karma = karmaEncoder.encode("karma");21console.log(karma);22var karmaEncoder = require('karma-encoder');23var karma = karmaEncoder.decode("karma");24console.log(karma);25var karmaEncoder = require('karma-encoder');26var karma = karmaEncoder.encode("karma");27console.log(karma);28var karmaEncoder = require('karma-encoder');29var karma = karmaEncoder.decode("karma");30console.log(karma);31var karmaEncoder = require('karma-encoder');32var karma = karmaEncoder.encode("karma");33console.log(karma);34var karmaEncoder = require('karma-encoder');35var karma = karmaEncoder.decode("karma");36console.log(karma);37var karmaEncoder = require('karma-encoder');38var karma = karmaEncoder.encode("karma");39console.log(karma);40var karmaEncoder = require('karma-encoder');41var karma = karmaEncoder.decode("karma");42console.log(karma);

Full Screen

Using AI Code Generation

copy

Full Screen

1var karmaEncoder = require("karma-encoder");2var karma = new karmaEncoder();3var encodedString = karma.encode("Hello World");4console.log(encodedString);5var decodedString = karma.decode(encodedString);6console.log(decodedString);7function KarmaEncoder() {8 this.encode = function (string) {9 var karma = "karma";10 var encodedString = "";11 for (var i = 0; i < string.length; i++) {12 encodedString += karma[string.charCodeAt(i) % 5];13 }14 return encodedString;15 };16 this.decode = function (string) {17 var karma = "karma";18 var decodedString = "";19 for (var i = 0; i < string.length; i++) {20 decodedString += String.fromCharCode(karma.indexOf(string[i]) + 97);21 }22 return decodedString;23 };24}25module.exports = KarmaEncoder;

Full Screen

Using AI Code Generation

copy

Full Screen

1var KarmaEncoder = require('./karmaEncoder');2var karmaEncoder = new KarmaEncoder();3var encoded = karmaEncoder.encode('hello world');4console.log(encoded);5var KarmaEncoder = function() {6 this.encode = function(input) {7 return input;8 }9}10module.exports = KarmaEncoder;

Full Screen

Using AI Code Generation

copy

Full Screen

1var KarmaEncoder = require('./karma-encoder.js');2var karma = new KarmaEncoder();3var encodedString = karma.encode("Hello World");4console.log(encodedString);5var KarmaEncoder = function() {6 this.encode = function(str) {7 return str;8 }9}10module.exports = KarmaEncoder;

Full Screen

Using AI Code Generation

copy

Full Screen

1var KarmaEncoder = require('karma-encoder');2var karmaEncoder = new KarmaEncoder();3var encodedString = karmaEncoder.encode('hello world');4var KarmaEncoder = require('karma-encoder');5var karmaEncoder = new KarmaEncoder();6var decodedString = karmaEncoder.decode('Ħėľļŏ ŵŏŗľď');

Full Screen

Using AI Code Generation

copy

Full Screen

1var KarmaEncoder = require('./lib/karmaEncoder');2var encoder = new KarmaEncoder();3var encodedMessage = encoder.encode("Hello world");4console.log(encodedMessage);5function KarmaEncoder() {6}7KarmaEncoder.prototype.encode = function(message) {8 return message;9}10module.exports = KarmaEncoder;11KarmaEncoder.prototype.encode = function(message) {12 var encodedMessage = "";13 for (var i = 0; i < message.length; i++) {14 var char = message[i];15 if (char === 'a') {16 encodedMessage += 'ka';17 } else if (char === 'e') {18 encodedMessage += 'ke';19 } else if (char === 'i') {20 encodedMessage += 'ki';21 } else if (char === 'o') {22 encodedMessage += 'ko';23 } else if (char === 'u') {24 encodedMessage += 'ku';25 } else {26 encodedMessage += char;27 }28 }29 return encodedMessage;30}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Karma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful