Best JavaScript code snippet using argos
scam.js
Source:scam.js
1const Asena = require('../events');2const {MessageType, MessageOptions, Mimetype, Presence} = require('@adiwajshing/baileys');3const Language = require('../language');4const Lang = Language.getString('scam');5Asena.addCommand({pattern: 'scam ?(.*)', fromMe: true, desc: Lang.SCAM_DESC}, (async (message, match) => {6 if (match[1] === '') {7 return await message.sendMessage(Lang.SCAM_NOTFOUND);8 } else if (match[1] === 'typing') {9 await message.client.updatePresence(message.jid,Presence.composing)10 await new Promise(r => setTimeout(r, 10000));11 await message.client.updatePresence(message.jid,Presence.composing)12 await new Promise(r => setTimeout(r, 10000));13 await message.client.updatePresence(message.jid,Presence.composing)14 await new Promise(r => setTimeout(r, 10000));15 await message.client.updatePresence(message.jid,Presence.composing)16 await new Promise(r => setTimeout(r, 10000));17 await message.client.updatePresence(message.jid,Presence.composing)18 await new Promise(r => setTimeout(r, 10000));19 await message.client.updatePresence(message.jid,Presence.composing)20 await new Promise(r => setTimeout(r, 10000));21 await message.client.updatePresence(message.jid,Presence.composing)22 await new Promise(r => setTimeout(r, 10000));23 await message.client.updatePresence(message.jid,Presence.composing)24 await new Promise(r => setTimeout(r, 10000));25 await message.client.updatePresence(message.jid,Presence.composing)26 await new Promise(r => setTimeout(r, 10000));27 await message.client.updatePresence(message.jid,Presence.composing)28 await new Promise(r => setTimeout(r, 10000));29 await message.client.updatePresence(message.jid,Presence.composing)30 await new Promise(r => setTimeout(r, 10000));31 await message.client.updatePresence(message.jid,Presence.composing)32 await new Promise(r => setTimeout(r, 10000));33 await message.client.updatePresence(message.jid,Presence.composing)34 await new Promise(r => setTimeout(r, 10000));35 await message.client.updatePresence(message.jid,Presence.composing)36 await new Promise(r => setTimeout(r, 10000));37 await message.client.updatePresence(message.jid,Presence.composing)38 await new Promise(r => setTimeout(r, 10000));39 await message.client.updatePresence(message.jid,Presence.composing)40 await new Promise(r => setTimeout(r, 10000));41 await message.client.updatePresence(message.jid,Presence.composing)42 await new Promise(r => setTimeout(r, 10000));43 await message.client.updatePresence(message.jid,Presence.composing)44 await new Promise(r => setTimeout(r, 10000));45 await message.client.updatePresence(message.jid,Presence.composing)46 await new Promise(r => setTimeout(r, 10000));47 await message.client.updatePresence(message.jid,Presence.composing)48 await new Promise(r => setTimeout(r, 10000));49 await message.client.updatePresence(message.jid,Presence.composing)50 await new Promise(r => setTimeout(r, 10000));51 await message.client.updatePresence(message.jid,Presence.composing)52 await new Promise(r => setTimeout(r, 10000));53 await message.client.updatePresence(message.jid,Presence.composing)54 await new Promise(r => setTimeout(r, 10000));55 await message.client.updatePresence(message.jid,Presence.composing)56 await new Promise(r => setTimeout(r, 10000));57 await message.client.updatePresence(message.jid,Presence.composing)58 await new Promise(r => setTimeout(r, 10000));59 await message.client.updatePresence(message.jid,Presence.composing)60 await message.client.updatePresence(message.jid,Presence.composing)61 await new Promise(r => setTimeout(r, 10000));62 await message.client.updatePresence(message.jid,Presence.composing)63 await new Promise(r => setTimeout(r, 10000));64 await message.client.updatePresence(message.jid,Presence.composing)65 await new Promise(r => setTimeout(r, 10000));66 await message.client.updatePresence(message.jid,Presence.composing)67 await new Promise(r => setTimeout(r, 10000));68 await message.client.updatePresence(message.jid,Presence.composing)69 await new Promise(r => setTimeout(r, 10000));70 await message.client.updatePresence(message.jid,Presence.composing)71 await new Promise(r => setTimeout(r, 10000));72 await message.client.updatePresence(message.jid,Presence.composing)73 await new Promise(r => setTimeout(r, 10000));74 await message.client.updatePresence(message.jid,Presence.composing)75 await new Promise(r => setTimeout(r, 10000));76 await message.client.updatePresence(message.jid,Presence.composing)77 await new Promise(r => setTimeout(r, 10000));78 await message.client.updatePresence(message.jid,Presence.composing)79 await new Promise(r => setTimeout(r, 10000));80 await message.client.updatePresence(message.jid,Presence.composing)81 await new Promise(r => setTimeout(r, 10000));82 await message.client.updatePresence(message.jid,Presence.composing)83 await new Promise(r => setTimeout(r, 10000));84 await message.client.updatePresence(message.jid,Presence.composing)85 await new Promise(r => setTimeout(r, 10000));86 await message.client.updatePresence(message.jid,Presence.composing)87 await new Promise(r => setTimeout(r, 10000));88 await message.client.updatePresence(message.jid,Presence.composing)89 await new Promise(r => setTimeout(r, 10000));90 await message.client.updatePresence(message.jid,Presence.composing)91 await new Promise(r => setTimeout(r, 10000));92 await message.client.updatePresence(message.jid,Presence.composing)93 await new Promise(r => setTimeout(r, 10000));94 await message.client.updatePresence(message.jid,Presence.composing)95 await new Promise(r => setTimeout(r, 10000));96 await message.client.updatePresence(message.jid,Presence.composing)97 await new Promise(r => setTimeout(r, 10000));98 await message.client.updatePresence(message.jid,Presence.composing)99 await new Promise(r => setTimeout(r, 10000));100 await message.client.updatePresence(message.jid,Presence.composing)101 await new Promise(r => setTimeout(r, 10000));102 await message.client.updatePresence(message.jid,Presence.composing)103 await new Promise(r => setTimeout(r, 10000));104 await message.client.updatePresence(message.jid,Presence.composing)105 await new Promise(r => setTimeout(r, 10000));106 await message.client.updatePresence(message.jid,Presence.composing)107 await new Promise(r => setTimeout(r, 10000));108 await message.client.updatePresence(message.jid,Presence.composing)109 await new Promise(r => setTimeout(r, 10000));110 await message.client.updatePresence(message.jid,Presence.composing)111 } else if (match[1] === 'online') {112 await message.client.updatePresence(message.jid,Presence.available)113 await new Promise(r => setTimeout(r, 10000));114 await message.client.updatePresence(message.jid,Presence.available)115 await new Promise(r => setTimeout(r, 10000));116 await message.client.updatePresence(message.jid,Presence.available)117 await new Promise(r => setTimeout(r, 10000));118 await message.client.updatePresence(message.jid,Presence.available)119 await new Promise(r => setTimeout(r, 10000));120 await message.client.updatePresence(message.jid,Presence.available)121 await new Promise(r => setTimeout(r, 10000));122 await message.client.updatePresence(message.jid,Presence.available)123 await new Promise(r => setTimeout(r, 10000));124 await message.client.updatePresence(message.jid,Presence.available)125 await new Promise(r => setTimeout(r, 10000));126 await message.client.updatePresence(message.jid,Presence.available)127 await new Promise(r => setTimeout(r, 10000));128 await message.client.updatePresence(message.jid,Presence.available)129 await new Promise(r => setTimeout(r, 10000));130 await message.client.updatePresence(message.jid,Presence.available)131 await new Promise(r => setTimeout(r, 10000));132 await message.client.updatePresence(message.jid,Presence.available)133 await new Promise(r => setTimeout(r, 10000));134 await message.client.updatePresence(message.jid,Presence.available)135 await new Promise(r => setTimeout(r, 10000));136 await message.client.updatePresence(message.jid,Presence.available)137 await new Promise(r => setTimeout(r, 10000));138 await message.client.updatePresence(message.jid,Presence.available)139 await new Promise(r => setTimeout(r, 10000));140 await message.client.updatePresence(message.jid,Presence.available)141 await new Promise(r => setTimeout(r, 10000));142 await message.client.updatePresence(message.jid,Presence.available)143 await new Promise(r => setTimeout(r, 10000));144 await message.client.updatePresence(message.jid,Presence.available)145 await new Promise(r => setTimeout(r, 10000));146 await message.client.updatePresence(message.jid,Presence.available)147 await new Promise(r => setTimeout(r, 10000));148 await message.client.updatePresence(message.jid,Presence.available)149 await new Promise(r => setTimeout(r, 10000));150 await message.client.updatePresence(message.jid,Presence.available)151 await new Promise(r => setTimeout(r, 10000));152 await message.client.updatePresence(message.jid,Presence.available)153 await new Promise(r => setTimeout(r, 10000));154 await message.client.updatePresence(message.jid,Presence.available)155 await new Promise(r => setTimeout(r, 10000));156 await message.client.updatePresence(message.jid,Presence.available)157 await new Promise(r => setTimeout(r, 10000));158 await message.client.updatePresence(message.jid,Presence.available)159 await new Promise(r => setTimeout(r, 10000));160 await message.client.updatePresence(message.jid,Presence.available)161 await new Promise(r => setTimeout(r, 10000));162 await message.client.updatePresence(message.jid,Presence.available)163 await message.client.updatePresence(message.jid,Presence.available)164 await new Promise(r => setTimeout(r, 10000));165 await message.client.updatePresence(message.jid,Presence.available)166 await new Promise(r => setTimeout(r, 10000));167 await message.client.updatePresence(message.jid,Presence.available)168 await new Promise(r => setTimeout(r, 10000));169 await message.client.updatePresence(message.jid,Presence.available)170 await new Promise(r => setTimeout(r, 10000));171 await message.client.updatePresence(message.jid,Presence.available)172 await new Promise(r => setTimeout(r, 10000));173 await message.client.updatePresence(message.jid,Presence.available)174 await new Promise(r => setTimeout(r, 10000));175 await message.client.updatePresence(message.jid,Presence.available)176 await new Promise(r => setTimeout(r, 10000));177 await message.client.updatePresence(message.jid,Presence.available)178 await new Promise(r => setTimeout(r, 10000));179 await message.client.updatePresence(message.jid,Presence.available)180 await new Promise(r => setTimeout(r, 10000));181 await message.client.updatePresence(message.jid,Presence.available)182 await new Promise(r => setTimeout(r, 10000));183 await message.client.updatePresence(message.jid,Presence.available)184 await new Promise(r => setTimeout(r, 10000));185 await message.client.updatePresence(message.jid,Presence.available)186 await new Promise(r => setTimeout(r, 10000));187 await message.client.updatePresence(message.jid,Presence.available)188 await new Promise(r => setTimeout(r, 10000));189 await message.client.updatePresence(message.jid,Presence.available)190 await new Promise(r => setTimeout(r, 10000));191 await message.client.updatePresence(message.jid,Presence.available)192 await new Promise(r => setTimeout(r, 10000));193 await message.client.updatePresence(message.jid,Presence.available)194 await new Promise(r => setTimeout(r, 10000));195 await message.client.updatePresence(message.jid,Presence.available)196 await new Promise(r => setTimeout(r, 10000));197 await message.client.updatePresence(message.jid,Presence.available)198 await new Promise(r => setTimeout(r, 10000));199 await message.client.updatePresence(message.jid,Presence.available)200 await new Promise(r => setTimeout(r, 10000));201 await message.client.updatePresence(message.jid,Presence.available)202 await new Promise(r => setTimeout(r, 10000));203 await message.client.updatePresence(message.jid,Presence.available)204 await new Promise(r => setTimeout(r, 10000));205 await message.client.updatePresence(message.jid,Presence.available)206 await new Promise(r => setTimeout(r, 10000));207 await message.client.updatePresence(message.jid,Presence.available)208 await new Promise(r => setTimeout(r, 10000));209 await message.client.updatePresence(message.jid,Presence.available)210 await new Promise(r => setTimeout(r, 10000));211 await message.client.updatePresence(message.jid,Presence.available)212 await new Promise(r => setTimeout(r, 10000));213 await message.client.updatePresence(message.jid,Presence.available)214 } else if (match[1] === 'recording') {215 await message.client.updatePresence(message.jid,Presence.recording)216 await new Promise(r => setTimeout(r, 10000));217 await message.client.updatePresence(message.jid,Presence.recording)218 await new Promise(r => setTimeout(r, 10000));219 await message.client.updatePresence(message.jid,Presence.recording)220 await new Promise(r => setTimeout(r, 10000));221 await message.client.updatePresence(message.jid,Presence.recording)222 await new Promise(r => setTimeout(r, 10000));223 await message.client.updatePresence(message.jid,Presence.recording)224 await new Promise(r => setTimeout(r, 10000));225 await message.client.updatePresence(message.jid,Presence.recording)226 await new Promise(r => setTimeout(r, 10000));227 await message.client.updatePresence(message.jid,Presence.recording)228 await new Promise(r => setTimeout(r, 10000));229 await message.client.updatePresence(message.jid,Presence.recording)230 await new Promise(r => setTimeout(r, 10000));231 await message.client.updatePresence(message.jid,Presence.recording)232 await new Promise(r => setTimeout(r, 10000));233 await message.client.updatePresence(message.jid,Presence.recording)234 await new Promise(r => setTimeout(r, 10000));235 await message.client.updatePresence(message.jid,Presence.recording)236 await new Promise(r => setTimeout(r, 10000));237 await message.client.updatePresence(message.jid,Presence.recording)238 await new Promise(r => setTimeout(r, 10000));239 await message.client.updatePresence(message.jid,Presence.recording)240 await new Promise(r => setTimeout(r, 10000));241 await message.client.updatePresence(message.jid,Presence.recording)242 await new Promise(r => setTimeout(r, 10000));243 await message.client.updatePresence(message.jid,Presence.recording)244 await new Promise(r => setTimeout(r, 10000));245 await message.client.updatePresence(message.jid,Presence.recording)246 await new Promise(r => setTimeout(r, 10000));247 await message.client.updatePresence(message.jid,Presence.recording)248 await new Promise(r => setTimeout(r, 10000));249 await message.client.updatePresence(message.jid,Presence.recording)250 await new Promise(r => setTimeout(r, 10000));251 await message.client.updatePresence(message.jid,Presence.recording)252 await new Promise(r => setTimeout(r, 10000));253 await message.client.updatePresence(message.jid,Presence.recording)254 await new Promise(r => setTimeout(r, 10000));255 await message.client.updatePresence(message.jid,Presence.recording)256 await new Promise(r => setTimeout(r, 10000));257 await message.client.updatePresence(message.jid,Presence.recording)258 await new Promise(r => setTimeout(r, 10000));259 await message.client.updatePresence(message.jid,Presence.recording)260 await new Promise(r => setTimeout(r, 10000));261 await message.client.updatePresence(message.jid,Presence.recording)262 await new Promise(r => setTimeout(r, 10000));263 await message.client.updatePresence(message.jid,Presence.recording)264 await new Promise(r => setTimeout(r, 10000));265 await message.client.updatePresence(message.jid,Presence.recording)266 await message.client.updatePresence(message.jid,Presence.recording)267 await new Promise(r => setTimeout(r, 10000));268 await message.client.updatePresence(message.jid,Presence.recording)269 await new Promise(r => setTimeout(r, 10000));270 await message.client.updatePresence(message.jid,Presence.recording)271 await new Promise(r => setTimeout(r, 10000));272 await message.client.updatePresence(message.jid,Presence.recording)273 await new Promise(r => setTimeout(r, 10000));274 await message.client.updatePresence(message.jid,Presence.recording)275 await new Promise(r => setTimeout(r, 10000));276 await message.client.updatePresence(message.jid,Presence.recording)277 await new Promise(r => setTimeout(r, 10000));278 await message.client.updatePresence(message.jid,Presence.recording)279 await new Promise(r => setTimeout(r, 10000));280 await message.client.updatePresence(message.jid,Presence.recording)281 await new Promise(r => setTimeout(r, 10000));282 await message.client.updatePresence(message.jid,Presence.recording)283 await new Promise(r => setTimeout(r, 10000));284 await message.client.updatePresence(message.jid,Presence.recording)285 await new Promise(r => setTimeout(r, 10000));286 await message.client.updatePresence(message.jid,Presence.recording)287 await new Promise(r => setTimeout(r, 10000));288 await message.client.updatePresence(message.jid,Presence.recording)289 await new Promise(r => setTimeout(r, 10000));290 await message.client.updatePresence(message.jid,Presence.recording)291 await new Promise(r => setTimeout(r, 10000));292 await message.client.updatePresence(message.jid,Presence.recording)293 await new Promise(r => setTimeout(r, 10000));294 await message.client.updatePresence(message.jid,Presence.recording)295 await new Promise(r => setTimeout(r, 10000));296 await message.client.updatePresence(message.jid,Presence.recording)297 await new Promise(r => setTimeout(r, 10000));298 await message.client.updatePresence(message.jid,Presence.recording)299 await new Promise(r => setTimeout(r, 10000));300 await message.client.updatePresence(message.jid,Presence.recording)301 await new Promise(r => setTimeout(r, 10000));302 await message.client.updatePresence(message.jid,Presence.recording)303 await new Promise(r => setTimeout(r, 10000));304 await message.client.updatePresence(message.jid,Presence.recording)305 await new Promise(r => setTimeout(r, 10000));306 await message.client.updatePresence(message.jid,Presence.recording)307 await new Promise(r => setTimeout(r, 10000));308 await message.client.updatePresence(message.jid,Presence.recording)309 await new Promise(r => setTimeout(r, 10000));310 await message.client.updatePresence(message.jid,Presence.recording)311 await new Promise(r => setTimeout(r, 10000));312 await message.client.updatePresence(message.jid,Presence.recording)313 await new Promise(r => setTimeout(r, 10000));314 await message.client.updatePresence(message.jid,Presence.recording)315 await new Promise(r => setTimeout(r, 10000));316 await message.client.updatePresence(message.jid,Presence.recording)317 } else if (match[1] === 'stop') {318 return await message.client.updatePresence(message.jid,Presence.paused)319 } else {320 await message.sendMessage(Lang.SCAM_NULL);321 }...
Timeout.js
Source:Timeout.js
1import React from 'react'2import $ from 'jquery'3import { Swiper , SwiperSlide } from 'swiper/react'4import SwiperCode,{ Navigation , Pagination , Autoplay } from 'swiper'5import 'swiper/swiper-bundle.css'6SwiperCode.use([Navigation , Pagination ,Autoplay])7class SectionTimeout extends React.Component{8 componentDidMount(){9 var timeHr = document.querySelector('.time-hr')10 var timeMin = document.querySelector('.time-min')11 var timeSec = document.querySelector('.time-sec')12 setInterval(function (){13 var time = new Date()14 var nowtime = time.getTime();15 time.setMonth(11)16 time.setDate(31)17 time.setHours(24)18 time.setMinutes(0)19 time.setSeconds(0)20 var endtime = time.getTime();21 var offsetTime = (endtime - nowtime) /1000;22 var hr = parseInt(offsetTime / 60 / 60);23 var min = parseInt((offsetTime / 60) % 60);24 var sec = parseInt(offsetTime % 60);25 timeHr.textContent = hr26 timeMin.textContent = min27 timeSec.textContent = sec28 },1000)29 }30 31 render(){32 // $(".swiper-slider-box").mouseenter(function(){33 // Swiper.stopAutoPlay();34 // });35 // $(".swiper-slider-box").mouseleave(function(){36 // Swiper.startAutoPlay();37 // });38 return(39 <>40 <div className="timeout">41 <div className="timeout-header">42 <div className="timeout-sales">43 <div className="saletime-text">éæç¹è³£</div>44 <div className="saletime-box">45 <div className="time-hr"></div>:46 <div className="time-min"></div>:47 <div className="time-sec"></div>48 </div>49 </div>50 <a href="#">æ¥çå
¨é¨ ></a>51 </div>52 <Swiper53 slidesPerView={6}54 navigation55 autoplay={{56 delay:3000,57 disableOnInteraction:false58 }}59 speed={1000}60 className="timeout-items"61 width={1200}62 height={240}63 64 >65 <SwiperSlide className="swiper-slider-box">66 <a href="#" className="timeout-product">67 <div className="timeout-img">68 <img src=""></img>69 </div>70 <div className="timeout-price">$600</div>71 <button className="timeout-saled">å·²å®åº0</button>72 </a>73 </SwiperSlide>74 <SwiperSlide className="swiper-slider-box">75 <a href="#" className="timeout-product">76 <div className="timeout-img">77 <img src=""></img>78 </div>79 <div className="timeout-price">$600</div>80 <button className="timeout-saled">å·²å®åº0</button>81 </a>82 </SwiperSlide>83 <SwiperSlide className="swiper-slider-box">84 <a href="#" className="timeout-product">85 <div className="timeout-img">86 <img src=""></img>87 </div>88 <div className="timeout-price">$600</div>89 <button className="timeout-saled">å·²å®åº0</button>90 </a>91 </SwiperSlide>92 <SwiperSlide className="swiper-slider-box">93 <a href="#" className="timeout-product">94 <div className="timeout-img">95 <img src=""></img>96 </div>97 <div className="timeout-price">$600</div>98 <button className="timeout-saled">å·²å®åº0</button>99 </a>100 </SwiperSlide>101 <SwiperSlide className="swiper-slider-box">102 <a href="#" className="timeout-product">103 <div className="timeout-img">104 <img src=""></img>105 </div>106 <div className="timeout-price">$600</div>107 <button className="timeout-saled">å·²å®åº0</button>108 </a>109 </SwiperSlide>110 <SwiperSlide className="swiper-slider-box">111 <a href="#" className="timeout-product">112 <div className="timeout-img">113 <img src=""></img>114 </div>115 <div className="timeout-price">$600</div>116 <button className="timeout-saled">å·²å®åº0</button>117 </a>118 </SwiperSlide>119 <SwiperSlide className="swiper-slider-box">120 <a href="#" className="timeout-product">121 <div className="timeout-img">122 <img src=""></img>123 </div>124 <div className="timeout-price">$600</div>125 <button className="timeout-saled">å·²å®åº0</button>126 </a>127 </SwiperSlide>128 <SwiperSlide className="swiper-slider-box">129 <a href="#" className="timeout-product">130 <div className="timeout-img">131 <img src=""></img>132 </div>133 <div className="timeout-price">$600</div>134 <button className="timeout-saled">å·²å®åº0</button>135 </a>136 </SwiperSlide>137 <SwiperSlide className="swiper-slider-box">138 <a href="#" className="timeout-product">139 <div className="timeout-img">140 <img src=""></img>141 </div>142 <div className="timeout-price">$600</div>143 <button className="timeout-saled">å·²å®åº0</button>144 </a>145 </SwiperSlide>146 </Swiper>147 </div>148 </>149 )150 }151}...
_timeoutWaiter.js
Source:_timeoutWaiter.js
1/*global QUnit, sinon */2sap.ui.define([3 "jquery.sap.global",4 "../utils/loggerInterceptor",5 "sap/ui/test/autowaiter/_timeoutWaiter"6], function ($, loggerInterceptor,timeoutWaiter) {7 "use strict";8 var fnSetTimeout = window["setTimeout"];9 var fnClearTimeout = window["clearTimeout"];10 ["Timeout", "Immediate"].forEach(function (sFunctionUnderTest) {11 var fnSetFunction = window["set" + sFunctionUnderTest];12 var fnClearFunction = window["clear" + sFunctionUnderTest];13 if (!fnSetFunction) {14 $.sap.log.debug("Skipped tests because" + sFunctionUnderTest + " is not defined in this browser");15 return;16 }17 QUnit.module("timeoutWaiter - no " + sFunctionUnderTest);18 QUnit.test("Should make sure there is no pending timeout before starting these tests", function (assert) {19 var fnDone = assert.async();20 function noTimeout () {21 var bHasTimeout = timeoutWaiter.hasPending();22 if (!bHasTimeout) {23 assert.ok(true, "no timeout present");24 fnDone();25 } else {26 setTimeout(noTimeout, 50);27 }28 return bHasTimeout;29 }30 noTimeout();31 });32 QUnit.test("Should return that there are no pending timeouts", function (assert) {33 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");34 });35 QUnit.test("Should return that there are no pending Timeouts if a timeout has finished", function (assert) {36 var fnDone = assert.async();37 fnSetFunction(function () {38 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");39 fnDone();40 }, 100);41 });42 QUnit.test("Should ignore long runners", function (assert) {43 var iID = fnSetFunction(function () {}, 1001);44 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");45 fnClearFunction(iID);46 });47 QUnit.test("Should have configurable max timeout delay", function (assert) {48 timeoutWaiter.extendConfig({timeoutWaiter: {maxDelay: 3000}});49 var iID = fnSetFunction(function () {}, 1001);50 var iIDIgnored = fnSetFunction(function () {}, 3001);51 assert.ok(timeoutWaiter.hasPending(), "there is 1 pending timeout");52 fnClearFunction(iID);53 fnClearFunction(iIDIgnored);54 // reset to default value55 timeoutWaiter.extendConfig({timeoutWaiter: {maxDelay: 1000}});56 });57 QUnit.module("timeoutWaiter - single " + sFunctionUnderTest);58 QUnit.test("Should respect the this pointer", function (assert) {59 var oThis = {},60 fnDone = assert.async(),61 fnSpy = sinon.spy(function () {62 sinon.assert.calledOn(fnSpy, oThis);63 fnDone();64 });65 fnSetFunction($.proxy(fnSpy, oThis));66 });67 QUnit.test("Should handle a single timeout", function (assert) {68 var fnDone = assert.async();69 fnSetFunction(function () {70 fnDone();71 });72 assert.ok(timeoutWaiter.hasPending(), "There was a timeout");73 });74 QUnit.module("timeoutWaiter - multiple " + sFunctionUnderTest);75 QUnit.test("Should handle 2 timeouts", function (assert) {76 var fnFirstTimeoutDone = assert.async();77 var fnSecondTimeoutDone = assert.async();78 fnSetFunction(function () {79 assert.ok(timeoutWaiter.hasPending(), "First timeout has compled");80 fnFirstTimeoutDone();81 });82 fnSetFunction(function () {83 assert.ok(!timeoutWaiter.hasPending(), "Both timeouts have completed");84 fnSecondTimeoutDone();85 }, 20);86 assert.ok(timeoutWaiter.hasPending(), "Both timeouts are scheduled");87 });88 QUnit.test("Should handle a timeout that adds a timeout", function (assert) {89 var fnDone = assert.async();90 fnSetFunction(function () {91 assert.ok(!timeoutWaiter.hasPending(), "First timeout has completed");92 fnSetFunction(function () {93 assert.ok(!timeoutWaiter.hasPending(), "Second timeout has completed");94 fnDone();95 });96 assert.ok(timeoutWaiter.hasPending(), "Second timeout is scheduled");97 });98 assert.ok(timeoutWaiter.hasPending(), "First timeout is scheduled");99 });100 QUnit.module("timeoutWaiter - clear " + sFunctionUnderTest);101 QUnit.test("Should clear a timeout", function (assert) {102 var iId = fnSetFunction(function () {});103 fnClearFunction(iId);104 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");105 });106 QUnit.test("Should clear 1 of 2 timeouts", function (assert) {107 var fnDone = assert.async();108 fnSetFunction(function () {109 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts");110 sinon.assert.notCalled(fnSecondTimeoutSpy);111 fnDone();112 },20);113 var fnSecondTimeoutSpy = sinon.spy();114 var iId = fnSetFunction(fnSecondTimeoutSpy);115 fnClearFunction(iId);116 assert.ok(timeoutWaiter.hasPending(), "There was a timeout");117 });118 });119 QUnit.module("timeoutWaiter - infinite timeout loops");120 QUnit.test("Should detect a infinite timeout loop", function (assert) {121 var fnDone = assert.async();122 var aTimeouts = [];123 function addTimeout () {124 aTimeouts.push(fnSetTimeout(addTimeout, 30));125 }126 fnSetTimeout(function () {127 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts - spawned " + aTimeouts.length + " timeouts");128 aTimeouts.forEach(function (iID) {129 fnClearTimeout(iID);130 });131 fnDone();132 }, 600);133 addTimeout();134 });135 QUnit.test("Should detect a infinite timeout loop with 2 timeouts added per loop", function (assert) {136 var fnDone = assert.async();137 var aTimeouts = [];138 function addTimeout () {139 aTimeouts.push(fnSetTimeout(addTimeout, 40));140 aTimeouts.push(fnSetTimeout(addTimeout, 40));141 }142 fnSetTimeout(function () {143 assert.ok(!timeoutWaiter.hasPending(), "there are no pending timeouts - spawned " + aTimeouts.length + " timeouts");144 aTimeouts.forEach(function (iID) {145 fnClearTimeout(iID);146 });147 fnDone();148 }, 600);149 addTimeout();150 });...
browser.js
Source:browser.js
1// shim for using process in browser2var process = module.exports = {};3// cached from whatever global is present so that test runners that stub it4// don't break things. But we need to wrap it in a try catch in case it is5// wrapped in strict mode code which doesn't define any globals. It's inside a6// function because try/catches deoptimize in certain engines.7var cachedSetTimeout;8var cachedClearTimeout;9function defaultSetTimout() {10 throw new Error('setTimeout has not been defined');11}12function defaultClearTimeout () {13 throw new Error('clearTimeout has not been defined');14}15(function () {16 try {17 if (typeof setTimeout === 'function') {18 cachedSetTimeout = setTimeout;19 } else {20 cachedSetTimeout = defaultSetTimout;21 }22 } catch (e) {23 cachedSetTimeout = defaultSetTimout;24 }25 try {26 if (typeof clearTimeout === 'function') {27 cachedClearTimeout = clearTimeout;28 } else {29 cachedClearTimeout = defaultClearTimeout;30 }31 } catch (e) {32 cachedClearTimeout = defaultClearTimeout;33 }34} ())35function runTimeout(fun) {36 if (cachedSetTimeout === setTimeout) {37 //normal enviroments in sane situations38 return setTimeout(fun, 0);39 }40 // if setTimeout wasn't available but was latter defined41 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {42 cachedSetTimeout = setTimeout;43 return setTimeout(fun, 0);44 }45 try {46 // when when somebody has screwed with setTimeout but no I.E. maddness47 return cachedSetTimeout(fun, 0);48 } catch(e){49 try {50 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally51 return cachedSetTimeout.call(null, fun, 0);52 } catch(e){53 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error54 return cachedSetTimeout.call(this, fun, 0);55 }56 }57}58function runClearTimeout(marker) {59 if (cachedClearTimeout === clearTimeout) {60 //normal enviroments in sane situations61 return clearTimeout(marker);62 }63 // if clearTimeout wasn't available but was latter defined64 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {65 cachedClearTimeout = clearTimeout;66 return clearTimeout(marker);67 }68 try {69 // when when somebody has screwed with setTimeout but no I.E. maddness70 return cachedClearTimeout(marker);71 } catch (e){72 try {73 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally74 return cachedClearTimeout.call(null, marker);75 } catch (e){76 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.77 // Some versions of I.E. have different rules for clearTimeout vs setTimeout78 return cachedClearTimeout.call(this, marker);79 }80 }81}82var queue = [];83var draining = false;84var currentQueue;85var queueIndex = -1;86function cleanUpNextTick() {87 if (!draining || !currentQueue) {88 return;89 }90 draining = false;91 if (currentQueue.length) {92 queue = currentQueue.concat(queue);93 } else {94 queueIndex = -1;95 }96 if (queue.length) {97 drainQueue();98 }99}100function drainQueue() {101 if (draining) {102 return;103 }104 var timeout = runTimeout(cleanUpNextTick);105 draining = true;106 var len = queue.length;107 while(len) {108 currentQueue = queue;109 queue = [];110 while (++queueIndex < len) {111 if (currentQueue) {112 currentQueue[queueIndex].run();113 }114 }115 queueIndex = -1;116 len = queue.length;117 }118 currentQueue = null;119 draining = false;120 runClearTimeout(timeout);121}122process.nextTick = function (fun) {123 var args = new Array(arguments.length - 1);124 if (arguments.length > 1) {125 for (var i = 1; i < arguments.length; i++) {126 args[i - 1] = arguments[i];127 }128 }129 queue.push(new Item(fun, args));130 if (queue.length === 1 && !draining) {131 runTimeout(drainQueue);132 }133};134// v8 likes predictible objects135function Item(fun, array) {136 this.fun = fun;137 this.array = array;138}139Item.prototype.run = function () {140 this.fun.apply(null, this.array);141};142process.title = 'browser';143process.browser = true;144process.env = {};145process.argv = [];146process.version = ''; // empty string to avoid regexp issues147process.versions = {};148function noop() {}149process.on = noop;150process.addListener = noop;151process.once = noop;152process.off = noop;153process.removeListener = noop;154process.removeAllListeners = noop;155process.emit = noop;156process.prependListener = noop;157process.prependOnceListener = noop;158process.listeners = function (name) { return [] }159process.binding = function (name) {160 throw new Error('process.binding is not supported');161};162process.cwd = function () { return '/' };163process.chdir = function (dir) {164 throw new Error('process.chdir is not supported');165};...
touch.js
Source:touch.js
1// Zepto.js2// (c) 2010-2012 Thomas Fuchs3// Zepto.js may be freely distributed under the MIT license.45;(function($){6 var touch = {},7 touchTimeout, tapTimeout, swipeTimeout,8 longTapDelay = 750, longTapTimeout910 function parentIfText(node) {11 return 'tagName' in node ? node : node.parentNode12 }1314 function swipeDirection(x1, x2, y1, y2) {15 var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)16 return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')17 }1819 function longTap() {20 longTapTimeout = null21 if (touch.last) {22 touch.el.trigger('longTap')23 touch = {}24 }25 }2627 function cancelLongTap() {28 if (longTapTimeout) clearTimeout(longTapTimeout)29 longTapTimeout = null30 }3132 function cancelAll() {33 if (touchTimeout) clearTimeout(touchTimeout)34 if (tapTimeout) clearTimeout(tapTimeout)35 if (swipeTimeout) clearTimeout(swipeTimeout)36 if (longTapTimeout) clearTimeout(longTapTimeout)37 touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null38 touch = {}39 }4041 $(document).ready(function(){42 var now, delta4344 $(document.body)45 .bind('touchstart', function(e){46 now = Date.now()47 delta = now - (touch.last || now)48 touch.el = $(parentIfText(e.originalEvent.touches[0].target))49 touchTimeout && clearTimeout(touchTimeout)50 touch.x1 = e.originalEvent.touches[0].pageX51 touch.y1 = e.originalEvent.touches[0].pageY52 if (delta > 0 && delta <= 250) touch.isDoubleTap = true53 touch.last = now54 longTapTimeout = setTimeout(longTap, longTapDelay)55 })56 .bind('touchmove', function(e){57 touch.x2 = e.originalEvent.touches[0].pageX58 touch.y2 = e.originalEvent.touches[0].pageY59 //触åæå°å·æ°, TODO å®ç°ä¸æå·æ°60 touch.el.trigger('pulltorefresh',[touch.y1,touch.y2]);61 if (Math.abs(touch.x1 - touch.x2) > 10)62 e.preventDefault()63 })64 .bind('touchend', function(e){65 cancelLongTap()6667 // swipe68 if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||69 (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))7071 swipeTimeout = setTimeout(function() {72 touch.el.trigger('swipe')73 touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))74 touch = {}75 }, 0)7677 // normal tap78 else if ('last' in touch)7980 // delay by one tick so we can cancel the 'tap' event if 'scroll' fires81 // ('tap' fires before 'scroll')82 tapTimeout = setTimeout(function() {8384 // trigger universal 'tap' with the option to cancelTouch()85 // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)86 var event = $.Event('tap')87 event.cancelTouch = cancelAll88 touch.el.trigger(event)8990 // trigger double tap immediately91 if (touch.isDoubleTap) {92 touch.el.trigger('doubleTap')93 touch = {}94 }9596 // trigger single tap after 250ms of inactivity97 else {98 touchTimeout = setTimeout(function(){99 touchTimeout = null100 touch.el.trigger('singleTap')101 touch = {}102 }, 250)103 }104105 }, 0)106107 })108 .bind('touchcancel', cancelAll)109110 $(window).bind('scroll', cancelAll)111 })112113 ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){114 $.fn[m] = function(callback){ return this.bind(m, callback) }115 });116 117
...
retry_operation.js
Source:retry_operation.js
1function RetryOperation(timeouts, options) {2 // Compatibility for the old (timeouts, retryForever) signature3 if (typeof options === 'boolean') {4 options = { forever: options };5 }6 this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));7 this._timeouts = timeouts;8 this._options = options || {};9 this._maxRetryTime = options && options.maxRetryTime || Infinity;10 this._fn = null;11 this._errors = [];12 this._attempts = 1;13 this._operationTimeout = null;14 this._operationTimeoutCb = null;15 this._timeout = null;16 this._operationStart = null;17 if (this._options.forever) {18 this._cachedTimeouts = this._timeouts.slice(0);19 }20}21module.exports = RetryOperation;22RetryOperation.prototype.reset = function() {23 this._attempts = 1;24 this._timeouts = this._originalTimeouts;25}26RetryOperation.prototype.stop = function() {27 if (this._timeout) {28 clearTimeout(this._timeout);29 }30 this._timeouts = [];31 this._cachedTimeouts = null;32};33RetryOperation.prototype.retry = function(err) {34 if (this._timeout) {35 clearTimeout(this._timeout);36 }37 if (!err) {38 return false;39 }40 var currentTime = new Date().getTime();41 if (err && currentTime - this._operationStart >= this._maxRetryTime) {42 this._errors.unshift(new Error('RetryOperation timeout occurred'));43 return false;44 }45 this._errors.push(err);46 var timeout = this._timeouts.shift();47 if (timeout === undefined) {48 if (this._cachedTimeouts) {49 // retry forever, only keep last error50 this._errors.splice(this._errors.length - 1, this._errors.length);51 this._timeouts = this._cachedTimeouts.slice(0);52 timeout = this._timeouts.shift();53 } else {54 return false;55 }56 }57 var self = this;58 var timer = setTimeout(function() {59 self._attempts++;60 if (self._operationTimeoutCb) {61 self._timeout = setTimeout(function() {62 self._operationTimeoutCb(self._attempts);63 }, self._operationTimeout);64 if (self._options.unref) {65 self._timeout.unref();66 }67 }68 self._fn(self._attempts);69 }, timeout);70 if (this._options.unref) {71 timer.unref();72 }73 return true;74};75RetryOperation.prototype.attempt = function(fn, timeoutOps) {76 this._fn = fn;77 if (timeoutOps) {78 if (timeoutOps.timeout) {79 this._operationTimeout = timeoutOps.timeout;80 }81 if (timeoutOps.cb) {82 this._operationTimeoutCb = timeoutOps.cb;83 }84 }85 var self = this;86 if (this._operationTimeoutCb) {87 this._timeout = setTimeout(function() {88 self._operationTimeoutCb();89 }, self._operationTimeout);90 }91 this._operationStart = new Date().getTime();92 this._fn(this._attempts);93};94RetryOperation.prototype.try = function(fn) {95 console.log('Using RetryOperation.try() is deprecated');96 this.attempt(fn);97};98RetryOperation.prototype.start = function(fn) {99 console.log('Using RetryOperation.start() is deprecated');100 this.attempt(fn);101};102RetryOperation.prototype.start = RetryOperation.prototype.try;103RetryOperation.prototype.errors = function() {104 return this._errors;105};106RetryOperation.prototype.attempts = function() {107 return this._attempts;108};109RetryOperation.prototype.mainError = function() {110 if (this._errors.length === 0) {111 return null;112 }113 var counts = {};114 var mainError = null;115 var mainErrorCount = 0;116 for (var i = 0; i < this._errors.length; i++) {117 var error = this._errors[i];118 var message = error.message;119 var count = (counts[message] || 0) + 1;120 counts[message] = count;121 if (count >= mainErrorCount) {122 mainError = error;123 mainErrorCount = count;124 }125 }126 return mainError;...
capture_timeout.js
Source:capture_timeout.js
1const log = require('../logger').create('launcher')2/**3 * Kill browser if it does not capture in given `captureTimeout`.4 */5function CaptureTimeoutLauncher (timer, captureTimeout) {6 if (!captureTimeout) {7 return8 }9 let pendingTimeoutId = null10 this.on('start', () => {11 pendingTimeoutId = timer.setTimeout(() => {12 pendingTimeoutId = null13 if (this.state !== this.STATE_BEING_CAPTURED) {14 return15 }16 log.warn(`${this.name} have not captured in ${captureTimeout} ms, killing.`)17 this.error = 'timeout'18 this.kill()19 }, captureTimeout)20 })21 this.on('done', () => {22 if (pendingTimeoutId) {23 timer.clearTimeout(pendingTimeoutId)24 pendingTimeoutId = null25 }26 })27}28CaptureTimeoutLauncher.decoratorFactory = function (timer,29 /* config.captureTimeout */ captureTimeout) {30 return function (launcher) {31 CaptureTimeoutLauncher.call(launcher, timer, captureTimeout)32 }33}34CaptureTimeoutLauncher.decoratorFactory.$inject = ['timer', 'config.captureTimeout']...
refresh.js
Source:refresh.js
1export default {2 setTimeoutWithJitter (commit, callback, seconds) {3 // cancel any previous timeouts4 commit('cancelTimeouts')5 // add jitter to the timeout6 const max = 1000 * seconds * 0.757 const min = 1000 * seconds * 1.258 const timeoutWithJitter = Math.floor(Math.random() * (max - min + 1) + min)9 // set the timeout10 const timeout = setTimeout(callback, timeoutWithJitter)11 // store timeout, to be able to cancel it later12 commit('setTimeout', timeout)13 },14 timeoutWithJitter (timeout, callback, seconds) {15 clearTimeout(timeout)16 // add jitter to the timeout17 const max = 1000 * seconds * 0.7518 const min = 1000 * seconds * 1.2519 const timeoutWithJitter = Math.floor(Math.random() * (max - min + 1) + min)20 // set the timeout21 timeout = setTimeout(callback, timeoutWithJitter)22 },23 timeout (timeout, callback, seconds) {24 clearTimeout(timeout)25 // set the timeout26 timeout = setTimeout(callback, 1000 * seconds)27 }...
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var timeout = require('argosy-timeout')4var service = argosy()5service.pipe(timeout(1000)).pipe(service)6service.accept({role: 'math', cmd: 'sum'}, function (msg, cb) {7 cb(null, {answer: msg.left + msg.right})8})9service.act({role: 'math', cmd: 'sum', left: 1, right: 2}, function (err, result) {10 console.log(err, result)11})12service.act({role: 'math', cmd: 'sum', left: 1, right: 2, timeout: 500}, function (err, result) {13 console.log(err, result)14})15service.act({role: 'math', cmd: 'sum', left: 1, right: 2, timeout: 1500}, function (err, result) {16 console.log(err, result)17})18var argosy = require('argosy')19var argosyPattern = require('argosy-pattern')20var timeout = require('argosy-timeout')21var service = argosy()22service.pipe(timeout(1000)).pipe(service)23service.accept({role: 'math', cmd: 'sum'}, function (msg, cb) {24 cb(null, {answer: msg.left + msg.right})25})26service.act({role: 'math', cmd: 'sum', left: 1, right: 2}, function (err, result) {27 console.log(err, result)28})29service.act({role: 'math', cmd: 'sum', left: 1, right: 2, timeout: 500}, function (err, result) {30 console.log(err, result)31})32service.act({role: 'math', cmd: 'sum', left: 1, right: 2, timeout: 1500}, function (err, result) {33 console.log(err, result)34})
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyTimeout = require('argosy-timeout')4var argosyService = argosy()5var argosyServiceTimeout = argosyTimeout(argosyService, 1000)6var pattern = argosyPattern({7})8argosyServiceTimeout.accept(pattern, function (msg, respond) {9 respond(null, 'Hello ' + msg.greet)10})11argosyServiceTimeout.on('error', function (err) {12 console.log('Error: ' + err.message)13})14argosyServiceTimeout.listen(8000)
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyTimeout = require('argosy-timout')4var argosyService = require('argosy-service')5var argosyServiceRegistry = require('argosy-service-registry')6var argosyServiceRegistryBrowser = require('argosy-service-registry-browser')7var argosyServiceRegistryHttp = require('argosy-service-registry-http')8var argosyServiceRegistryWebsocket = require('argosy-service-registry-websocket')9var argosyServiceRegistryMemory = require('argosy-service-registry-memory')10var argosyServiceRegistryPeer = require('argosy-service-registry-peer')11var argosyServiceRegistryPeerBrowser = require('argosy-service-registry-peer-browser')12var argosyServiceRegistryPeerHttp = require('argosy-service-registry-peer-http')13var argosyServiceRegistryPeerWebsocket = require('argosy-service-registry-peer-websocket')14var argosyServiceRegistryPeerMemory = require('argosy-service-registry-peer-memory')15var argosyServiceRegistryPeerHttpBrowser = require('argosy-service-registry-peer-http-browser')16var argosyServiceRegistryPeerWebsocketBrowser = require('argosy-service-registry-peer-websocket-browser')17var argosyServiceRegistryPeerMemoryBrowser = require('argosy-service-registry-peer-memory-browser')18var argosyServiceRegistryPeerHttpBrowser = require('argosy-service-registry-peer-http-browser')19var argosyServiceRegistryPeerWebsocketBrowser = require('argosy-service-registry-peer-websocket-browser')20var argosyServiceRegistryPeerMemoryBrowser = require('argosy-service-registry-peer-memory-browser')21var argosyServiceRegistryPeerHttpBrowser = require('argosy-service-registry-peer-http-browser')22var argosyServiceRegistryPeerWebsocketBrowser = require('argosy-service-registry-peer-websocket-browser')23var argosyServiceRegistryPeerMemoryBrowser = require('argosy-service-registry-peer-memory-browser')24var argosyServiceRegistryPeerHttpBrowser = require('argosy-service-registry-peer-http-browser')25var argosyServiceRegistryPeerWebsocketBrowser = require('argosy-service-registry-peer-websocket-browser')
Using AI Code Generation
1var argosy = require('argosy')2var timeout = require('argosy-pattern/timeout')3var patterns = require('argosy-pattern')4var patterns = require('argosy-pattern')5var request = argosy()6request.accept({7})8request.on('ping', function (msg, respond) {9 respond(null, 'pong')10})11request.pipe(timeout(500)).pipe(request)12request({13}, function (err, response) {14 console.log(err, response)15})16var argosy = require('argosy')17var patterns = require('argosy-pattern')18var request = argosy()19request.accept({20})21request.on('ping', function (msg, respond) {22 respond(null, 'pong')23})24request({25}, function (err, response) {26 console.log(err, response)27})28var argosy = require('argosy')29var patterns = require('argosy-pattern')30var request = argosy()31request.accept({32})33request.on('ping', function (msg, respond) {34 respond(null, 'pong')35})36request({37 ping: {foo: 'bar'}38}, function (err, response) {39 console.log(err, response)40})41var argosy = require('argosy')42var patterns = require('argosy-pattern')43var request = argosy()44request.accept({45})46request.on('ping', function (msg, respond) {47 respond(null, 'pong')48})49request({50}, function (err, response) {51 console.log(err, response)52})
Using AI Code Generation
1var argosy = require('argosy')2var service = argosy()3service.pipe(argosy.acceptor({4})).pipe(service)5service.accept({6 hello: function (name, cb) {7 cb(null, 'hello ' + name)8 }9})10service.accept({11 hello: function (name, cb) {12 setTimeout(function () {13 cb(null, 'hello ' + name)14 }, 2000)15 }16})17service.on('error', function (err) {18 console.error(err)19})20service.on('hello', function (name, cb) {21 cb(null, 'hello ' + name)22})23service.act({24}, function (err, response) {25 console.log(response)26})27service.act({28}, function (err, response) {29 console.log(response)30})31var argosy = require('argosy')32var pattern = require('argosy-pattern')33var service = argosy()34service.pipe(argosy.acceptor({35})).pipe(service)36service.accept({37 hello: pattern.match('string')38}, function (name, cb) {39 cb(null, 'hello ' + name)40})41service.accept({42 hello: pattern.match('string')43}, function (name, cb) {44 setTimeout(function () {45 cb(null, 'hello ' + name)46 }, 2000)47})48service.on('error', function (err) {49 console.error(err)50})51service.on('hello', function (name, cb) {52 cb(null, 'hello ' + name)53})54service.act({55}, function (err, response) {56 console.log(response)57})58service.act({59}, function (err, response) {60 console.log(response)61})62var argosy = require('argosy')63var pattern = require('argosy-pattern')64var service = argosy()65service.pipe(argosy.acceptor({
Using AI Code Generation
1const argosy = require('argosy')2const service = argosy()3service.pipe(argosy.pattern({4})).pipe(argosy.timeout(1000)).pipe(argosy.respond((request, cb) => {5 cb(null, {6 greeting: `Hello, ${request.greet}!`7 })8}))9service.listen()10const argosy = require('argosy')11const service = argosy()12service.pipe(argosy.pattern({13})).pipe(argosy.respond((request, cb) => {14 setTimeout(() => {15 cb(null, {16 greeting: `Hello, ${request.greet}!`17 })18 }, 2000)19}))20service.listen()21const argosy = require('argosy')22const service = argosy()23service.pipe(argosy.pattern({24})).pipe(argosy.timeout(1000)).pipe(argosy.respond((request, cb) => {25 cb(null, {26 greeting: `Hello, ${request.greet}!`27 })28}))29service.listen()30const argosy = require('argosy')31const service = argosy()32service.pipe(argosy.pattern({33})).pipe(argosy.respond((request, cb) => {34 setTimeout(() => {35 cb(null, {36 greeting: `Hello, ${request.greet}!`37 })38 }, 2000)39}))40service.listen()41const argosy = require('argosy')42const service = argosy()43service.pipe(argosy.pattern({44})).pipe(argosy.timeout(1000)).pipe(argosy.respond((request, cb) => {45 cb(null, {46 greeting: `Hello, ${request.greet}!`47 })48}))49service.listen()
Using AI Code Generation
1var argosy = require('argosy')2var timeout = require('argosy-pattern/timeout')3var service = argosy()4service.use('add', timeout(2000, function (a, b) {5}))6service.listen(8000)7var argosy = require('argosy')8var timeout = require('argosy-pattern/timeout')9var service = argosy()10service.use('add', timeout(2000, function (a, b) {11}))12service.listen(8000)13var argosy = require('argosy')14var once = require('argosy-pattern/once')15var service = argosy()16service.use('add', once(function (a, b) {17}))18service.listen(8000)19var argosy = require('argosy')20var queue = require('argosy-pattern/queue')21var service = argosy()22service.use('add', queue(function (a, b, cb) {23 setTimeout(function () {24 cb(null, a + b)25 }, 1000)26}))27service.listen(8000)28var argosy = require('argosy')29var parallel = require('argosy-pattern/parallel')30var service = argosy()31service.use('add', parallel(function (a, b, cb) {32 setTimeout(function () {33 cb(null, a + b)34 }, 1000)35}))36service.listen(8000)37var argosy = require('argosy')38var serial = require('argosy-pattern/serial')
Using AI Code Generation
1var argosy = require('argosy');2var timeout = require('argosy-pattern-timeout');3var service = argosy();4service.accept({5 ping: timeout('ping', 1000)6});7service.listen(8000);8service.on('error', function (err) {9 console.log(err);10});11service.on('service ping', function (req, cb) {12 cb(null, 'pong');13});14var argosy = require('argosy');15var timeout = require('argosy-pattern-timeout');16var service = argosy();17service.accept({18 ping: timeout('ping', 1000)19});20service.on('error', function (err) {21 console.log(err);22});23service.on('service ping', function (req, cb) {24 cb(null, 'pong');25});26service.on('service ping timeout', function (req, cb) {27 cb(null, 'timeout');28});29service.connect(8000);30service.ping(function (err, res) {31 console.log(err, res);32});33var argosy = require('argosy');34var timeout = require('argosy-pattern-timeout');35var service = argosy();36service.accept({37 ping: timeout('ping', 1000)38});39service.on('error', function (err) {40 console.log(err);41});42service.on('service ping', function (req, cb) {43 cb(null, 'pong');44});45service.on('service ping timeout', function (req, cb) {46 cb(null, 'timeout');47});48service.connect(8000);49service.ping(function (er
Using AI Code Generation
1var timeout = require('argos/timeout');2var timeout = require('argos/timeout');3timeout(function() {4 console.log('timeout');5}, 1000);6var timeout = function(callback, time) {7 var timerId = setTimeout(function() {8 callback();9 }, time);10 return timerId;11};12module.exports = timeout;13var timeout = require('argos/timeout');14timeout(function() {15 console.log('timeout');16}, 1000);17var timeout = function(callback, time) {18 var timerId = setTimeout(function() {19 callback();20 }, time);21 return timerId;22};23module.exports = timeout;24var timeout = require('argos/timeout');25timeout(function() {26 console.log('timeout');27}, 1000);28var timeout = function(callback, time) {29 var timerId = setTimeout(function() {30 callback();31 }, time);32 return timerId;33};34module.exports = timeout;35var timeout = require('argos/timeout');36timeout(function() {37 console.log('timeout');38}, 1000);39var timeout = function(callback, time) {40 var timerId = setTimeout(function() {41 callback();42 }, time);43 return timerId;44};45module.exports = timeout;46var timeout = require('argos/timeout');47timeout(function() {48 console.log('timeout');49}, 1000);50var timeout = function(callback, time) {51 var timerId = setTimeout(function() {52 callback();53 }, time);54 return timerId;55};56module.exports = timeout;57var timeout = require('argos/timeout');58timeout(function() {59 console.log('timeout');60}, 1000);61var timeout = function(callback, time) {62 var timerId = setTimeout(function() {63 callback();64 }, time);65 return timerId;66};67module.exports = timeout;
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!!