Best JavaScript code snippet using istanbul
bbb.js
Source:bbb.js
...99return new Promise((resolve, reject) => {100 let timestamp=new Date().getTime();101 let userInfo ={102 url: 'https://bububao.duoshoutuan.com/user/profile',103 headers: JSON.parse(CookieVal),104}105 $.post(userInfo,async(error, response, data) =>{106 const userinfo = JSON.parse(data)107 if(response.statusCode == 200 && userinfo.code != -1){108 $.log('\nð模æ¬ç»é¸æå\n')109 notice += 'ðæ¥æ¥å¯¶å¸³è: '+userinfo.username+'\n'+'ðç¶åéå¹£: '+userinfo.jinbi+'ð° ç´'+userinfo.money+'å
ð¸\n'110 }else{111 notice += 'â ï¸ç°å¸¸åå : '+userinfo.msg+'\n'112 }113 resolve()114 })115 })116 } 117function signIn() {118return new Promise((resolve, reject) => {119 let timestamp=new Date().getTime();120 let signin ={121 url: `https://bububao.duoshoutuan.com/user/sign`,122 headers: JSON.parse(CookieVal),123}124 $.post(signin,async(error, response, data) =>{125$.log('\nðéå§ç¾å°\n')126 const sign = JSON.parse(data)127 if(sign.code == 1) {128 $.log('\nð'+sign.msg+'ç°½å°éå¹£+ '+sign.jinbi+'ð°\n')129 signInStr = sign.nonce_str130 await signDouble()131 }else{132 $.log('\nð'+sign.msg+'\n')133 }134 resolve()135 })136 })137 } 138function signDouble() {139return new Promise((resolve, reject) => {140 let timestamp=new Date().getTime();141 let signdouble ={142 url: `https://bububao.duoshoutuan.com/you/callback`,143 headers: JSON.parse(CookieVal),144 body: `nonce_str=${signInStr}&tid=2&pos=1&`,145}146 $.post(signdouble,async(error, response, data) =>{147 const signin2 = JSON.parse(data)148$.log('\nðéå§é åæ¯æ¥è§ççåµ\n')149 if(signin2.code == 1) {150 $.log('\nðç°½å°ç¿»åæå\n')151 }else{152 $.log('\nâ ï¸ç°½å°ç¿»å失ææ:'+signin2.msg+'\n')153 }154 resolve()155 })156 })157 } 158function zaoWanDkInfo() {159return new Promise((resolve, reject) => {160 let timestamp=new Date().getTime();161 let zaowandkinfo ={162 url: `https://bububao.duoshoutuan.com/mini/dk_info`,163 headers: JSON.parse(CookieVal),164}165 $.post(zaowandkinfo,async(error, response, data) =>{166 const zwdkinfo = JSON.parse(data)167 if(zwdkinfo.code == 1 && zwdkinfo.is_dk == 0) {168 nowTime = zwdkinfo.now_time169 title1 = zwdkinfo.title1170 title2 = zwdkinfo.title2171 await zaoWanDk()172 }173 resolve()174 })175 })176 } 177function zaoWanDk() {178return new Promise((resolve, reject) => {179 let timestamp=new Date().getTime();180 let zaowandk ={181 url: `https://bububao.duoshoutuan.com/user/chuansj`,182 headers: JSON.parse(CookieVal),183 body: `mini_pos=3&c_type=1&`,184}185 $.post(zaowandk,async(error, response, data) =>{186 const zwdk = JSON.parse(data)187 if(zwdk.code == 1) {188 zwdkStr = zwdk.nonce_str189 await $.wait(30000)190 await dkClick()191 }192 resolve()193 })194 })195 } 196function dkClick() {197return new Promise((resolve, reject) => {198 let timestamp=new Date().getTime();199 let dkclick ={200 url: `https://bububao.duoshoutuan.com/mini/dk_click`,201 headers: JSON.parse(CookieVal),202 body: `now_time=${nowTime}&`,203}204 $.post(dkclick,async(error, response, data) =>{205 const clickdk = JSON.parse(data)206 if(clickdk.code == 1) {207 $.log('\nð'+clickdk.msg+'+ '+clickdk.jinbi+'ð°\n')208 $.msg(`${title1}`,`${title2}`,'')209 await checkWaterNum()210 }else{211 $.log('\nâ ï¸'+clickdk.msg)212 await checkWaterNum()213 }214 resolve()215 })216 })217 } 218function guaList() {219return new Promise((resolve, reject) => {220 let timestamp=new Date().getTime();221 let gualist ={222 url: `https://bububao.duoshoutuan.com/gua/gualist?`,223 headers: JSON.parse(CookieVal),224}225 $.post(gualist,async(error, response, data) =>{226$.log('\nðéå§æ¥è©¢å®å®å¡ID\n')227 const guaid = JSON.parse(data)228 if(guaid.ka > 0){229 for (guaId of guaid.list){230 if(guaId.is_ad == 0)231 GID = guaId.id232$.log('\nðæ¥è©¢å®å®å¡IDæå,5så¾éå§æ¥è¯¢å®å¡ç¾å\n')233$.log('\nGID: '+GID+'\n')234 await $.wait(5000)235 await guaDet()236 }}else{237$.log('\nâ ï¸å®å®å¡å·²ç¨å®,è«æ天åå®å§ï¼\n')238 await checkWaterNum()239 }240 resolve()241 })242 })243 } 244function guaDet() {245return new Promise((resolve, reject) => {246 let timestamp=new Date().getTime();247 let guadet ={248 url: `https://bububao.duoshoutuan.com/gua/guadet?`,249 headers: JSON.parse(CookieVal),250 body: `gid=${GID}&`251}252 $.post(guadet,async(error, response, data) =>{253$.log('\nðéå§æ¥è©¢å®å¡ç°½å\n')254 const guasign= JSON.parse(data)255 if(response.statusCode == 200) {256$.log('\nðæ¥è©¢å®å¡ç°½åæå\n')257 SIGN = guasign.sign258 GLID = guasign.glid259$.log('\nsign: '+SIGN+'\n')260$.log('\nglid: '+GLID+'\n')261 await guaPost()262 }263 resolve()264 })265 })266 } 267function guaPost() {268return new Promise((resolve, reject) => {269 let timestamp=new Date().getTime();270 let guapost ={271 url: `https://bububao.duoshoutuan.com/gua/guapost?`,272 headers: JSON.parse(CookieVal),273 body: `sign=${SIGN}&gid=${GID}&glid=${GLID}&`274}275 $.post(guapost,async(error, response, data) =>{276$.log('\nðéå§å®å¡\n')277 const guaka= JSON.parse(data)278 if(typeof guaka.jf === 'number') {279 guaStr = guaka.nonce_str280 $.log('\nðå®å¡æå\næåæ¨å®åº'+guaka.tp+'å¼µç¸ååæ¡\néå¹£+ '+guaka.jf+'\nçå¾
45så¾éå§ç¿»åå®å¡çåµ')281 await $.wait(45000)282 await guaDouble()283 }284 resolve()285 })286 })287 } 288function guaDouble() {289return new Promise((resolve, reject) => {290 let timestamp=new Date().getTime();291 let guadouble ={292 url: `https://bububao.duoshoutuan.com/you/callback`,293 headers: JSON.parse(CookieVal),294 body: `nonce_str=${guaStr}&tid=6&pos=1&`,295}296 $.post(guadouble,async(error, response, data) =>{297 const guaka2 = JSON.parse(data)298$.log('\nðéå§é åå®å¡ç¿»åçåµ\n')299 if(guaka2.code == 1) {300 $.log('\nðå®å¡ç¿»åæå,çå¾
2så¾æ¥è©¢ä¸ä¸å¼µå®å®å¡ID\n')301 await $.wait(2000)302 //await guaList()303 }else{304 $.log('\nâ ï¸å®å¡ç¿»å失æ:'+guaka2.msg+'\n')305 }306 resolve()307 })308 })309 } 310function checkWaterNum() {311return new Promise((resolve, reject) => {312 let timestamp=new Date().getTime();313 let checkwaternum ={314 url: `https://bububao.duoshoutuan.com/mini/water_info`,315 headers: JSON.parse(CookieVal),316}317 $.post(checkwaternum,async(error, response, data) =>{318$.log('\nðéå§æ¥è©¢åæ°´æ¯æ¸\n')319 const waternum = JSON.parse(data)320 if(waternum.code == 1 && waternum.day_num < 7) {321 waterNum = waternum.day_num322 if(waternum.is_sp == 1){323 $.log('\nðåæ°´åéè¦ç廣ååï¼,1så¾éå§ç廣å\n')324 await $.wait(1000)325 await checkWaterSp()326 }else{327 $.log('\nðæ¥è©¢æå,1så¾é ååæ°´çåµ\n')328 await $.wait(1000)329 await waterClick()330 }}else{331 $.log('\nâ ï¸å水失æ: ä»æ¥åæ°´å·²ä¸é\n')332 }333 resolve()334 })335 })336 } 337function checkWaterSp() {338return new Promise((resolve, reject) => {339 let timestamp=new Date().getTime();340 let checksp ={341 url: `https://bububao.duoshoutuan.com/user/chuansj`,342 headers: JSON.parse(CookieVal),343 body: `mini_pos=2&c_type=1&`,344}345 $.post(checksp,async(error, response, data) =>{346 const sp = JSON.parse(data)347 if(sp.code == 1) {348 waterSpStr = sp.nonce_str349 await WaterSp()350 }351 resolve()352 })353 })354 } 355function WaterSp() {356return new Promise((resolve, reject) => {357 let timestamp=new Date().getTime();358 let watersp ={359 url: `https://bububao.duoshoutuan.com/mini/water_sp`,360 headers: JSON.parse(CookieVal),361 body: `day_num=${waterNum}&`,362}363 $.post(watersp,async(error, response, data) =>{364 const spwater = JSON.parse(data)365 if(spwater.code == 1) {366 $.log('\nðæ£å¨è§çå水廣å, 30å¾é ååæ°´çåµ\n')367 await $.wait(30000)368 await waterClick()369 }370 resolve()371 })372 })373 } 374function waterClick() {375return new Promise((resolve, reject) => {376 let timestamp=new Date().getTime();377 let waterclick ={378 url: `https://bububao.duoshoutuan.com/mini/water_click`,379 headers: JSON.parse(CookieVal),380 body: `day_num=0${waterNum}&`,381}382 $.post(waterclick,async(error, response, data) =>{383 const clickwater = JSON.parse(data)384$.log('\nðéå§é ååæ°´çåµ\n')385 if(clickwater.code == 1) {386 $.log('\nð'+clickwater.msg+'åæ°´éå¹£+ '+clickwater.jinbi+'ð°\n')387 }else{388 $.log('\nâ ï¸å水失æ:'+clickwater.msg+'\n')389 }390 resolve()391 })392 })393 } 394function sleepStatus() {395return new Promise((resolve, reject) => {396 let timestamp=new Date().getTime();397 let sleepstatus ={398 url: `https://bububao.duoshoutuan.com/mini/sleep_info`,399 headers: JSON.parse(CookieVal),400}401 $.post(sleepstatus,async(error, response, data) =>{402$.log('\nðéå§æ¥è©¢ç¡è¦ºçæ
\n')403 const slpstatus = JSON.parse(data)404 if(slpstatus.code == 1) {405 if(slpstatus.is_lq == 1 && now.getHours() >= 8 && now.getHours() <= 18) {406 sleepStr = slpstatus.nonce_str407 sleepId = slpstatus.taskid408 }else{409$.log('ð大ç½å¤©çå°±ä¸è¦ç¡è¦ºå¦ï¼')410 }411 if(slpstatus.is_sleep == 0 && slpstatus.is_lq == 1 && now.getHours() >= 20) {412$.log('ðé½å¹¾é»äºï¼éä¸ç¡ï¼5så¾éå§ç¡è¦ºï¼')413 await $.wait(5000)414 await sleepStart()415 }else if((slpstatus.is_sleep == 1 || slpstatus.is_sleep == 0)&& slpstatus.is_lq == 0 && now.getHours() >= 8 && now.getHours() <= 12){416$.log('ðé½å¹¾é»äºï¼éä¸èµ·ï¼5så¾æºåèµ·åºï¼')417 await $.wait(5000)418 await sleepEnd()419 }else if(slpstatus.is_sleep == 0 && slpstatus.is_lq == 1 && now.getHours() >= 8 && now.getHours() <= 12){420 await sleepDone()421 }else if(slpstatus.is_sleep == 1 && slpstatus.is_lq == 1 && now.getHours() >= 22){422 $.log('â ï¸ç¡è¦ºçæåä¸è¦ç©ææ©ï¼ï¼ï¼')423 }else if(slpstatus.is_sleep == 0 &&424now.getHours() >= 18){425 $.log('ðé麼æ©å°±æºåç¡è¦ºäºåï¼æ¯èº«é«ä¸èæåï¼è¦ä¿é身é«åï¼')426 }}427 resolve()428 })429 })430 } 431function sleepStart() {432return new Promise((resolve, reject) => {433 let timestamp=new Date().getTime();434 let sleepstart ={435 url: `https://bububao.duoshoutuan.com/mini/sleep_start`,436 headers: JSON.parse(CookieVal),437}438 $.post(sleepstart,async(error, response, data) =>{439 const startsleep = JSON.parse(data)440$.log('\nðéå§ç¡è¦º\n')441 if(startsleep.code == 1) {442 $.log('\nðç¡è¦ºæåï¼æ©ç¡æ©èµ·èº«é«å¥½ï¼\n')443 }else{444 $.log('\nâ ï¸ç¡è¦ºå¤±ææ:'+startsleep.msg+'\n')445 }446 resolve()447 })448 })449 } 450function sleepEnd() {451return new Promise((resolve, reject) => {452 let timestamp=new Date().getTime();453 let sleepend ={454 url: `https://bububao.duoshoutuan.com/mini/sleep_end`,455 headers: JSON.parse(CookieVal),456}457 $.post(sleepend,async(error, response, data) =>{458 const endsleep = JSON.parse(data)459$.log('\nðéå§èµ·åº\n')460 if(endsleep.code == 1) {461 $.log('\nðèµ·åºäºï¼å¥ç¡äºï¼\n')462 await sleepStatus()463 }else{464 $.log('\nâ ï¸èµ·åºå¤±æ:'+endsleep.msg+'\n')465 }466 resolve()467 })468 })469 } 470function sleepDone() {471return new Promise((resolve, reject) => {472 let timestamp=new Date().getTime();473 let sleepdone ={474 url: `https://bububao.duoshoutuan.com/mini/sleep_done`,475 headers: JSON.parse(CookieVal),476 body: `taskid=${sleepId}&nonce_str=${sleepStr}&`477}478 $.post(sleepdone,async(error, response, data) =>{479 const donesleep = JSON.parse(data)480$.log('\nðéå§é åç¡è¦ºéå¹£\n')481 if(donesleep.code == 1) {482 $.log('\nð'+donesleep.msg+'éå¹£+ '+donesleep.jinbi+'ð°\n')483 }else{484 $.log('\nâ ï¸é åç¡è¦ºé幣失ææ:'+donesleep.msg+'\n')485 }486 resolve()487 })488 })489 } 490function clickTaskStatus() {491return new Promise((resolve, reject) => {492 let timestamp=new Date().getTime();493 let clicktaskstatus ={494 url: `https://bububao.duoshoutuan.com/user/renwu`,495 headers: JSON.parse(CookieVal),496 body: `idfa=${JSON.parse(CookieVal)['idfa']}&`,497}498 $.post(clicktaskstatus,async(error, response, data) =>{499 const clicktask = JSON.parse(data)500 if(clicktask.first.admobile_st != 2) {501$.log('\nðéå§æ¥è©¢æ¯æ¥é»æä»»åçæ
\n')502 await checkDailyClickAdId()503 }else{504 $.log('\nâ ï¸æ¯æ¥é»æ廣åä»»åå·²ä¸é\n')505 }506 resolve()507 })508 })509 } 510function watchTaskStatus() {511return new Promise((resolve, reject) => {512 let timestamp=new Date().getTime();513 let watchtaskstatus ={514 url: `https://bububao.duoshoutuan.com/user/renwu`,515 headers: JSON.parse(CookieVal),516 body: `idfa=${JSON.parse(CookieVal)['idfa']}&`,517}518 $.post(watchtaskstatus,async(error, response, data) =>{519 const watchtask = JSON.parse(data)520$.log('\nðéå§æ¥è©¢æ¯æ¥è§ç廣åä»»åçæ
\n')521 if(watchtask.v_st != 2) {522$.log('\nðæ¯æ¥è§ç廣åä»»åçæ
æ¥è©¢æå,1så¾æ¥è©¢æ¯æ¥è§ç廣åID\n')523 await $.wait(1000)524 await checkDailyWatchAdId()525 }else{526 $.log('\nâ ï¸æ¯æ¥ç廣åä»»åå·²ä¸é\n')527 await checkWaterNum()528 }529 resolve()530 })531 })532 } 533function checkDailyWatchAdId() {534return new Promise((resolve, reject) => {535 let timestamp=new Date().getTime();536 let checkdailywatchadid ={537 url: `https://bububao.duoshoutuan.com/user/chuansj`,538 headers: JSON.parse(CookieVal),539 body: `mini_pos=0&c_type=1&`,540}541 $.post(checkdailywatchadid,async(error, response, data) =>{542$.log('\nðéå§æ¥è©¢æ¯æ¥è§ç廣åID\n')543 const dailywatchid = JSON.parse(data)544 if(dailywatchid.code == 1) {545 dailyWatchStr = dailywatchid.nonce_str546 // $.log('\n'+dailyWatchStr+'\n')547 $.log('\nðæ¥è©¢æå,30så¾é åçåµ\n')548 await $.wait(30000)549 await DailyWatchAd()550 }551 resolve()552 })553 })554 } 555function DailyWatchAd() {556return new Promise((resolve, reject) => {557 let timestamp=new Date().getTime();558 let dailywatchad ={559 url: `https://bububao.duoshoutuan.com/you/callback`,560 headers: JSON.parse(CookieVal),561 body: `nonce_str=${dailyWatchStr}&tid=9&pos=1&`,562}563 $.post(dailywatchad,async(error, response, data) =>{564 const dailywatch = JSON.parse(data)565$.log('\nðéå§é åæ¯æ¥è§ççåµ\n')566 if(dailywatch.code == 1) {567 $.log('\nðæ¯æ¥è§ççåµé åæå,5m(300s)å¾æ¥è©¢ä¸ä¸æ¬¡å»£å\n')568 for(let i=1;i<=60;i++){569 (function(){570 setTimeout(() => {571 $.log('\nâ±è«çå¾
'+(60-i)*5+'så¾æ¥è©¢ä¸ä¸æ¬¡å»£å\n')572 }, 5000*i);573 })()574 }575 await $.wait(300000)576 await watchTaskStatus()577 }else{578 $.log('\nâ ï¸æ¯æ¥çåµé å失æ:'+dailywatch.msg+'\n')579 }580 resolve()581 })582 })583 } 584function checkDailyClickAdId() {585return new Promise((resolve, reject) => {586 let timestamp=new Date().getTime();587 let checkdailyclickadid ={588 url: `https://bububao.duoshoutuan.com/user/admobile_show`,589 headers: JSON.parse(CookieVal),590}591 $.post(checkdailyclickadid,async(error, response, data) =>{592$.log('\nðéå§æ¥è©¢æ¯æ¥å»£åID\n')593 const dailyclickid = JSON.parse(data)594 if(dailyclickid.code == 1) {595 dailyClickAdId = dailyclickid.ad_id596 // $.log('\n'+dailyClickAdId+'\n')597 $.log('\nðæ¥è©¢æå,1så¾é åçåµ\n')598 await $.wait(1000)599 await checkDailyClickAd()600 }601 resolve()602 })603 })604 } 605function checkDailyClickAd() {606return new Promise((resolve, reject) => {607 let timestamp=new Date().getTime();608 let checkdailyclickad ={609 url: `https://bububao.duoshoutuan.com/user/admobile_click`,610 headers: JSON.parse(CookieVal),611 body: `ad_id=${dailyClickAdId}&`,612}613 $.post(checkdailyclickad,async(error, response, data) =>{614$.log('\nðéå§æ¥è©¢æ¯æ¥å»£åé»æID\n')615 const dailyclick = JSON.parse(data)616 if(dailyclick.code == 1) {617 dailyClickStr = dailyclick.nonce_str618 // $.log('\n'+dailyClickStr+'\n')619 $.log('\nðæ¥è©¢æå,5så¾è¿åé åçåµ\n')620 await $.wait(5000)621 await DailyClickAd()622 }623 resolve()624 })625 })626 } 627function DailyClickAd() {628return new Promise((resolve, reject) => {629 let timestamp=new Date().getTime();630 let dailyclickad ={631 url: `https://bububao.duoshoutuan.com/user/admobile_done`,632 headers: JSON.parse(CookieVal),633 body: `nonce_str=${dailyClickStr}&ad_id=${dailyClickAdId}&`,634}635 $.post(dailyclickad,async(error, response, data) =>{636 const dailyclick = JSON.parse(data)637$.log('\nðéå§é åæ¯æ¥é»æçåµ\n')638 if(dailyclick.code == 1) {639 $.log('\nðæ¯æ¥é»æçåµé åæå,1så¾æ¥è©¢ä¸ä¸æ¬¡å»£åID\n')640 await $.wait(1000)641 await clickTaskStatus()642 }else{643 $.log('\nâ ï¸æ¯æ¥é»æé å失æ:'+dailyclick.msg+'\n')644 }645 resolve()646 })647 })648 } 649function checkHomeJin() {650return new Promise((resolve, reject) => {651 let timestamp=new Date().getTime();652 let checkhomejin ={653 url: 'https://bububao.duoshoutuan.com/user/home',654 headers: JSON.parse(CookieVal),655}656 $.post(checkhomejin,async(error, response, data) =>{657 const checkhomejb = JSON.parse(data)658 if(checkhomejb.right_st == 0){659 await homeJin()660 }else if(checkhomejb.right_st == 1){661$.log('\nðéå§æ¥è©¢é¦é éå¹£çæ
\n')662$.log('\nðçå¾
'+(checkhomejb.right_time+5)+'sé¢åé¦é¡µéå¸')663 await $.wait(checkhomejb.right_time*1000+5000)664 await homeJin()665 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 0){666$.log('\nðéå§æ¥è©¢é¦é éèçæ
\n')667$.log('\nðçå¾
'+(checkhomejb.jindan_djs+5)+'sé¢åéèçåµ')668 await $.wait(checkhomejb.jindan_djs*1000+5000)669 await checkGoldEggId()670 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 1){671$.log('\nðéå§æ¥è©¢é¦é éèçæ
\n')672$.log('\nðçå¾
'+(checkhomejb.jindan_djs+5)+'sé¢åéèçåµ')673 await $.wait(checkhomejb.jindan_djs*1000+5000)674 await checkGoldEggId()675 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 2 && checkhomejb.hb_st == 0){676$.log('\nðéå§æ¥è©¢é¦é ç´
å
çæ
\n')677 await checkRedBagId()678 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 2 && checkhomejb.hb_st == 1){679$.log('\nðéå§æ¥è©¢é¦é ç´
å
çæ
\n')680$.log('\nðçå¾
'+(checkhomejb.hb_time+5)+'sé åé¦é ç´
å
')681time = checkhomejb.hb_time+5682 for(let i=1;i<=(time/5);i++){683 (function(){684 setTimeout(() => {685 $.log('\nâ±è«çå¾
'+((time/5-i)*5)+'så¾é åé¦é ç´
å
\n')686 }, 5000*i);687 })()688 }689 await $.wait(checkhomejb.hb_time*1000+5000)690 await checkRedBagId()691 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 2 && checkhomejb.hb_st == 2){692$.log('\nðé¦é éå¹£çæ
:'+checkhomejb.right_text+'\nðé¦é ç´
å
çæ
:'+checkhomejb.hb_text+'\nðé¦é éèçæ
:'+checkhomejb.jindan_text+'\n')693 await checkWaterNum()694 }695 resolve()696 })697 })698 } 699function homeJin() {700return new Promise((resolve, reject) => {701 let timestamp=new Date().getTime();702 let homejin ={703 url: 'https://bububao.duoshoutuan.com/user/homejin',704 headers: JSON.parse(CookieVal),705}706 $.post(homejin,async(error, response, data) =>{707 const homejb = JSON.parse(data)708 if(homejb.code == 1){709$.log('\nðéå§é åé¦é éå¹£\n')710 $.log('\nðé¦é éå¹£:'+homejb.msg+'\néå¹£+ '+homejb.jinbi+'çå¾
30så¾éå§ç¿»åéå¹£\n')711 homeJinStr = homejb.nonce_str712 //$.log('\n'+homeJinStr+'\n')713 await $.wait(30000)714 await homeJinCallBack()715 }else{716 $.log('\nâ ï¸é¦é é幣失æ:'+homejb.msg+'\n')717 }718 resolve()719 })720 })721 } 722function homeJinCallBack() {723return new Promise((resolve, reject) => {724 let timestamp=new Date().getTime();725 let homejincallback ={726 url: `https://bububao.duoshoutuan.com/you/callback`,727 headers: JSON.parse(CookieVal),728 body: `nonce_str=${homeJinStr}&tid=21&pos=1&`,729}730 $.post(homejincallback,async(error, response, data) =>{731 const hmjcallback = JSON.parse(data)732$.log('\nðéå§ç¿»åé¦é éå¹£\n')733 if(hmjcallback.code == 1) {734 $.log('\nðé¦é é幣翻åæå\n')735 await checkHomeJin()736 }else{737 $.log('\nðé¦é é幣翻å失æ'+hmjcallback.msg+'\n')738 }739 resolve()740 })741 })742 } 743function checkRedBagId() {744return new Promise((resolve, reject) => {745 let timestamp=new Date().getTime();746 let checkredbagid ={747 url: `https://bububao.duoshoutuan.com/user/chuansj`,748 headers: JSON.parse(CookieVal),749 body: `mini_pos=0&c_type=2&`,750}751 $.post(checkredbagid,async(error, response, data) =>{752$.log('\nðéå§æ¥è©¢é¦é ç´
å
ID\n')753 const code = JSON.parse(data)754 if(code.code == 1) {755 redBagStr = code.nonce_str756$.log('\nðæ¥è©¢é¦é ç´
å
IDæå,çå¾
30så¾é åé¦é ç´
å
\n')757 await $.wait(30000)758 await redBagCallback()759 }760 resolve()761 })762 })763 } 764function redBagCallback() {765return new Promise((resolve, reject) => {766 let timestamp=new Date().getTime();767 let redbagcallback ={768 url: `https://bububao.duoshoutuan.com/you/callback`,769 headers: JSON.parse(CookieVal),770 body: `nonce_str=${redBagStr}&tid=17&pos=1&`,771}772 $.post(redbagcallback,async(error, response, data) =>{773 const redbag = JSON.parse(data)774$.log('\nðéå§é åé¦é ç´
å
\n')775 if(redbag.code == 1) {776 $.log('\nðé¦é ç´
å
é åæå\n')777 await checkHomeJin()778 }else{779 $.log('\nâ ï¸é¦é ç´
å
é å失æ:'+redbag.msg+'\n')780 await checkHomeJin()781 }782 resolve()783 })784 })785 } 786function checkGoldEggId() {787return new Promise((resolve, reject) => {788 let timestamp=new Date().getTime();789 let checkgoldeggid ={790 url: `https://bububao.duoshoutuan.com/user/jindan_click`,791 headers: JSON.parse(CookieVal),792}793 $.post(checkgoldeggid,async(error, response, data) =>{794 const goldeggid = JSON.parse(data)795 if(goldeggid.code == 1) {796$.log('\nðéèID data'+data)797$.log('\nðéå§æ¥è©¢é¦é éèID\n')798 goldEggStr = goldeggid.nonce_str799 $.log('\n'+goldEggStr+'\n')800 goldEggId = goldeggid.taskid801 $.log('\n'+goldEggId+'\n')802 await goldEggDone()803 }else{804 $.log('\nâ ï¸é¦é éè失æ:'+goldeggid.msg+'\n')805 await checkHomeJin()806 }807 resolve()808 })809 })810 } 811function goldEggDone() {812return new Promise((resolve, reject) => {813 let timestamp= Date.parse(new Date())/1000;814 let goldeggdone ={815 url: `https://bububao.duoshoutuan.com/user/jindan_done`,816 headers: JSON.parse(CookieVal),817 body: `taskid=${goldEggId}&clicktime=${timestamp}&donetime=${timestamp}+1000&nonce_str=${goldEggStr}&`818}819 $.post(goldeggdone,async(error, response, data) =>{820 const goldegg2 = JSON.parse(data)821 if(goldegg2.code == 1) {822$.log('\nðéå§é åé¦é éèçåµ\n')823 $.log('\nðé¦é éè:'+goldegg2.msg+'\néå¹£+ '+goldegg2.jinbi+'\n')824 await goldEggCallback()825 }else{826 $.log('\nâ ï¸é¦é éè失æ:'+goldegg2.msg+'\n')827 await checkHomeJin()828 }829 resolve()830 })831 })832 } 833function goldEggCallback() {834return new Promise((resolve, reject) => {835 let timestamp=new Date().getTime();836 let goldeggcallback ={837 url: `https://bububao.duoshoutuan.com/you/callback`,838 headers: JSON.parse(CookieVal),839 body: `nonce_str=${goldEggStr}&tid=5&pos=1&`,840}841 $.post(goldeggcallback,async(error, response, data) =>{842 const goldeggback = JSON.parse(data)843$.log('\nðéå§ç¿»åé¦é éè\n')844 if(goldeggback.code == 1) {845 $.log('\nðéèç¿»åæå\n')846 await checkHomeJin()847 }else{848 $.log('\nâ ï¸éèç¿»å失æ:'+goldeggback.msg+'\n')849 await checkHomeJin()850 }851 resolve()852 })853 })854 } 855function helpStatus() {856return new Promise((resolve, reject) => {857 let timestamp=new Date().getTime();858 let helpstatus ={859 url: `https://bububao.duoshoutuan.com/user/help_index`,860 headers: JSON.parse(CookieVal),861}862 $.post(helpstatus,async(error, response, data) =>{863 const help = JSON.parse(data)864$.log('\nðéå§æ¥è©¢å©åè¦é »çæ
\n')865 if(help.status == 0) {866$.log('\nðæ¥è©¢å©åè¦é »çæ
æå, 1så¾ç²åå©åè¦é »ID\n')867 await checkCode()868 }else{869$.log('\nðä»æ¥å©åå·²ä¸é,è«æ天å試!\n')870 }871 resolve()872 })873 })874 } 875function checkCode() {876return new Promise((resolve, reject) => {877 let timestamp=new Date().getTime();878 let checkcode ={879 url: `https://bububao.duoshoutuan.com/user/chuansj`,880 headers: JSON.parse(CookieVal),881 body: `mini_pos=5&c_type=1&`,882}883 $.post(checkcode,async(error, response, data) =>{884 const code = JSON.parse(data)885$.log('\nðéå§æ¥è©¢å©åè¦é »ID\n')886 if(code.code == 1) {887 nonce_str = code.nonce_str888$.log('\nðæ¥è©¢å©åè¦é »IDæå, éå§è§çå©åè¦é »\n')889 await helpClick()890 }891 resolve()892 })893 })894 } 895function helpClick() {896return new Promise((resolve, reject) => {897 let timestamp=new Date().getTime();898 let helpclick ={899 url: `https://bububao.duoshoutuan.com/user/help_click`,900 headers: JSON.parse(CookieVal),901 body: `nonce_str=${nonce_str}`,902}903 $.post(helpclick,async(error, response, data) =>{904 const help = JSON.parse(data)905 if(help.code == 1) {906$.log('\nðéå§è§çå©åè¦é », 60så¾é åå©åè¦é »çåµ\n')907 await $.wait(60000)908 $.log('\nðè§çå©åè¦é »æå, 1så¾é åéå¹£+ '+help.jinbi+'\n')909 await callBack()910 }else{911 $.log('\nâ ï¸è§çå©åè¦é »å¤±æ: '+help.msg+'\n')912 }913 resolve()914 })915 })916 } 917function callBack() {918return new Promise((resolve, reject) => {919 let timestamp=new Date().getTime();920 let callback ={921 url: `https://bububao.duoshoutuan.com/you/callback`,922 headers: JSON.parse(CookieVal),923 body: `nonce_str=${nonce_str}&tid=22&pos=1&`,924}925 $.post(callback,async(error, response, data) =>{926 const back = JSON.parse(data)927$.log('\nðéå§é åå©åè¦é »çåµ\n')928 if(back.code == 1) {929 $.log('\nðé åå©åè¦é »çåµæå,1så¾æ¥è©¢ä¸ä¸æ¬¡å©åè¦é »çæ
\n')930 await $.wait(1000)931 await helpStatus()932 }else{933 $.log('\nâ ï¸å©åè¦é »çåµå¤±æ:'+back.msg+'\n')934 }935 resolve()936 })937 })938 } 939function getNewsId() {940return new Promise((resolve, reject) => {941 let timestamp=new Date().getTime();942 let getnewsid ={943 url: 'https://bububao.duoshoutuan.com/user/news',944 headers: JSON.parse(CookieVal),945 body: `type_class=1&`946}947 $.post(getnewsid,async(error, response, data) =>{948 const newsid = JSON.parse(data)949 if(newsid.code == 1){950 if(newsid.is_first == 1 && newsid.is_max == 0){951 $.log('\nðéå§æ¥è©¢æ°èID\n')952 newsStr = newsid.nonce_str953 $.log('\nðæ°èIDæ¥è©¢æå,15så¾é åé±è®çåµ\n')954 await $.wait(15000)955 await autoRead()956 }else{957 $.log('\nâ ï¸é±è®å¤±æ: ä»æ¥é±è®å·²ä¸é\n')958 await checkLuckNum()959 }}else{960 $.log('\nâ ï¸æ¥è©¢æ°èID失æ:'+newsid.msg+'\n')961 }962 resolve()963 })964 })965 } 966function autoRead() {967return new Promise((resolve, reject) => {968 let timestamp=new Date().getTime();969 let autoread ={970 url: 'https://bububao.duoshoutuan.com/user/donenews',971 headers: JSON.parse(CookieVal),972 body: `nonce_str=${newsStr}& `,973}974 $.post(autoread,async(error, response, data) =>{975 const read = JSON.parse(data)976 if(read.code == 1) {977 $.log('\nðé±è®æå,éå¹£+ '+read.jinbi+'ð°,éå§æ¥è©¢ä¸ä¸ç¯æ°èID\n')978 await getNewsId()979 }else{980 $.log('\nâ ï¸é±è®å¤±æ:'+data+'\n')981 }982 resolve()983 })984 })985 } 986function checkLuckNum() {987return new Promise((resolve, reject) => {988 let timestamp=new Date().getTime();989 let lucknum ={990 url: `https://bububao.duoshoutuan.com/user/lucky`,991 headers: JSON.parse(CookieVal),992}993 $.post(lucknum,async(error, response, data) =>{994 const num = JSON.parse(data)995$.log('\nðéå§æ¥è©¢æ½ç次æ¸\n')996 if(num.lucky_num != 0) {997 $.log('\nðå©é¤æ½ç次æ¸:'+num.lucky_num+'1så¾éå§æ½ç\n')998 await $.wait(1000)999 await luckyClick()1000 }else if(num.lucky_num == 0) {1001 $.log('\nâ ï¸ä»æ¥æ½ç次æ¸å·²ç¨å®,1så¾æ¥è©¢å¯¶ç®±çæ
\n')1002 await $.wait(1000)1003 for (box of num.lucky_box){1004 //$.log(box)1005 if (box != 2)1006 await luckyBox()1007 if (box == 2)1008 $.log('\nâ ï¸å¯¶ç®±å·²éå\n')1009 }1010 }1011 resolve()1012 })1013 })1014 } 1015function luckyClick() {1016return new Promise((resolve, reject) => {1017 let timestamp=new Date().getTime();1018 let luckclick ={1019 url: `https://bububao.duoshoutuan.com/user/lucky_click`,1020 headers: JSON.parse(CookieVal),1021}1022 $.post(luckclick,async(error, response, data) =>{1023 const lucky = JSON.parse(data)1024$.log('\nðéå§æ½ç\n')1025 if(lucky.code == 1) {1026 $.log('\nðæ½ç:'+lucky.msg+'\néå¹£+ '+lucky.jinbi+'\n')1027 luckyStr = lucky.nonce_str1028 //$.log('\n'+luckyStr+'\n')1029 if(lucky.jinbi != 0) {1030 await $.wait(5000)1031 await luckyCallBack()1032 }else{1033 await luckyClick()1034 }1035 }1036 resolve()1037 })1038 })1039 } 1040function luckyCallBack() {1041return new Promise((resolve, reject) => {1042 let timestamp=new Date().getTime();1043 let luckycallback ={1044 url: `https://bububao.duoshoutuan.com/you/callback`,1045 headers: JSON.parse(CookieVal),1046 body: `nonce_str=${luckyStr}&tid=16&pos=1&`,1047}1048 $.post(luckycallback,async(error, response, data) =>{1049 const callback = JSON.parse(data)1050$.log('\nðéå§ç¿»åæ½ç\n')1051 if(callback.code == 1) {1052 $.log('\nðæ½çç¿»åæå\n')1053 await $.wait(5000)1054 await luckyClick()1055 }else{1056 $.log('\nâ ï¸æ½çç¿»å失æ:'+callback.msg+'\n')1057 }1058 resolve()1059 })1060 })1061 } 1062function luckyBox() {1063return new Promise((resolve, reject) => {1064 let timestamp=new Date().getTime();1065 let luckybox ={1066 url: `https://bububao.duoshoutuan.com/user/lucky_box`,1067 headers: JSON.parse(CookieVal),1068 body: `box=${getBoxId()}&`,1069}1070//$.log('\nlockyboxBODY:'+luckybox.body+'\n')1071 $.post(luckybox,async(error, response, data) =>{1072 const boxlucky = JSON.parse(data)1073$.log('\nðéå§æé寶箱\n')1074 if(boxlucky.code == 1) {1075 $.log('ð寶箱: '+boxlucky.msg+'\néå¹£+ '+boxlucky.jinbi+'\n')1076 luckyBoxStr = boxlucky.nonce_str1077 $.log('\nð寶箱翻åID'+luckyBoxStr+'\n')1078 await $.wait(5000)1079 await luckyBoxCallBack()1080 }else{1081 $.log('\nâ ï¸å¯¶ç®±å¤±æ:'+boxlucky.msg+'\n')1082 }1083 resolve()1084 })1085 })1086 } 1087function luckyBoxCallBack() {1088return new Promise((resolve, reject) => {1089 let timestamp=new Date().getTime();1090 let luckyboxcallback ={1091 url: `https://bububao.duoshoutuan.com/you/callback`,1092 headers: JSON.parse(CookieVal),1093 body: `nonce_str=${luckyBoxStr}&tid=16&pos=1&`,1094}1095 $.post(luckyboxcallback,async(error, response, data) =>{1096 const boxcallback = JSON.parse(data)1097$.log('\nðéå§ç¿»å寶箱\n')1098 if(boxcallback.code == 1) {1099 $.log('\nð寶箱翻åæå\n')1100 await $.wait(1000)1101 }else{1102 $.log('\nâ ï¸å¯¶ç®±ç¿»å失æ'+boxcallback.msg+'\n')1103 }1104 resolve()1105 })1106 })1107 } 1108function getQuestionId() {1109return new Promise((resolve, reject) => {1110 let timestamp=new Date().getTime();1111 let getquestionid ={1112 url: `https://bububao.duoshoutuan.com/mini/cy_info`,1113 headers: JSON.parse(CookieVal),1114}1115 $.post(getquestionid,async(error, response, data) =>{1116 const question = JSON.parse(data)1117 if(question.code == 1 && question.day_num != 0) {1118$.log('\nðéå§æ¥è©¢çé¡ID\n')1119 questionSite = question.site1120 $.log('\nðçé¡ID1â£ï¸: '+questionSite+'\n')1121 questionId = question.cy_id1122 $.log('\nðçé¡ID2â£ï¸: '+questionId+'\n')1123 spId = question.day_num1124 $.log('\nðçé¡è¦é »: '+spId+'\n')1125 if(question.is_sp == 1) {1126 await $.wait(5000)1127 await checkSp()1128 }else{1129 await answerQue()1130 }}else{1131 $.log('\nâ ï¸æ¥è©¢çé¡IDæå,çé¡å¤±æ: ä»æ¥çé¡å·²ä¸é\n')1132 }1133 resolve()1134 })1135 })1136 } 1137function checkSp() {1138return new Promise((resolve, reject) => {1139 let timestamp=new Date().getTime();1140 let checksp ={1141 url: `https://bububao.duoshoutuan.com/user/chuansj`,1142 headers: JSON.parse(CookieVal),1143 body: `mini_pos=1&c_type=1&`,1144}1145 $.post(checksp,async(error, response, data) =>{1146 const sp = JSON.parse(data)1147 if(sp.code == 1) {1148 spStr = sp.nonce_str1149 //$.log('\n'+spStr+'\n')1150 await $.wait(5000)1151 await cySp()1152 }1153 resolve()1154 })1155 })1156 } 1157function cySp() {1158return new Promise((resolve, reject) => {1159 let timestamp=new Date().getTime();1160 let cysp ={1161 url: `https://bububao.duoshoutuan.com/mini/cy_sp`,1162 headers: JSON.parse(CookieVal),1163 body: `day_num=${spId}&`,1164}1165 $.post(cysp,async(error, response, data) =>{1166 const sp = JSON.parse(data)1167 if(sp.code == 1) {1168 // $.log('\n'+sp.msg+'\n')1169 //await $.wait(5000)1170 await answerQue()1171 }1172 resolve()1173 })1174 })1175 } 1176function answerQue() {1177return new Promise((resolve, reject) => {1178 let timestamp=new Date().getTime();1179 let answerque ={1180 url: `https://bububao.duoshoutuan.com/mini/cy_click`,1181 headers: JSON.parse(CookieVal),1182 body: `cy_id=${questionId}&site=${questionSite}&`,1183}1184//$.log('\nanswerqueBODY:'+answerque.body+'\n')1185 $.post(answerque,async(error, response, data) =>{1186 const answer = JSON.parse(data)1187$.log('\nðéå§çé¡\n')1188 if(answer.code == 1) {1189 $.log('\nðçé¡: '+answer.msg+'\néå¹£+ '+answer.jinbi+'\n')1190 answerStr = answer.nonce_str1191 $.log('\nðçé¡ç¿»åID:'+answerStr+'\n')1192 await $.wait(5000)1193 await answerQueCallBack()1194 }else{1195 $.log('\nâ ï¸çé¡å¤±æ: '+answer.msg+'\n')1196 }1197 resolve()1198 })1199 })1200 } 1201function answerQueCallBack() {1202return new Promise((resolve, reject) => {1203 let timestamp=new Date().getTime();1204 let answerquecallback ={1205 url: `https://bububao.duoshoutuan.com/you/callback`,1206 headers: JSON.parse(CookieVal),1207 body: `nonce_str=${answerStr}&tid=18&pos=1&`,1208}1209//$.log('\nanswerQueCallBackBODY:'+answerquecallback.body+'\n')1210 $.post(answerquecallback,async(error, response, data) =>{1211 const answerback = JSON.parse(data)1212$.log('\nðéå§ç¿»åçé¡éå¹£\n')1213 if(answerback.code == 1) {1214 $.log('\nðçé¡é幣翻åæå\n')1215 await $.wait(5000)1216 await getQuestionId()1217 }else{1218 $.log('\nâ ï¸çé¡é幣翻å失æ:'+answerback.msg+'\n')1219 }1220 resolve()1221 })1222 })1223 } 1224function checkH5Id() {1225return new Promise((resolve, reject) => {1226 let timestamp=new Date().getTime();1227 let checkh5id ={1228 url: `https://bububao.duoshoutuan.com/user/h5_list?`,1229 headers: JSON.parse(CookieVal),1230 body: `page=1&page_limit=50&`,1231}1232 $.post(checkh5id,async(error, response, data) =>{1233 const checkh5 = JSON.parse(data)1234 if(response.statusCode == 200){1235 for(ID of checkh5){1236 H5ID = ID.mini_id1237 $.log('\n'+H5ID+'\n')1238 await doTaskH5()1239 }1240 }1241 resolve()1242 })1243 })1244 } 1245function doTaskH5() {1246return new Promise((resolve, reject) => {1247 let timestamp=new Date().getTime();1248 let dotaskh5 ={1249 url: `https://bububao.duoshoutuan.com/user/h5_news?`,1250 headers: JSON.parse(CookieVal),1251 body: `mini_id=${H5ID}&`,1252}1253 $.post(dotaskh5,async(error, response, data) =>{1254 $.post(dotaskh5,async(error, response, data) =>{1255 const doh5task = JSON.parse(data)1256$.log('\ndoTaskH5:'+data+'\n')1257 if(response.body.indexOf('nonce_str') != -1) {1258 H5Str = doh5task.nonce_str1259 $.log('\n'+H5Str+'\n')1260 H5TaskID = doh5task.taskid1261 $.log('\n'+H5TaskID+'\n')1262 //await $.wait(30000)1263 await upLoadTime2()1264 }else{1265 $.log('\n'+data+'\n')1266 }1267 resolve()1268 })1269 })})1270 } 1271function upLoadTime() {1272return new Promise((resolve, reject) => {1273 let timestamp=new Date().getTime();1274 let uploadtime ={1275 url: `https://wapinformation.dfxwdc.com/wapreport/screen_show?encodedMsg=cWlkMTAyNjcJMTYxMDkxODY0MzAyMjkwNTYJbmV3cwllYXN0ZGF5X3dhcG5ld3MJanVuc2hpCWRmdHQtNzcxMjNkYWI3MC04YWFmCXRvdXRpYW8JaHR0cHM6Ly90b3V0aWFvLmVhc3RkYXkuY29tLwlqdW5zaGkJMQkxCTAJLy9taW5pLmVhc3RkYXkuY29tL21vYmlsZS8yMTAxMTYxMTU0MTE5NTU1NTE3NzcuaHRtbAl0b3V0aWFvCWp1bnNoaQ%3D%3D&_=1610918646639&jsonpcallback=Zepto${timestamp}`,1276 headers: {"Accept": "*/*","Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-cn","Connection": "keep-alive","Host": "wapunionstatis.dfxwdc.com","Referer": "https://toutiao.eastday.com/?qid=qid10267","User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",},1277 timeout: 30000,1278}1279 $.get(uploadtime,async(error, response, data) =>{1280$.log('\nupLoadTime:'+timestamp+'\n'+data+'\n')1281 await $.wait(30000)1282 await h5Done()1283 resolve()1284 })1285 })1286 } 1287function upLoadTime2() {1288return new Promise((resolve, reject) => {1289 let timestamp=new Date().getTime();1290 let uploadtime ={1291 url: `https://api.clotfun.online/tiger/getConfig/a0d2cb8e06bd53b0530f8786624999db?hdggHtmlId=675`,1292 headers: {"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",},1293 timeout: 30000,1294}1295 $.get(uploadtime,async(error, response, data) =>{1296$.log('\nupLoadTime2:'+data+'\n')1297 await $.wait(30000)1298 await h5Done()1299 resolve()1300 })1301 })1302 } 1303function h5Done() {1304return new Promise((resolve, reject) => {1305 let timestamp=new Date().getTime();1306 let h5done ={1307 url: `https://bububao.duoshoutuan.com/user/h5_newsdone`,1308 headers: JSON.parse(CookieVal),1309 body: `taskid=${H5TaskID}&nonce_str=${H5Str}&`,1310 timeout: 30000,1311}1312 $.post(h5done,async(error, response, data) =>{1313 const doneh5 = JSON.parse(data)1314 if(doneh5.code == 1) {1315 $.log('\nçç賺æå, éå¹£+ '+ $.log('\n'+doneh5.jinbi+'\n')+'\n')1316 }else{1317 $.log('\n'+doneh5.msg+'\n')1318 }1319 resolve()1320 })1321 })1322 } ...
json-parse-coverage.js
Source:json-parse-coverage.js
...31 calledFunctions: 0,32 path: "build/json-parse/json-parse.js",33 code: []34};35_yuitest_coverage["build/json-parse/json-parse.js"].code=["YUI.add('json-parse', function (Y, NAME) {","","/**"," * <p>The JSON module adds support for serializing JavaScript objects into"," * JSON strings and parsing JavaScript objects from strings in JSON format.</p>"," *"," * <p>The JSON namespace is added to your YUI instance including static methods"," * Y.JSON.parse(..) and Y.JSON.stringify(..).</p>"," *"," * <p>The functionality and method signatures follow the ECMAScript 5"," * specification. In browsers with native JSON support, the native"," * implementation is used.</p>"," *"," * <p>The <code>json</code> module is a rollup of <code>json-parse</code> and"," * <code>json-stringify</code>.</p>"," *"," * <p>As their names suggest, <code>json-parse</code> adds support for parsing"," * JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing"," * JavaScript data into JSON strings (Y.JSON.stringify). You may choose to"," * include either of the submodules individually if you don't need the"," * complementary functionality, or include the rollup for both.</p>"," *"," * @module json"," * @main json"," * @class JSON"," * @static"," */","","/**"," * Provides Y.JSON.parse method to accept JSON strings and return native"," * JavaScript objects."," *"," * @module json"," * @submodule json-parse"," * @for JSON"," * @static"," */","","","// All internals kept private for security reasons","function fromGlobal(ref) {"," var g = ((typeof global === 'object') ? global : undefined);"," return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];","}","",""," /**"," * Alias to native browser implementation of the JSON object if available."," *"," * @property Native"," * @type {Object}"," * @private"," */","var _JSON = fromGlobal('JSON'),",""," Native = (Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON),"," useNative = !!Native,",""," /**"," * Replace certain Unicode characters that JavaScript may handle incorrectly"," * during eval--either by deleting them or treating them as line"," * endings--with escape sequences."," * IMPORTANT NOTE: This regex will be used to modify the input if a match is"," * found."," *"," * @property _UNICODE_EXCEPTIONS"," * @type {RegExp}"," * @private"," */"," _UNICODE_EXCEPTIONS = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,","",""," /**"," * First step in the safety evaluation. Regex used to replace all escape"," * sequences (i.e. \"\\\\\", etc) with '@' characters (a non-JSON character)."," *"," * @property _ESCAPES"," * @type {RegExp}"," * @private"," */"," _ESCAPES = /\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,",""," /**"," * Second step in the safety evaluation. Regex used to replace all simple"," * values with ']' characters."," *"," * @property _VALUES"," * @type {RegExp}"," * @private"," */"," _VALUES = /\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,",""," /**"," * Third step in the safety evaluation. Regex used to remove all open"," * square brackets following a colon, comma, or at the beginning of the"," * string."," *"," * @property _BRACKETS"," * @type {RegExp}"," * @private"," */"," _BRACKETS = /(?:^|:|,)(?:\\s*\\[)+/g,",""," /**"," * Final step in the safety evaluation. Regex used to test the string left"," * after all previous replacements for invalid characters."," *"," * @property _UNSAFE"," * @type {RegExp}"," * @private"," */"," _UNSAFE = /[^\\],:{}\\s]/,",""," /**"," * Replaces specific unicode characters with their appropriate \\unnnn"," * format. Some browsers ignore certain characters during eval."," *"," * @method escapeException"," * @param c {String} Unicode character"," * @return {String} the \\unnnn escapement of the character"," * @private"," */"," _escapeException = function (c) {"," return '\\\\u'+('0000'+(+(c.charCodeAt(0))).toString(16)).slice(-4);"," },",""," /**"," * Traverses nested objects, applying a reviver function to each (key,value)"," * from the scope if the key:value's containing object. The value returned"," * from the function will replace the original value in the key:value pair."," * If the value returned is undefined, the key will be omitted from the"," * returned object."," *"," * @method _revive"," * @param data {MIXED} Any JavaScript data"," * @param reviver {Function} filter or mutation function"," * @return {MIXED} The results of the filtered data"," * @private"," */"," _revive = function (data, reviver) {"," var walk = function (o,key) {"," var k,v,value = o[key];"," if (value && typeof value === 'object') {"," for (k in value) {"," if (value.hasOwnProperty(k)) {"," v = walk(value, k);"," if (v === undefined) {"," delete value[k];"," } else {"," value[k] = v;"," }"," }"," }"," }"," return reviver.call(o,key,value);"," };",""," return typeof reviver === 'function' ? walk({'':data},'') : data;"," },",""," /**"," * Parse a JSON string, returning the native JavaScript representation."," *"," * @param s {string} JSON string data"," * @param reviver {function} (optional) function(k,v) passed each key value"," * pair of object literals, allowing pruning or altering values"," * @return {MIXED} the native JavaScript representation of the JSON string"," * @throws SyntaxError"," * @method parse"," * @static"," */"," // JavaScript implementation in lieu of native browser support. Based on"," // the json2.js library from http://json.org"," _parse = function (s,reviver) {"," // Replace certain Unicode characters that are otherwise handled"," // incorrectly by some browser implementations."," // NOTE: This modifies the input if such characters are found!"," s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);",""," // Test for any remaining invalid characters"," if (!_UNSAFE.test(s.replace(_ESCAPES,'@')."," replace(_VALUES,']')."," replace(_BRACKETS,''))) {",""," // Eval the text into a JavaScript data structure, apply any"," // reviver function, and return"," return _revive( eval('(' + s + ')'), reviver );"," }",""," throw new SyntaxError('JSON.parse');"," };","","Y.namespace('JSON').parse = function (s,reviver) {"," if (typeof s !== 'string') {"," s += '';"," }",""," return Native && Y.JSON.useNativeParse ?"," Native.parse(s,reviver) : _parse(s,reviver);","};","","function workingNative( k, v ) {"," return k === \"ok\" ? true : v;","}","","// Double check basic functionality. This is mainly to catch early broken","// implementations of the JSON API in Firefox 3.1 beta1 and beta2","if ( Native ) {"," try {"," useNative = ( Native.parse( '{\"ok\":false}', workingNative ) ).ok;"," }"," catch ( e ) {"," useNative = false;"," }","}","","/**"," * Leverage native JSON parse if the browser has a native implementation."," * In general, this is a good idea. See the Known Issues section in the"," * JSON user guide for caveats. The default value is true for browsers with"," * native JSON support."," *"," * @property useNativeParse"," * @type Boolean"," * @default true"," * @static"," */","Y.JSON.useNativeParse = useNative;","","","}, '3.7.3', {\"requires\": [\"yui-base\"]});"];36_yuitest_coverage["build/json-parse/json-parse.js"].lines = {"1":0,"41":0,"42":0,"43":0,"54":0,"124":0,"141":0,"142":0,"143":0,"144":0,"145":0,"146":0,"147":0,"148":0,"150":0,"155":0,"158":0,"178":0,"181":0,"187":0,"190":0,"193":0,"194":0,"195":0,"198":0,"202":0,"203":0,"208":0,"209":0,"210":0,"213":0,"228":0};37_yuitest_coverage["build/json-parse/json-parse.js"].functions = {"fromGlobal:41":0,"_escapeException:123":0,"walk:141":0,"_revive:140":0,"_parse:174":0,"parse:193":0,"workingNative:202":0,"(anonymous 1):1":0};38_yuitest_coverage["build/json-parse/json-parse.js"].coveredLines = 32;39_yuitest_coverage["build/json-parse/json-parse.js"].coveredFunctions = 8;40_yuitest_coverline("build/json-parse/json-parse.js", 1);41YUI.add('json-parse', function (Y, NAME) {42/**43 * <p>The JSON module adds support for serializing JavaScript objects into44 * JSON strings and parsing JavaScript objects from strings in JSON format.</p>45 *46 * <p>The JSON namespace is added to your YUI instance including static methods47 * Y.JSON.parse(..) and Y.JSON.stringify(..).</p>48 *49 * <p>The functionality and method signatures follow the ECMAScript 550 * specification. In browsers with native JSON support, the native51 * implementation is used.</p>52 *53 * <p>The <code>json</code> module is a rollup of <code>json-parse</code> and54 * <code>json-stringify</code>.</p>55 *56 * <p>As their names suggest, <code>json-parse</code> adds support for parsing57 * JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing58 * JavaScript data into JSON strings (Y.JSON.stringify). You may choose to59 * include either of the submodules individually if you don't need the60 * complementary functionality, or include the rollup for both.</p>61 *...
json.js
Source:json.js
1define(["doh/main", "../json", "../has"], function(doh, JSON, has){2 var mustThrow = function(json){3 try{4 JSON.parse(json, true);5 }catch(e){6 return;7 }8 throw new Error("Invalid JSON " + json + " should have been rejected");9 };10 doh.register("tests.json", [11 // all tests below are taken from #4.2 of the CSS3 Color Module12 function simpleString(t){ t.is("bar", JSON.parse('{"foo":"bar"}').foo); },13 function simpleTrue(t){ t.is(true, JSON.parse('{"foo":true}').foo); },14 function simpleFalse(t){ t.is(false, JSON.parse('{"foo":false}').foo); },15 function simpleNull(t){ t.is(null, JSON.parse('{"foo":null}').foo); },16 function simpleNumber(t){ t.is(3.3, JSON.parse('{"foo":3.3}', true).foo); },17 function strictString(t){ t.is("bar", JSON.parse('{"foo":"bar"}', true).foo); },18 function strictEmptyString(t){ t.is("", JSON.parse('{"foo":""}', true).foo); },19 function strictStringEsc(t){ t.is("b\n\t\"ar()", JSON.parse('{"foo":"b\\n\\t\\"ar()"}', true).foo); },20 function strictTrue(t){ t.is(true, JSON.parse('{"foo":true}', true).foo); },21 function strictFalse(t){ t.is(false, JSON.parse('{"foo":false}', true).foo); },22 function strictNull(t){ t.is(null, JSON.parse('{"foo":null}', true).foo); },23 function strictNumber(t){ t.is(3.3, JSON.parse('{"foo":3.3}', true).foo); },24 function strictNumberNeg(t){ t.is(-3.3, JSON.parse('{"foo":-3.3}', true).foo); },25 function exponentNegative(t){ t.is(3.3e-33, JSON.parse('{"foo":3.3e-33}', true).foo); },26 function exponent(t){ t.is(3.3e33, JSON.parse('{"foo":3.3e33}', true).foo); },27 function array(t){ t.is(3, JSON.parse('{"foo":[3,true,[]]}', true).foo[0]); },28 function badCall(t){ mustThrow('{"foo":alert()}'); },29 function badMath(t){ mustThrow('{"foo":3+4}'); },30 function badIndex(t){ mustThrow('{"foo":"bar"}[3]'); },31 function badKey(t){ mustThrow('{foo:"bar"}'); },32 //function badKey2(t){ mustThrow('{2:"bar"}')},33 function badUnbalanced(t){ mustThrow('['); },34 function badUnbalanced2(t){ mustThrow('}'); },35 function badType(t){ mustThrow('["foo":"bar"]'); },36 function badUnbalanced2(t){ mustThrow('}'); },37 function serializeString(t){ t.is('{"foo":"bar"}', JSON.stringify({"foo":"bar"})); },38 function serializeNull(t){ t.is('{"foo":null}', JSON.stringify({"foo":null})); },39 function serializeFunction(t){ t.is('{}', JSON.stringify({"foo":function(){}})); },40 function serializeNaN(t){ t.is('{"foo":null}', JSON.stringify({"foo":NaN})); },41 function serializeInfinity(t){ t.is('{"foo":null}', JSON.stringify({"foo":Infinity})); },42 // there is differences in how many decimals of accuracies in seconds in how Dates are serialized between browsers43 function serializeDate(t){ t.t(/1970-01-01T00:00:00.*Z/.test(JSON.parse(JSON.stringify({"foo":new Date(1)})).foo)); },44 function serializeInherited(t){45 function FooBar() { this.foo = "foo"; }46 FooBar.prototype.bar = "bar";47 t.is('{"foo":"foo"}', JSON.stringify(new FooBar()));48 },49 /*Apparently Firefox doesn't pass the key to the toJSON method*/50 function serializeToJSON(t){ t.is('{"foo":{"name":"value"}}', JSON.stringify({foo:{toJSON:function(key){return {name:"value"}; }}})); }51 ]);52 if(!has("host-rhino")){53 doh.register("tests.json.circular", [54 function serializeCircular(t){55 try{56 var a = {};57 a.a = a;58 console.log("circular: " + JSON.stringify(a));59 }catch(e){60 return;61 }62 throw new Error("stringify must throw for circular references");63 }64 ]);65 }66var smallDataSet = {67 prop1: null,68 prop2: true,69 prop3: [],70 prop4: 3.4325222223332266,71 prop5: 10003,72 prop6: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper",73 prop7: "sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum",74 prop8: "lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus",75 prop9: "venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie",76 prop10: "tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus." +77 "Aliquam vitae enim. Duis scelerisque metus auctor est venenatis imperdiet." +78 "Fusce dignissim porta augue. Nulla vestibulum. Integer lorem nunc," +79 "ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in massa" +80 "bibendum suscipit. Integer eros. Nullam suscipit mauris. In pellentesque." +81 "Mauris ipsum est, pharetra semper, pharetra in, viverra quis, tellus. Etiam" +82 "purus. Quisque egestas, tortor ac cursus lacinia, felis leo adipiscing" +83 "nisi, et rhoncus elit dolor eget eros. Fusce ut quam. Suspendisse eleifend" +84 "leo vitae ligula. Nulla facilisi."85};86var smallJson = JSON.stringify(smallDataSet);87var i, mediumDataSet = [];88for(i = 0; i < 20; i++){89 mediumDataSet.push({90 prop1: null,91 prop2: true,92 prop3: false,93 prop4: 3.4325222223332266 - i,94 prop5: 10003 + i,95 prop6: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper",96 prop7: "sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum",97 prop8: "lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus",98 prop9: "venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie",99 prop10: "tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus." +100 "Aliquam vitae enim."101 });102}103var mediumJson = JSON.stringify(mediumDataSet);104var largeDataSet = [];105for(i = 0; i < 100; i++){106 largeDataSet.push({107 prop1: null,108 prop2: true,109 prop3: false,110 prop4: 3.4325222223332266 - i,111 prop5: ["Mauris ipsum est, pharetra semper, pharetra in, viverra quis, tellus. Etiam" +112 "purus. Quisque egestas, tortor ac cursus lacinia, felis leo adipiscing",113 "nisi, et rhoncus elit dolor eget eros. Fusce ut quam. Suspendisse eleifend" +114 "leo vitae ligula. Nulla facilisi."115 ],116 prop6: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper",117 prop7: "sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum",118 prop8: "lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus",119 prop9: "venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie",120 prop10: "tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus." +121 "Aliquam vitae enim. Duis scelerisque metus auctor est venenatis imperdiet." +122 "Fusce dignissim porta augue. Nulla vestibulum. Integer lorem nunc," +123 "ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in massa" +124 "bibendum suscipit. Integer eros. Nullam suscipit mauris. In pellentesque."125 });126}127var largeJson = JSON.stringify(largeDataSet);128doh.register("tests.json.performance", [129 // all tests below are taken from #4.2 of the CSS3 Color Module130 function small(){131 var i = 10000;132 while(i-->0){133 var result = JSON.parse(smallJson);134 }135 },136 function strictSmall(){137 var i = 10000;138 while(i-->0){139 var result = JSON.parse(smallJson, true);140 }141 },142 function medium(){143 var i = 1000;144 while(i-->0){145 var result = JSON.parse(mediumJson);146 }147 },148 function strictMedium(){149 var i = 1000;150 while(i-->0){151 var result = JSON.parse(mediumJson, true);152 }153 },154 function large(){155 var i = 100;156 while(i-->0){157 var result = JSON.parse(largeJson);158 }159 },160 function strictLarge(){161 var i = 100;162 while(i-->0){163 var result = JSON.parse(largeJson, true);164 }165 }166 ]);...
parse3.test.js
Source:parse3.test.js
1const json = require("./parse");2describe("test json", () => {3 test("true", () => {4 expect(json.parse("true")).toBe(true)5 expect(json.parse(" true")).toBe(true)6 expect(json.parse(" \r\t\ntrue")).toBe(true)7 expect(json.parse("\r\t\n true \r\t\n ")).toBe(true)8 expect(() => json.parse("t")).toThrow()9 expect(() => json.parse("tr ue")).toThrow()10 expect(() => json.parse("tru e")).toThrow()11 expect(() => json.parse("true1")).toThrow()12 expect(() => json.parse("true 1")).toThrow()13 expect(() => json.parse("true \r1")).toThrow()14 })15 test("false", () => {16 expect(json.parse("false")).toBe(false)17 expect(json.parse(" false")).toBe(false)18 expect(json.parse(" \r\t\nfalse")).toBe(false)19 expect(json.parse("\r\t\n false \r\t\n ")).toBe(false)20 expect(() => json.parse("f")).toThrow()21 expect(() => json.parse("fa lse")).toThrow()22 expect(() => json.parse("fals e")).toThrow()23 expect(() => json.parse("false1")).toThrow()24 expect(() => json.parse("false 1")).toThrow()25 expect(() => json.parse("false \r1")).toThrow()26 })27 test("null", () => {28 expect(json.parse("null")).toBe(null)29 expect(json.parse(" null")).toBe(null)30 expect(json.parse(" \r\t\nnull")).toBe(null)31 expect(json.parse("\r\t\n null \r\t\n ")).toBe(null)32 expect(() => json.parse("n")).toThrow()33 expect(() => json.parse("nu ll")).toThrow()34 expect(() => json.parse("ss")).toThrow()35 expect(() => json.parse("null1")).toThrow()36 expect(() => json.parse("null 1")).toThrow()37 expect(() => json.parse("null \r1")).toThrow()38 expect(() => json.parse("nsull")).toThrow()39 })40 test("array", () => {41 expect(json.parse("[]")).toEqual([])42 expect(json.parse("[[]]")).toEqual([[]])43 expect(json.parse("[[],[],[]]")).toEqual([[], [], []])44 expect(json.parse("[[true ],[],[]]")).toEqual([[true], [], []])45 expect(json.parse("[true]")).toEqual([true])46 expect(json.parse("[true,false,null]")).toEqual([true, false, null])47 expect(json.parse("[ \n\r true \n, \n false \n , \n null \n ]")).toEqual([true, false, null])48 expect(() => json.parse("[[]")).toThrow()49 expect(() => json.parse("[,]")).toThrow()50 expect(() => json.parse("[false,,true]")).toThrow()51 expect(() => json.parse("[,true]")).toThrow()52 expect(() => json.parse("[,true]]")).toThrow()53 expect(() => json.parse("[[,]")).toThrow()54 expect(() => json.parse("[[],]")).toThrow()55 expect(() => json.parse("[ \n\r false \n\r , ]")).toThrow()56 expect(json.parse("[ ]")).toEqual([])57 expect(json.parse("[null]")).toEqual([null])58 expect(json.parse("[null, true ,false]")).toEqual([null, true, false])59 expect(json.parse("[true,[null,false]]")).toEqual([true, [null, false]])60 expect(() => json.parse('[')).toThrow()61 expect(() => json.parse('[,,]')).toThrow()62 expect(() => json.parse('[false]]')).toThrow()63 expect(() => json.parse('[,null \r1,]')).toThrow()64 expect(() => json.parse('[nu,]')).toThrow()65 expect(() => json.parse('[[],]')).toThrow()66 expect(() => json.parse('[true,[]')).toThrow()67 expect(() => json.parse('\n[\t]y\t')).toThrow()68 })69 test("string", () => {70 expect(json.parse('"1233"')).toBe("1233")71 expect(json.parse('" 12343"')).toBe(" 12343")72 expect(json.parse('"\\u0033 3"')).toBe("3 3")73 expect(json.parse('"\\n 0033 3"')).toBe("\n 0033 3")74 expect(json.parse('"\\\\"')).toBe("\\")75 expect(() => json.parse('" 123 3')).toThrow()76 expect(() => json.parse('" 123 3\"33 "')).toThrow()77 expect(() => json.parse('"\\s"')).toThrow()78 expect(() => json.parse('"\\ s"')).toThrow()79 expect(() => json.parse('"\\u 0033"')).toThrow()80 expect(() => json.parse('"\\"')).toThrow()81 })82 test("object", () => {83 expect(json.parse('{"key1":true ,"key2":"yahaha"}')).toEqual({ "key1": true, "key2": "yahaha" })84 expect(json.parse('{"key1":["1","2","3"] ,"key2":"yahaha"}')).toEqual({ "key1": ["1", "2", "3"], "key2": "yahaha" })85 expect(json.parse('{"key1":{"key1":true,"key2":[{"a":true,"b":false},"2","3"]} ,"key2":"yahaha"}')).toEqual({ "key1": { "key1": true, "key2": [{ "a": true, "b": false }, "2", "3"] }, "key2": "yahaha" })86 expect(() => json.parse('{key1:true ,"key2":"yahaha"}')).toThrow()87 expect(() => json.parse('{true:true ,"key2":"yahaha"}')).toThrow()88 expect(() => json.parse('{true: ,"key2":"yahaha"}')).toThrow()89 expect(() => json.parse('{ ,"key2":"yahaha"}')).toThrow()90 expect(() => json.parse('{: ,"key2":"yahaha"}')).toThrow()91 expect(() => json.parse('{}: ,"key2":"yahaha"}')).toThrow()92 expect(() => json.parse('{}{: ,"key2":"yahaha"}')).toThrow()93 expect(() => json.parse('{"key1":{{"key1":true,"key2":[{"a":true,"b":false},"2","3"]} ,"key2":"yahaha"}')).toThrow()94 expect(() => json.parse('{"key1":{{"key1":true,"key2":{[{"a":true,"b":false}, "2","3"]} , "key2":"yahaha"}')).toThrow()95 })96 test("number", () => {97 expect(json.parse('0')).toBe(0)98 expect(json.parse('123')).toBe(123)99 expect(json.parse('11.11')).toBe(11.11)100 expect(json.parse('-123')).toBe(-123)101 expect(json.parse('0.123')).toBe(0.123)102 expect(json.parse('-0.123')).toBe(-0.123)103 expect(json.parse('123e+1')).toBe(1230)104 expect(json.parse('1.23e+1')).toBe(1.23e+1)105 expect(json.parse('123e001')).toBe(1230)106 expect(json.parse('1.1e+3345')).toEqual(Infinity)107 expect(() => json.parse('-')).toThrow()108 expect(() => json.parse('-.')).toThrow()109 expect(() => json.parse('-e')).toThrow()110 expect(() => json.parse('-.e')).toThrow()111 expect(() => json.parse('.')).toThrow()112 expect(() => json.parse('1.23 e+')).toThrow()113 expect(() => json.parse('1 23')).toThrow()114 expect(() => json.parse('1.23e+a')).toThrow()115 expect(() => json.parse('0123')).toThrow()116 expect(() => json.parse('00')).toThrow()117 expect(() => json.parse('00.23')).toThrow()118 expect(() => json.parse('0.2.3')).toThrow()119 expect(() => json.parse('0e')).toThrow()120 expect(() => json.parse('123e')).toThrow()121 expect(() => json.parse('1.e')).toThrow()122 expect(() => json.parse('123e2+2')).toThrow()123 expect(() => json.parse('-123e')).toThrow()124 expect(() => json.parse('-123e+2.1e')).toThrow()125 expect(() => json.parse('123e+')).toThrow()126 expect(() => json.parse('123e+0+e')).toThrow()127 expect(() => json.parse('-0.1e+g')).toThrow()128 })...
index.js
Source:index.js
...64 connectionmysql.query(usersql, async (err1, data1) => {65 if (err1) console.log(err1);66 var userdata = JSON.stringify(data1)67 for (var i = 0; i < data1.length; i++){68 const contact1 = await bot.Contact.find({name: JSON.parse(userdata)[i].name})69 if(JSON.parse(userdata)[i].chp == 1){70 var sql = "SELECT content FROM soul";71 connectionmysql.query(sql, async (err, data) => {72 if (err) console.log(err);73 var Range = data.length - 1;74 var Rand = Math.random();75 var id = Math.round(Rand * Range) + 1;76 var content = JSON.stringify(data)77 await contact1.say(JSON.parse(content)[id].content)78 });79 }80 if(JSON.parse(userdata)[i].wea == 1){81 var url = 'https://tianqiapi.com/api?version=v6&appid=ä½ çappid&appsecret=ä½ çå¯ç &city='+ encodeURI('å¦ç');82 request(url, async function(err, response, body){83 var tis = "å½åå®æ¶æ¸©åº¦ï¼"+ JSON.parse(body).tem +"â\n"+84 "天æ°ä¸ºï¼" + JSON.parse(body).wea + "\n"+85 "温度为ï¼" + JSON.parse(body).tem2 + "â - " + JSON.parse(body).tem1 +"â\n"+86 "é£åç级ï¼" + JSON.parse(body).win_speed + " \n"+87 "é£éï¼" + JSON.parse(body).win_meter + " \n" + 88 "空æ°è´¨éï¼" + JSON.parse(body).air + "\n" + 89 "空æ°è´¨éç级ï¼" + JSON.parse(body).air_level + "\n" + 90 "空æ°è´¨éå°è´´å£«ï¼" + JSON.parse(body).air_tips91 await contact1.say(tis)92 // console.log(JSON.parse(body).tem)//å®æ¶æ¸©åº¦93 // console.log(JSON.parse(body).wea)//天æ°94 // console.log(JSON.parse(body).tem1)//ç½å¤©æ¸©åº¦(é«æ¸©)95 // console.log(JSON.parse(body).tem2)//ç½å¤©æ¸©åº¦(ä½æ¸©)96 // console.log(JSON.parse(body).win)//é£å97 // console.log(JSON.parse(body).win_speed)//é£åç级98 // console.log(JSON.parse(body).win_meter)//é£é99 // console.log(JSON.parse(body).air)//空æ°è´¨é100 // console.log(JSON.parse(body).air_tips)//天æ°æ示101 // console.log(JSON.parse(body).air_level)102 })103 }104 }105 })106 });107 })108 .on("message", async message => {109 if(message.self()) return ;110 const contact = message.from()111 const contact1 = await bot.Contact.find({name: contact.name()})112 var params = {113 "Query": message.text()114 }115 client.ChatBot(params).then(
...
parse1.test.js
Source:parse1.test.js
1const json = require("./parse");2describe("parse litertual", () => {3 test("true", () => {4 expect((json.parse("true"))).toBe(true)5 expect((json.parse(" true \r"))).toBe(true)6 expect(() => { (json.parse("tru")) }).toThrow()7 expect(() => { (json.parse("true1")) }).toThrow()8 })9 test("false1", () => {10 expect(json.parse("false")).toBe(false)11 expect(json.parse("false\r\t ")).toBe(false)12 expect(() => { (json.parse("fals")) }).toThrow()13 expect(() => { (json.parse("false1")) }).toThrow()14 })15 test("null1", () => {16 expect(json.parse("null")).toBe(null)17 expect(json.parse("null \n")).toBe(null)18 expect(() => { (json.parse("nul")) }).toThrow()19 expect(() => { (json.parse("null1")) }).toThrow()20 })21 test("number int1", () => {22 expect(json.parse("-0")).toBe(-0)23 expect(json.parse("11")).toBe(11)24 expect(() => json.parse("012")).toThrow()25 expect(() => json.parse("-012")).toThrow()26 expect(json.parse("-1")).toBe(-1)27 expect(json.parse("0")).toBe(0)28 expect(json.parse("-11")).toBe(-11)29 expect(json.parse("1234567890")).toBe(1234567890)30 expect(json.parse("1e1")).toBe(10)31 expect(json.parse("1.1e1")).toBe(11)32 expect(json.parse("1e+1")).toBe(10)33 expect(json.parse("1.1e+1")).toBe(11)34 expect(json.parse("100e-1")).toBe(10)35 expect(json.parse("110e-1")).toBe(11)36 })37 test("number float1", () => {38 expect(json.parse("-0.1")).toBe(-0.1)39 expect(() => json.parse("01.2")).toThrow()40 expect(() => json.parse("-01.2")).toThrow()41 expect(json.parse("-0.123456789")).toBe(-0.123456789)42 expect(json.parse("0.1")).toBe(0.1)43 expect(json.parse("0.123456789")).toBe(0.123456789)44 expect(json.parse("1.23e1")).toBe(12.3)45 expect(json.parse("1.24e+1")).toBe(12.4)46 expect(json.parse("1e-1")).toBe(0.1)47 expect(json.parse("110e-3")).toBe(0.11)48 })49 test("string1", () => {50 expect(json.parse('""')).toBe("")51 expect(json.parse('"12abc"')).toBe("12abc")52 expect(json.parse('"\\r\\n\\b\\t\\f\\"\\\\\\/"')).toBe("\r\n\b\t\f\"\\/")53 expect(json.parse('"\\u0031\\u0032\\u0033abc"')).toBe("123abc")54 expect(() => json.parse('"aa')).toThrow()55 expect(() => json.parse('"\\"')).toThrow()56 expect(() => json.parse('"\\uooiu"')).toThrow()57 expect(() => json.parse('"\\o"')).toThrow()58 })59 test("array1", () => {60 expect(json.parse('[1,2]')).toEqual([1, 2])61 expect(json.parse('[ ]')).toEqual([])62 expect(json.parse('[null, true, false, "123", 1 ]')).toEqual([null, true, false, "123", 1])63 expect(() => json.parse('[')).toThrow()64 expect(() => json.parse('[1, ]')).toThrow()65 expect(json.parse('[{"a":1}, {"a":2}, {"b":1, "c":{"d":3}}]')).toEqual([{ a: 1 }, { a: 2 }, { b: 1, c: { d: 3 } }])66 })67 test("object1", () => {68 expect(json.parse("{}")).toEqual({})69 expect(json.parse('{"a": 1}')).toEqual({ a: 1 })70 expect(json.parse('{"a": "1"}')).toEqual({ a: "1" })71 expect(json.parse('{"a": null}')).toEqual({ a: null })72 expect(json.parse('{"a": true}')).toEqual({ a: true })73 expect(json.parse('{"a": false}')).toEqual({ a: false })74 expect(json.parse('{"a": "null"}')).toEqual({ a: "null" })75 expect(json.parse('{"a": "true"}')).toEqual({ a: "true" })76 expect(json.parse('{"a": "false"}')).toEqual({ a: "false" })77 expect(() => json.parse('{')).toThrow()78 expect(() => json.parse('{a, "b":1}')).toThrow()79 expect(() => json.parse('{ "b":1,}')).toThrow()80 expect(() => json.parse('{a:1}')).toThrow()81 expect(json.parse('{"a": {"a": "a"}, "b":[1,2,3]}')).toEqual({ a: { a: "a" }, b: [1, 2, 3] })82 })...
jsonfile.js
Source:jsonfile.js
1const fs = require("fs")234//Storage5exports.setiker = JSON.parse(fs.readFileSync('./temp/stick.json'))6exports.audionye = JSON.parse(fs.readFileSync('./temp/vn.json'))7exports.musiknye = JSON.parse(fs.readFileSync('./temp/music.json'))8exports.imagenye = JSON.parse(fs.readFileSync('./temp/image.json'))9exports.videonye = JSON.parse(fs.readFileSync('./temp/video.json'))1011//Grup12exports.antilink = JSON.parse(fs.readFileSync('./database/antilink.json'))13exports.antivirtex = JSON.parse(fs.readFileSync('./database/antivirtex.json'))14exports.antihidetg = JSON.parse(fs.readFileSync("./database/antihidetag.json"));15exports.antivo = JSON.parse(fs.readFileSync("./database/antivo.json"));16exports.kickarea = JSON.parse(fs.readFileSync("./database/antibule.json"));17exports.welkom = JSON.parse(fs.readFileSync('./database/welkom.json'))18exports.antibug = JSON.parse(fs.readFileSync('./database/antibug.json'))19exports.antidel = JSON.parse(fs.readFileSync('./database/antidelete.json'))20exports.linkgcnya = JSON.parse(fs.readFileSync('./database/gcdetec.json'))21exports.siminya = JSON.parse(fs.readFileSync('./database/simi.json'))22exports.nsfw = JSON.parse(fs.readFileSync('./database/nsfw.json'))232425//Owner26exports.bancht = JSON.parse(fs.readFileSync('./database/banchat.json'))27exports.mute = JSON.parse(fs.readFileSync('./database/mute.json'))2829//User30exports.spamkuyy = JSON.parse(fs.readFileSync('./database/spam.json'))31exports.grupbadword = JSON.parse(fs.readFileSync('./database/grupbadword.json'));32exports.senbadword = JSON.parse(fs.readFileSync('./database/senbadword.json'));33exports.ban = JSON.parse(fs.readFileSync('./database/banned.json'))34exports.badword = JSON.parse(fs.readFileSync('./database/badword.json'))35exports.balance = JSON.parse(fs.readFileSync('./database/balance.json'));36exports.limit = JSON.parse(fs.readFileSync('./database/limit.json'));37exports.glimit = JSON.parse(fs.readFileSync('./database/glimit.json'));38exports.premium = JSON.parse(fs.readFileSync('./database/premium.json'))39exports._claim = JSON.parse(fs.readFileSync('./database/claim.json'))40exports.sewa = JSON.parse(fs.readFileSync("./database/sewa.json"))41exports.user = JSON.parse(fs.readFileSync('./database/user.json'))42exports.hitnya = JSON.parse(fs.readFileSync('./database/hitToday.json'))43exports.spamBan = JSON.parse(fs.readFileSync('./database/spamban.json'))44exports.blocked = JSON.parse(fs.readFileSync('./database/userblocked.json'))4546exports._reminder = JSON.parse(fs.readFileSync("./database/reminder.json"));47484950//List51exports.listcmdblock = JSON.parse(fs.readFileSync('./database/blockcmd.json'))52exports.listerror = JSON.parse(fs.readFileSync('./database/listerror.json'))5354exports.settings = JSON.parse(fs.readFileSync('./settings.json'))55exports.extream = JSON.parse(fs.readFileSync('./database/extream.json'))565758exports._scommand = JSON.parse(fs.readFileSync('./database/scommand.json'))5960exports.commandsDB = JSON.parse(fs.readFileSync('./database/commands.json'))6162636465666768697071727374
...
formatter.js
Source:formatter.js
1import { jsonParse } from '../formatter';2describe('jsonParse', () => {3 it('should return undefined on undefined input', () => {4 expect(jsonParse(undefined)).toBeNull();5 expect(jsonParse('{')).toBeNull();6 expect(jsonParse('hello world')).toBeNull();7 });8 it('should return parsed JSON', () => {9 expect(jsonParse('{}')).toEqual({});10 expect(jsonParse('"hello world"')).toEqual('hello world');11 expect(jsonParse(42)).toEqual(42);12 expect(jsonParse('24')).toEqual(24);13 expect(jsonParse('{ "test": "ok" }')).toEqual({14 test: 'ok',15 });16 expect(jsonParse('[2, 4, 55]')).toEqual([2, 4, 55]);17 expect(jsonParse('{ "arr": [2, 5] }')).toEqual({18 arr: [2, 5],19 });20 });...
Using AI Code Generation
1var fs = require('fs');2var path = require('path');3var istanbul = require('istanbul');4var collector = new istanbul.Collector();5var reporter = new istanbul.Reporter();6var sync = false;7var verbose = false;8var coverage = JSON.parse(fs.readFileSync(path.resolve(process.cwd(),'coverage/coverage.json')));9collector.add(coverage);10reporter.add('lcov');11reporter.write(collector, sync, function() {12 console.log('All reports generated');13});
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4collector.add(JSON.parse(process.argv[2]));5reporter.add('lcov');6reporter.write(collector, sync, function () {7 console.log('done');8});9FN:6,(anonymous_0)10FN:7,(anonymous_1)11FN:8,(anonymous_2)12FN:9,(anonymous_3)13FN:10,(anonymous_4)14FN:11,(anonymous_5)15FN:12,(anonymous_6)16FN:13,(anonymous_7)17FN:14,(anonymous_8)18FN:15,(anonymous_9)19FN:16,(anonymous_10)20FN:17,(anonymous_11)21FN:18,(anonymous_12)22FN:19,(anonymous_13)23FN:20,(anonymous_14)24FN:21,(anonymous_15)25FN:22,(anonymous_16)26FN:23,(anonymous_17)27FN:24,(anonymous_18)28FN:25,(anonymous_19)29FN:26,(anonymous_20)30FN:27,(anonymous_21)31FN:28,(anonymous_22)32FN:29,(anonymous_23)33FN:30,(anonymous_24)34FN:31,(anonymous_25)35FN:32,(anonymous_26)36FN:33,(anonymous_27)37FN:34,(anonymous_28)38FN:35,(anonymous_29)39FN:36,(anonymous_30)40FN:37,(anonymous_31)41FN:38,(anonymous_32)42FN:39,(anonymous_33)43FN:40,(anonymous_34)44FN:41,(anonymous_35)45FN:42,(anonymous_36)46FN:43,(anonymous_37)47FN:44,(anonymous_38)48FN:45,(anonymous_39)49FN:46,(anonymous_40)50FN:47,(anonymous_41)51FN:48,(anonymous_42)52FN:49,(anonymous_43)53FN:50,(anonymous_44)54FN:51,(anonymous_45)55FN:52,(anonymous_46)56FN:53,(anonymous_47)57FN:54,(anonymous_48)58FN:55,(
Using AI Code Generation
1var fs = require('fs');2var json = fs.readFileSync('./coverage/coverage.json', 'utf8');3var cov = JSON.parse(json);4console.log(cov);5var libCoverage = require('istanbul-lib-coverage');6var map = libCoverage.createCoverageMap(cov);7console.log(map);8var reports = require('istanbul-reports');9var context = libCoverage.createContext();10var tree = reports.create('text', {});11tree.writeReport(map, context);12var reports = require('istanbul-reports');13var context = libCoverage.createContext();14var tree = reports.create('text-summary', {});15tree.writeReport(map, context);16var reports = require('istanbul-reports');17var context = libCoverage.createContext();18var tree = reports.create('html', {});19tree.writeReport(map, context);
Using AI Code Generation
1var fs = require('fs');2var JSON = require('JSON');3var myJSON = fs.readFileSync('coverage/coverage-final.json');4var myObject = JSON.parse(myJSON);5console.log(myObject);6var istanbul = require('istanbul');7var collector = new istanbul.Collector();8collector.add(myObject);9var reporter = new istanbul.Reporter();10reporter.add('html');11reporter.write(collector, true, function () {12 console.log('All reports generated');13});14 at Object.fs.openSync (fs.js:439:18)15 at Object.fs.readFileSync (fs.js:290:15)16 at Object.<anonymous> (test.js:5:21)17 at Module._compile (module.js:449:26)18 at Object.Module._extensions..js (module.js:467:10)19 at Module.load (module.js:356:32)20 at Function.Module._load (module.js:312:12)21 at Function.Module.runMain (module.js:497:10)22 at startup (node.js:119:16)
Using AI Code Generation
1var fs = require('fs');2var istanbul = require('istanbul');3var coverage = fs.readFileSync('coverage.json', 'utf8');4var collector = new istanbul.Collector();5var reporter = new istanbul.Reporter();6var sync = false;7collector.add(JSON.parse(coverage));8reporter.add('html');9reporter.write(collector, sync, function () {10 console.log('All reports generated');11});
Using AI Code Generation
1var istanbul = require('istanbul');2var coverage = istanbul.utils.readJSONSync('coverage/coverage.json');3console.log(coverage);4var istanbul = require('istanbul');5var coverage = istanbul.utils.readJSONSync('coverage.json');6console.log(coverage);7var istanbul = require('istanbul');8var coverage = istanbul.utils.readJSONSync('coverage/coverage.json');9console.log(coverage);10var istanbul = require('istanbul');11var coverage = istanbul.utils.readJSONSync('coverage.json');12console.log(coverage);13var istanbul = require('istanbul');14var coverage = istanbul.utils.readJSONSync('coverage/coverage.json');15console.log(coverage);16var istanbul = require('istanbul');17var coverage = istanbul.utils.readJSONSync('coverage.json');18console.log(coverage);19var istanbul = require('istanbul');20var coverage = istanbul.utils.readJSONSync('coverage/coverage.json');21console.log(coverage);22var istanbul = require('istan
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!!