Best JavaScript code snippet using istanbul
cards.js
Source:cards.js
1const imageFilenames = {2 turtle: 'turtle.jpg',3 tired: 'tired.jpg',4 swim: 'swim.jpg',5 surprised: 'surprised.jpg',6 stew: 'stew.jpg',7 squid: 'squid.jpg',8 smile: 'smile.jpg',9 skirt: 'skirt.jpg',10 skip: 'skip.jpg',11 sister: 'sister.jpg',12 sing: 'sing.jpg',13 shoe: 'shoe.jpg',14 shirt: 'shirt.jpg',15 sheep: 'sheep.jpg',16 scared: 'scared.jpg',17 sad: 'sad.jpg',18 run: 'run.jpg',19 ride: 'ride.jpg',20 recipe: 'recipe.jpg',21 rabbit: 'rabbit.jpg',22 point: 'point.jpg',23 play: 'play.jpg',24 pig: 'pig.jpg',25 pet: 'pet.jpg',26 pants: 'pants.jpg',27 open: 'open.jpg',28 mushroom: 'mushroom.jpg',29 mouse: 'mouse.jpg',30 mother: 'mother.jpg',31 lion: 'lion.jpg',32 laugh: 'laugh.jpg',33 jump: 'jump.jpg',34 hug: 'hug.jpg',35 horse: 'horse.jpg',36 happy: 'happy.jpg',37 grandpa: 'grandpa.jpg',38 grandma: 'grandma.jpg',39 giraffe: 'giraffe.jpg',40 garlic: 'garlic.jpg',41 frog: 'frog.jpg',42 Food: 'Food.jpg',43 fly: 'fly.jpg',44 fish1: 'fish1.jpg',45 fish: 'fish.jpg',46 father: 'father.jpg',47 Family: 'Family.jpg',48 fail: 'fail.png',49 excellent: 'excellent.png',50 emotions: 'Emotions.jpg',51 dress: 'dress.jpg',52 draw: 'draw.jpg',53 dolphin: 'dolphin.jpg',54 dog: 'dog.jpg',55 dive: 'dive.jpg',56 dance: 'dance.jpg',57 cry: 'cry.jpg',58 courgette: 'courgette.jpg',59 coat: 'coat.jpg',60 Clothes: 'Clothes.jpg',61 chicken: 'chicken.jpg',62 chick: 'chick.jpg',63 cereal: 'cereal.jpg',64 cat: 'cat.jpg',65 brother: 'brother.jpg',66 boot: 'boot.jpg',67 blouse: 'blouse.jpg',68 bird: 'bird.jpg',69 aubergine: 'aubergine.jpg',70 animalB: 'Animal (set B).jpg',71 animalA: 'Animal (set A).jpg',72 angry: 'angry.jpg',73 actionB: 'Action (set B).jpg',74 actionA: 'Action (set A).jpg',75}76const audioFilenames = {77 turtle: 'turtle.mp3',78 tired: 'tired.mp3',79 swim: 'swim.mp3',80 surprised: 'surprised.mp3',81 stew: 'stew.mp3',82 squid: 'squid.mp3',83 smile: 'smile.mp3',84 skirt: 'skirt.mp3',85 skip: 'skip.mp3',86 sister: 'sister.mp3',87 sing: 'sing.mp3',88 shoe: 'shoe.mp3',89 shirt: 'shirt.mp3',90 sheep: 'sheep.mp3',91 scared: 'scared.mp3',92 sad: 'sad.mp3',93 run: 'run.mp3',94 ride: 'ride.mp3',95 recipe: 'recipe.mp3',96 rabbit: 'rabbit.mp3',97 point: 'point.mp3',98 play: 'play.mp3',99 pig: 'pig.mp3',100 pet: 'pet.mp3',101 pants: 'pants.mp3',102 open: 'open.mp3',103 mushroom: 'mushroom.mp3',104 mouse: 'mouse.mp3',105 mother: 'mother.mp3',106 lion: 'lion.mp3',107 laugh: 'laugh.mp3',108 jump: 'jump.mp3',109 hug: 'hug.mp3',110 horse: 'horse.mp3',111 happy: 'happy.mp3',112 grandpa: 'grandpa.mp3',113 grandma: 'grandma.mp3',114 giraffe: 'giraffe.mp3',115 garlic: 'garlic.mp3',116 family: 'family.mp3',117 frog: 'frog.mp3',118 fly: 'fly.mp3',119 fish: 'fish.mp3',120 father: 'father.mp3',121 dress: 'dress.mp3',122 draw: 'draw.mp3',123 dolphin: 'dolphin.mp3',124 dog: 'dog.mp3',125 dive: 'dive.mp3',126 dance: 'dance.mp3',127 cry: 'cry.mp3',128 courgette: 'courgette.mp3',129 coat: 'coat.mp3',130 chicken: 'chicken.mp3',131 chick: 'chick.mp3',132 cereal: 'cereal.mp3',133 cat: 'cat.mp3',134 brother: 'brother.mp3',135 boot: 'boot.mp3',136 blouse: 'blouse.mp3',137 bird: 'bird.mp3',138 aubergine: 'aubergine.mp3',139 angry: 'angry.mp3',140}141function resolveImagePath(filename) {142 return require(`../img/${filename}`)143}144function resolveAudioPath(filename) {145 return require(`../audio/${filename}`)146}147export const categories = [148 {149 name: 'Action (set A)',150 filename: resolveImagePath(imageFilenames.actionA),151 cards: [152 {153 word: 'cry',154 translation: 'плакаÑÑ',155 filename: resolveImagePath(imageFilenames.cry),156 audioSrc: resolveAudioPath(audioFilenames.cry),157 },158 {159 word: 'dance',160 translation: 'ÑанÑеваÑÑ',161 filename: resolveImagePath(imageFilenames.dance),162 audioSrc: resolveAudioPath(audioFilenames.dance),163 },164 {165 word: 'dive',166 translation: 'нÑÑÑÑÑ',167 filename: resolveImagePath(imageFilenames.dive),168 audioSrc: resolveAudioPath(audioFilenames.dive),169 },170 {171 word: 'draw',172 translation: 'ÑиÑоваÑÑ',173 filename: resolveImagePath(imageFilenames.draw),174 audioSrc: resolveAudioPath(audioFilenames.draw),175 },176 {177 word: 'fishing',178 translation: 'ловиÑÑ ÑÑбÑ',179 filename: resolveImagePath(imageFilenames.fish),180 audioSrc: resolveAudioPath(audioFilenames.fish),181 },182 {183 word: 'fly',184 translation: 'леÑаÑÑ',185 filename: resolveImagePath(imageFilenames.fly),186 audioSrc: resolveAudioPath(audioFilenames.fly),187 },188 {189 word: 'hug',190 translation: 'обнимаÑÑ',191 filename: resolveImagePath(imageFilenames.hug),192 audioSrc: resolveAudioPath(audioFilenames.hug),193 },194 {195 word: 'jump',196 translation: 'пÑÑгаÑÑ',197 filename: resolveImagePath(imageFilenames.jump),198 audioSrc: resolveAudioPath(audioFilenames.jump),199 },200 ],201 },202 {203 name: 'Action (set B)',204 filename: resolveImagePath(imageFilenames.actionB),205 cards: [206 {207 word: 'open',208 translation: 'оÑкÑÑваÑÑ',209 filename: resolveImagePath(imageFilenames.open),210 audioSrc: resolveAudioPath(audioFilenames.open),211 },212 {213 word: 'play',214 translation: 'игÑаÑÑ',215 filename: resolveImagePath(imageFilenames.play),216 audioSrc: resolveAudioPath(audioFilenames.play),217 },218 {219 word: 'point',220 translation: 'ÑказÑваÑÑ',221 filename: resolveImagePath(imageFilenames.point),222 audioSrc: resolveAudioPath(audioFilenames.point),223 },224 {225 word: 'ride',226 translation: 'ездиÑÑ',227 filename: resolveImagePath(imageFilenames.ride),228 audioSrc: resolveAudioPath(audioFilenames.ride),229 },230 {231 word: 'run',232 translation: 'бегаÑÑ',233 filename: resolveImagePath(imageFilenames.run),234 audioSrc: resolveAudioPath(audioFilenames.run),235 },236 {237 word: 'sing',238 translation: 'пеÑÑ',239 filename: resolveImagePath(imageFilenames.sing),240 audioSrc: resolveAudioPath(audioFilenames.sing),241 },242 {243 word: 'skip',244 translation: 'пÑопÑÑкаÑÑ, пÑÑгаÑÑ',245 filename: resolveImagePath(imageFilenames.skip),246 audioSrc: resolveAudioPath(audioFilenames.skip),247 },248 {249 word: 'swim',250 translation: 'плаваÑÑ',251 filename: resolveImagePath(imageFilenames.swim),252 audioSrc: resolveAudioPath(audioFilenames.swim),253 },254 ],255 },256 {257 name: 'Animal (set A)',258 filename: resolveImagePath(imageFilenames.animalA),259 cards: [260 {261 word: 'cat',262 translation: 'коÑ',263 filename: resolveImagePath(imageFilenames.cat),264 audioSrc: resolveAudioPath(audioFilenames.cat),265 },266 {267 word: 'chick',268 translation: 'ÑÑплÑнок',269 filename: resolveImagePath(imageFilenames.chick),270 audioSrc: resolveAudioPath(audioFilenames.chick),271 },272 {273 word: 'chicken',274 translation: 'кÑÑиÑа',275 filename: resolveImagePath(imageFilenames.chicken),276 audioSrc: resolveAudioPath(audioFilenames.chicken),277 },278 {279 word: 'dog',280 translation: 'Ñобака',281 filename: resolveImagePath(imageFilenames.dog),282 audioSrc: resolveAudioPath(audioFilenames.dog),283 },284 {285 word: 'horse',286 translation: 'лоÑадÑ',287 filename: resolveImagePath(imageFilenames.horse),288 audioSrc: resolveAudioPath(audioFilenames.horse),289 },290 {291 word: 'pig',292 translation: 'ÑвинÑÑ',293 filename: resolveImagePath(imageFilenames.pig),294 audioSrc: resolveAudioPath(audioFilenames.pig),295 },296 {297 word: 'rabbit',298 translation: 'кÑолик',299 filename: resolveImagePath(imageFilenames.rabbit),300 audioSrc: resolveAudioPath(audioFilenames.rabbit),301 },302 {303 word: 'sheep',304 translation: 'овÑа',305 filename: resolveImagePath(imageFilenames.sheep),306 audioSrc: resolveAudioPath(audioFilenames.sheep),307 },308 ],309 },310 {311 name: 'Animal (set B)',312 filename: resolveImagePath(imageFilenames.animalB),313 cards: [314 {315 word: 'bird',316 translation: 'пÑиÑа',317 filename: resolveImagePath(imageFilenames.bird),318 audioSrc: resolveAudioPath(audioFilenames.bird),319 },320 {321 word: 'fish',322 translation: 'ÑÑба',323 filename: resolveImagePath(imageFilenames.fish1),324 audioSrc: resolveAudioPath(audioFilenames.fish),325 },326 {327 word: 'frog',328 translation: 'жаба',329 filename: resolveImagePath(imageFilenames.frog),330 audioSrc: resolveAudioPath(audioFilenames.frog),331 },332 {333 word: 'giraffe',334 translation: 'жиÑаÑа',335 filename: resolveImagePath(imageFilenames.giraffe),336 audioSrc: resolveAudioPath(audioFilenames.giraffe),337 },338 {339 word: 'lion',340 translation: 'лев',341 filename: resolveImagePath(imageFilenames.lion),342 audioSrc: resolveAudioPath(audioFilenames.lion),343 },344 {345 word: 'mouse',346 translation: 'мÑÑÑ',347 filename: resolveImagePath(imageFilenames.mouse),348 audioSrc: resolveAudioPath(audioFilenames.mouse),349 },350 {351 word: 'turtle',352 translation: 'ÑеÑепаÑ
а',353 filename: resolveImagePath(imageFilenames.turtle),354 audioSrc: resolveAudioPath(audioFilenames.turtle),355 },356 {357 word: 'dolphin',358 translation: 'делÑÑин',359 filename: resolveImagePath(imageFilenames.dolphin),360 audioSrc: resolveAudioPath(audioFilenames.dolphin),361 },362 ],363 },364 {365 name: 'Clothes',366 filename: resolveImagePath(imageFilenames.Clothes),367 cards: [368 {369 word: 'skirt',370 translation: 'Ñбка',371 filename: resolveImagePath(imageFilenames.skirt),372 audioSrc: resolveAudioPath(audioFilenames.skirt),373 },374 {375 word: 'pants',376 translation: 'бÑÑки',377 filename: resolveImagePath(imageFilenames.pants),378 audioSrc: resolveAudioPath(audioFilenames.pants),379 },380 {381 word: 'blouse',382 translation: 'блÑзка',383 filename: resolveImagePath(imageFilenames.blouse),384 audioSrc: resolveAudioPath(audioFilenames.blouse),385 },386 {387 word: 'dress',388 translation: 'плаÑÑе',389 filename: resolveImagePath(imageFilenames.dress),390 audioSrc: resolveAudioPath(audioFilenames.dress),391 },392 {393 word: 'boot',394 translation: 'боÑинок',395 filename: resolveImagePath(imageFilenames.boot),396 audioSrc: resolveAudioPath(audioFilenames.boot),397 },398 {399 word: 'shirt',400 translation: 'ÑÑбаÑка',401 filename: resolveImagePath(imageFilenames.shirt),402 audioSrc: resolveAudioPath(audioFilenames.shirt),403 },404 {405 word: 'coat',406 translation: 'палÑÑо',407 filename: resolveImagePath(imageFilenames.coat),408 audioSrc: resolveAudioPath(audioFilenames.coat),409 },410 {411 word: 'shoe',412 translation: 'ÑÑÑли',413 filename: resolveImagePath(imageFilenames.shoe),414 audioSrc: resolveAudioPath(audioFilenames.shoe),415 },416 ],417 },418 {419 name: 'Emotions',420 filename: resolveImagePath(imageFilenames.emotions),421 cards: [422 {423 word: 'sad',424 translation: 'гÑÑÑÑнÑй',425 filename: resolveImagePath(imageFilenames.sad),426 audioSrc: resolveAudioPath(audioFilenames.sad),427 },428 {429 word: 'angry',430 translation: 'ÑеÑдиÑÑй',431 filename: resolveImagePath(imageFilenames.angry),432 audioSrc: resolveAudioPath(audioFilenames.angry),433 },434 {435 word: 'happy',436 translation: 'ÑÑаÑÑливÑй',437 filename: resolveImagePath(imageFilenames.happy),438 audioSrc: resolveAudioPath(audioFilenames.happy),439 },440 {441 word: 'tired',442 translation: 'ÑÑÑавÑий',443 filename: resolveImagePath(imageFilenames.tired),444 audioSrc: resolveAudioPath(audioFilenames.tired),445 },446 {447 word: 'surprised',448 translation: 'ÑдивлÑннÑй',449 filename: resolveImagePath(imageFilenames.surprised),450 audioSrc: resolveAudioPath(audioFilenames.surprised),451 },452 {453 word: 'scared',454 translation: 'иÑпÑганнÑй',455 filename: resolveImagePath(imageFilenames.scared),456 audioSrc: resolveAudioPath(audioFilenames.scared),457 },458 {459 word: 'smile',460 translation: 'ÑлÑбка',461 filename: resolveImagePath(imageFilenames.smile),462 audioSrc: resolveAudioPath(audioFilenames.smile),463 },464 {465 word: 'laugh',466 translation: 'ÑмеÑ
',467 filename: resolveImagePath(imageFilenames.laugh),468 audioSrc: resolveAudioPath(audioFilenames.laugh),469 },470 ],471 },472 {473 name: 'Food',474 filename: resolveImagePath(imageFilenames.Food),475 cards: [476 {477 word: 'squid',478 translation: 'калÑмаÑ',479 filename: resolveImagePath(imageFilenames.squid),480 audioSrc: resolveAudioPath(audioFilenames.squid),481 },482 {483 word: 'courgette',484 translation: 'кабаÑок',485 filename: resolveImagePath(imageFilenames.courgette),486 audioSrc: resolveAudioPath(audioFilenames.courgette),487 },488 {489 word: 'garlic',490 translation: 'ÑеÑнок',491 filename: resolveImagePath(imageFilenames.garlic),492 audioSrc: resolveAudioPath(audioFilenames.garlic),493 },494 {495 word: 'mushroom',496 translation: 'гÑиб',497 filename: resolveImagePath(imageFilenames.mushroom),498 audioSrc: resolveAudioPath(audioFilenames.mushroom),499 },500 {501 word: 'cereal',502 translation: 'зеÑновой',503 filename: resolveImagePath(imageFilenames.cereal),504 audioSrc: resolveAudioPath(audioFilenames.cereal),505 },506 {507 word: 'aubergine',508 translation: 'баклажан',509 filename: resolveImagePath(imageFilenames.aubergine),510 audioSrc: resolveAudioPath(audioFilenames.aubergine),511 },512 {513 word: 'stew',514 translation: 'ÑÑÑенка',515 filename: resolveImagePath(imageFilenames.stew),516 audioSrc: resolveAudioPath(audioFilenames.stew),517 },518 {519 word: 'recipe',520 translation: 'ÑеÑепÑ',521 filename: resolveImagePath(imageFilenames.recipe),522 audioSrc: resolveAudioPath(audioFilenames.recipe),523 },524 ],525 },526 {527 name: 'Family',528 filename: resolveImagePath(imageFilenames.Family),529 cards: [530 {531 word: 'family',532 translation: 'ÑемÑÑ',533 filename: resolveImagePath(imageFilenames.Family),534 audioSrc: resolveAudioPath(audioFilenames.family),535 },536 {537 word: 'mother',538 translation: 'маÑÑ',539 filename: resolveImagePath(imageFilenames.mother),540 audioSrc: resolveAudioPath(audioFilenames.mother),541 },542 {543 word: 'father',544 translation: 'оÑеÑ',545 filename: resolveImagePath(imageFilenames.father),546 audioSrc: resolveAudioPath(audioFilenames.father),547 },548 {549 word: 'sister',550 translation: 'ÑеÑÑÑа',551 filename: resolveImagePath(imageFilenames.sister),552 audioSrc: resolveAudioPath(audioFilenames.sister),553 },554 {555 word: 'brother',556 translation: 'бÑаÑ',557 filename: resolveImagePath(imageFilenames.brother),558 audioSrc: resolveAudioPath(audioFilenames.brother),559 },560 {561 word: 'grandma',562 translation: 'бабÑÑка',563 filename: resolveImagePath(imageFilenames.grandma),564 audioSrc: resolveAudioPath(audioFilenames.grandma),565 },566 {567 word: 'grandpa',568 translation: 'дедÑÑка',569 filename: resolveImagePath(imageFilenames.grandpa),570 audioSrc: resolveAudioPath(audioFilenames.grandpa),571 },572 {573 word: 'pet',574 translation: 'домаÑнее живоÑное',575 filename: resolveImagePath(imageFilenames.pet),576 audioSrc: resolveAudioPath(audioFilenames.pet),577 },578 ],579 },...
bot.js
Source:bot.js
1require('dotenv').config();2const Discord = require('discord.js');3const fs = require('fs');4const { OpusEncoder } = require('@discordjs/opus');5const { Client, Intents } = require('discord.js');6const client = new Client({7 ws: { intents: Intents.All },8 partials: ['MESSAGE', 'CHANNEL', 'REACTION'],9});10client.once('ready', () => {11 console.log('Ready!');12});13let macIntro = true;14client.on('voiceStateUpdate', async (state, state2) => {15 // Plays audio of tony Tony Hologram for mac16 if (state2.member.id === '295912051984039936') {17 if (macIntro === true) {18 if (state.selfMute === false && state2.selfMute == false) {19 if (state.mute === false && state2.mute == false) {20 if (state.deaf === false && state2.deaf == false) {21 if (state.streaming === false && state2.streaming == false) {22 if (state.selfVideo === false && state2.selfVideo == false) {23 await state2.channel24 .join()25 .then(connection => {26 const dispatcher = connection.play('audio folder1/porn.mp3', { volume: 0.5 }, { highWaterMark: 50 });27 dispatcher.on('finish', () => connection.disconnect());28 })29 .catch(e => {30 console.error(e);31 });32 }33 }34 }35 }36 }37 }38 }39});40const memes = new Map([41 ['anime', { fileNames: ['anime.mp3'] }],42 ['ara ara', { fileNames: ['ara ara.mp3'], volume: 0.9 }],43 ['ahh', { fileNames: ['ahh.mp3'], volume: 0.9 }],44 ['airpods', { fileNames: ['airpods.mp3'], volume: 0.9 }],45 ['arkbar', { fileNames: ['arkbar.mp3'] }],46 ['asnee', { fileNames: ['asnee.mp3'] }],47 ['asian people', { fileNames: ['asianpeople.mp3'], volume: 0.9 }],48 ['autism', { fileNames: ['autism.mp3'] }],49 ['bear patrol', { fileNames: ['bear patrol.mp3'] }],50 ['bender', { fileNames: ['bender.mp3'] }],51 ['bigshaq', { fileNames: ['bigshaq.mp3'] }],52 ['bono', { fileNames: ['bono.mp3'] }],53 ['borat', { fileNames: ['borat.mp3'] }],54 ['buklau', { fileNames: ['buklau.mp3', 'buklau2.mp3', 'buklau3.mp3'] }],55 ['breyers', { fileNames: ['byriers.mp3'] }],56 ['call to prayer', { fileNames: ['call to prayer.mp3'], volume: 0.2 }],57 ['carlton', { fileNames: ['carlton.mp3'] }],58 ['cat jam', { fileNames: ['cat jam original.mp3'] }],59 ['chum drum', { fileNames: ['chum_drum_bedrum_-4353029994025334169.mp3'] }],60 ['coke', { fileNames: ['coke.mp3'] }],61 ['cold snap', { fileNames: ['cold snap.mp3'] }],62 ['crab rave', { fileNames: ['crab_rave_sound_effect_84840729185338176.mp3'] }],63 ['croissant', { fileNames: ['carl_wheezer_croissant_2900525901889400232.mp3'] }],64 ['dat boi', { fileNames: ['datboi.mp3'], volume: 0.9 }],65 ['democracy', { fileNames: ['democracy.mp3'], volume: 0.9 }],66 ['dinkster', { fileNames: ['somebody_ring_the_dinkster_-2919279323241905165.mp3'] }],67 ['divorce cute', { fileNames: ['divorce-cute.mp3'] }],68 ['divorce short', { fileNames: ['divroce-short.mp3'] }],69 ['donkey', { fileNames: ['donkey.mp3'] }],70 ['dortycorry', { fileNames: ['dortycorry1.mp3', 'dortycorry2.mp3'] }],71 ['ed scream', { fileNames: ['Edscream.mp3'] }],72 ['egg', { fileNames: ['egg.mp3'] }],73 ['eyboss', { fileNames: ['eyboss.mp3'] }],74 ['foksmash', { fileNames: ['foksmash.mp3'] }],75 ['getaknife', { fileNames: ['getaknife.mp3'] }],76 [77 'news',78 {79 fileNames: ['government-sponsors.mp3', 'dublin-airport.mp3', 'public-stonings.mp3', 'rebel-stronghold.mp3'],80 },81 ],82 ['hairy', { fileNames: ['hairy.mp3'], volume: 0.9 }],83 ['hal', { fileNames: ['hal.mp3'] }],84 ['halo', { fileNames: ['halo.mp3'], volume: 0.9 }],85 ['halo theme', { fileNames: ['halo theme.mp3'], volume: 0.4 }],86 ['harry', { fileNames: ['harry1.mp3', 'harry2.mp3'] }],87 ['heffo', { fileNames: ['heffo.mp3'] }],88 ['horseplay', { fileNames: ['horseplay.mp3'], volume: 0.9 }],89 ['im taking a shit', { fileNames: ['please_get_out_im_taking_a_shit_-606515860420089524.mp3'] }],90 ['joey', { fileNames: ['joey.mp3'] }],91 ['judo', { fileNames: ['judo.mp3'], volume: 0.9 }],92 ['divorce', { fileNames: ['John-I-want-Divorce.mp3'] }],93 ['konichiwa', { fileNames: ['konichiwa.mp3'], volume: 0.9 }],94 ['knifey', { fileNames: ['knifey.mp3'] }],95 ['knuckes', { fileNames: ['knuckles1.mp3', 'knuckles2.mp3'] }],96 ['lads', { fileNames: ['LADS.mp3'] }],97 ['ladsfull', { fileNames: ['ladsfull.mp3'] }],98 ['limp', { fileNames: ['limp.mp3'], volume: 0.9 }],99 ['legs', { fileNames: ['legs (1).mp3'] }],100 ['lesson', { fileNames: ['lesson.mp3'] }],101 ['lie detector', { fileNames: ['lie detector.mp3'] }],102 ['lovely', { fileNames: ['lovely.mp3', 'lovely2.mp3'] }],103 ['mac shut up', { fileNames: ['mac shut up.mp3'], volume: 1.8 }],104 ['milkman', { fileNames: ['milkman.mp3'], volume: 0.9 }],105 ['my penis', { fileNames: ['mypenis.mp3'], volume: 0.6 }],106 ['menu', { fileNames: ['menu1.mp3, menu2.mp3, menu3.mp3'] }],107 ['miranda', { fileNames: ['miranda.mp3'] }],108 ['mr freeze', { fileNames: ['mr freeze.mp3', 'mrfreeze.mp3'] }],109 ['muck', { fileNames: ['muck.mp3'] }],110 ['neck', { fileNames: ['neck.mp3'], volume: 0.4 }],111 ['nice', { fileNames: ['nice.mp3'] }],112 ['pats', { fileNames: ['pats1.mp3', 'pats2.mp3', 'pats3.mp3'] }],113 ['pen', { fileNames: ['pen.mp3'] }],114 ['penis', { fileNames: ['penis.mp3'], volume: 0.9 }],115 ['pissing', { fileNames: ['pissing.mp3'] }],116 ['please', { fileNames: ['please.mp3'] }],117 ['poopy', { fileNames: ['poopy.mp3'] }],118 ['popcoin', { fileNames: ['popcoin.mp3'] }],119 ['porn', { fileNames: ['porn.mp3'] }],120 ['potions', { fileNames: ['potions.mp3'] }],121 ['prettygood', { fileNames: ['prettygood.mp3'] }],122 ['pro cycling manager', { fileNames: ['pro cycling manager.mp3'], volume: 0.4 }],123 ['pussy', { fileNames: ['pussy.mp3'], volume: 0.9 }],124 ['putin', { fileNames: ['putin.mp3'] }],125 ['quickmafs', { fileNames: ['quickmafs.mp3'] }],126 ['renekton', { fileNames: ['renekton.mp3'] }],127 ['sassy', { fileNames: ['sassy1.mp3'] }],128 ['say again', { fileNames: ['say-again.mp3'] }],129 ['shit', { fileNames: ['shit.mp3'] }],130 ['shut up', { fileNames: ['mac shut up.mp3'] }],131 ['smellz', { fileNames: ['smellz1.mp3', 'smellz2.mp3', 'smellz3.mp3'] }],132 ['somebody', { fileNames: ['somebody.mp3'] }],133 ['soup1', { fileNames: ['soup1.mp3'], volume: 0.9 }],134 ['soup2', { fileNames: ['soup2.mp3'], volume: 0.9 }],135 ['soup3', { fileNames: ['soup3.mp3'], volume: 0.9 }],136 ['succulent', { fileNames: ['succulent.mp3'], volume: 0.9 }],137 ['suh1', { fileNames: ['suh1.mp3'], volume: 0.9 }],138 ['suh2', { fileNames: ['suh2.mp3'], volume: 0.9 }],139 ['suh3', { fileNames: ['suh3.mp3'], volume: 0.9 }],140 ['starving', { fileNames: ['starving (1).mp3'] }],141 ['stinging roger', { fileNames: ['stinging roger.mp3'] }],142 ['street', { fileNames: ['street.mp3'] }],143 ['strong potions', { fileNames: ['strong-potions.mp3'] }],144 ['sus', { fileNames: ['sus.mp3'] }],145 ['the sun priest', { fileNames: ['TheSunPriest.mp3'] }],146 ['viper', { fileNames: ['TheViper.mp3', 'Theviper2.mp3', 'Theviper3.mp3'] }],147 ['tony', { fileNames: ['tony.mp3'] }],148 [149 'trump',150 {151 fileNames: ['trump1.mp3', 'trump2.mp3', 'trump3.mp3', 'trump4.mp3', 'trump5.mp3'],152 },153 ],154 ['uncanny', { fileNames: ['uncanny.mp3', 'uncanny2.mp3'] }],155 ['uncle roger', { fileNames: ['uncle roger.mp3'] }],156 ['wam', { fileNames: ['Dedotated Wam - MLG Sound Effect (HD).mp3'] }],157 ['weans', { fileNames: ['weans.mp3'] }],158 ['wink', { fileNames: ['wink.mp3'], volume: 0.9 }],159 ['yokes', { fileNames: ['yokes.mp3'] }],160]);161client.on('messageReactionAdd', async (reaction, user) => {162 // When a reaction is received, check if the structure is partial163 if (reaction.partial) {164 // If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled165 try {166 await reaction.fetch();167 } catch (error) {168 console.error('Something went wrong when fetching the message: ', error);169 // Return as `reaction.message.author` may be undefined/null170 return;171 }172 if (reaction.emoji.name === 'ð' && reaction.message.member.id === '276804557055721483') {173 console.log('if statemnet passed');174 reaction.message.channel.send('Good man yourself, keep downvoting Mark');175 } else {176 }177 }178});179client.on('message', async msg => {180 if (memes.has(msg.content)) {181 const meme = memes.get(msg.content);182 if (meme && meme.fileNames && meme.fileNames.length > 0) {183 let random = meme.fileNames.length === 1 ? 0 : Math.floor(Math.random() * meme.fileNames.length);184 if (!msg.member.voice.channel) {185 msg.channel.send('Go into a channel to hear this meme.');186 } else {187 await msg.member.voice.channel188 .join()189 .then(connection => {190 const dispatcher = connection.play(191 `audio folder1/${meme.fileNames[random]}`,192 { volume: meme.volume ? meme.volume : 0.6 },193 { highWaterMark: 50 }194 );195 dispatcher.on('finish', () => connection.disconnect());196 })197 .catch(e => {198 console.error(e);199 });200 }201 }202 }203 204});205client.on('message', async msg => {206 // Downvotes Mark207 if (msg.member.id === '276804557055721483') {208 msg.react('ð');209 }210 if (msg.member.id === '270185954789031936') {211 msg.react('ð¤¡');212 }213 if (msg.member.id === '184793319014924289') {214 msg.react('ð¤¡');215 }216 if (msg.member.id === '140845637636718595') {217 // Upvotes Mac218 msg.react('ð');219 }220 if (msg.member.id === '378702852786356224') {221 // Rat Emojis eddy222 msg.react('ð');223 }224 if (msg.content === 'is edd a rat') {225 // simple string sent to channel on condition226 msg.channel.send('I see absolutely no difference between edd and Stuart Little');227 }228 if (msg.content === 'start intro' && msg.member.id === '140845637636718595') {229 // changes boolean which is required to play intro music, also sends a message with their username.230 macIntro = true;231 if (msg.member.nickname === null) {232 msg.channel.send(`${msg.member.displayName} has turned their intro on..`);233 } else {234 msg.channel.send(`${msg.member.nickname} has their intro on..`);235 }236 }237 if (msg.content === 'stop intro' && msg.member.id === '140845637636718595') {238 macIntro = false;239 if (msg.member.nickname === null) {240 msg.channel.send(`${msg.member.displayName} has their intro turned off.`);241 } else {242 msg.channel.send(`${msg.member.nickname} has their intro turned off.`);243 }244 }245 if (msg.content === 'start intro' && msg.member.id === '140845637636718595') {246 // changes boolean which is required to play intro music, also sends a message with their username.247 macIntro = true;248 if (msg.member.nickname === null) {249 msg.channel.send(`${msg.member.displayName} has turned their intro on..`);250 } else {251 msg.channel.send(`${msg.member.nickname} has their intro on..`);252 }253 }254 if (msg.content === 'stop intro' && msg.member.id === '140845637636718595') {255 macIntro = false;256 if (msg.member.nickname === null) {257 msg.channel.send(`${msg.member.displayName} has their intro turned off.`);258 } else {259 msg.channel.send(`${msg.member.nickname} has their intro turned off.`);260 }261 }262 if (msg.content === 'is bray a shithole') {263 msg.channel.send('yes, bray is shit.');264 }265});...
dawn-like.ts
Source:dawn-like.ts
1import { EntityAnimationGroup } from 'src/domain/entity-animation';2export function dawnLike(): Map<string, EntityAnimationGroup> {3 const groups: Map<string, EntityAnimationGroup> = new Map();4 const playerFilenames = ['Player0.png', 'Player1.png'];5 // Row 06 groups.set('dl-player-0-0', genGroup(0, 0, playerFilenames, 'dl-player-0-0'));7 groups.set('dl-player-1-0', genGroup(1, 0, playerFilenames, 'dl-player-1-0'));8 groups.set('dl-player-2-0', genGroup(2, 0, playerFilenames, 'dl-player-2-0'));9 groups.set('dl-player-3-0', genGroup(3, 0, playerFilenames, 'dl-player-3-0'));10 groups.set('dl-player-4-0', genGroup(4, 0, playerFilenames, 'dl-player-4-0'));11 groups.set('dl-player-5-0', genGroup(5, 0, playerFilenames, 'dl-player-5-0'));12 groups.set('dl-player-6-0', genGroup(6, 0, playerFilenames, 'dl-player-6-0'));13 groups.set('dl-player-7-0', genGroup(7, 0, playerFilenames, 'dl-player-7-0'));14 // Row 115 groups.set('dl-player-0-1', genGroup(0, 1, playerFilenames, 'dl-player-0-1'));16 groups.set('dl-player-1-1', genGroup(1, 1, playerFilenames, 'dl-player-1-1'));17 groups.set('dl-player-2-1', genGroup(2, 1, playerFilenames, 'dl-player-2-1'));18 groups.set('dl-player-3-1', genGroup(3, 1, playerFilenames, 'dl-player-3-1'));19 groups.set('dl-player-4-1', genGroup(4, 1, playerFilenames, 'dl-player-4-1'));20 groups.set('dl-player-5-1', genGroup(5, 1, playerFilenames, 'dl-player-5-1'));21 groups.set('dl-player-6-1', genGroup(6, 1, playerFilenames, 'dl-player-6-1'));22 groups.set('dl-player-7-1', genGroup(7, 1, playerFilenames, 'dl-player-7-1'));23 // Row 2 (blank)24 // Row 325 groups.set('dl-player-0-3', genGroup(0, 3, playerFilenames, 'dl-player-0-3'));26 groups.set('dl-player-1-3', genGroup(1, 3, playerFilenames, 'dl-player-1-3'));27 groups.set('dl-player-2-3', genGroup(2, 3, playerFilenames, 'dl-player-2-3'));28 groups.set('dl-player-3-3', genGroup(3, 3, playerFilenames, 'dl-player-3-3'));29 groups.set('dl-player-4-3', genGroup(4, 3, playerFilenames, 'dl-player-4-3'));30 groups.set('dl-player-5-3', genGroup(5, 3, playerFilenames, 'dl-player-5-3'));31 groups.set('dl-player-6-3', genGroup(6, 3, playerFilenames, 'dl-player-6-3'));32 groups.set('dl-player-7-3', genGroup(7, 3, playerFilenames, 'dl-player-7-3'));33 // Row 434 groups.set('dl-player-0-4', genGroup(0, 4, playerFilenames, 'dl-player-0-4'));35 groups.set('dl-player-1-4', genGroup(1, 4, playerFilenames, 'dl-player-1-4'));36 groups.set('dl-player-2-4', genGroup(2, 4, playerFilenames, 'dl-player-2-4'));37 groups.set('dl-player-3-4', genGroup(3, 4, playerFilenames, 'dl-player-3-4'));38 groups.set('dl-player-4-4', genGroup(4, 4, playerFilenames, 'dl-player-4-4'));39 groups.set('dl-player-5-4', genGroup(5, 4, playerFilenames, 'dl-player-5-4'));40 groups.set('dl-player-6-4', genGroup(6, 4, playerFilenames, 'dl-player-6-4'));41 groups.set('dl-player-7-4', genGroup(7, 4, playerFilenames, 'dl-player-7-4'));42 // Row 543 groups.set('dl-player-0-5', genGroup(0, 5, playerFilenames, 'dl-player-0-5'));44 groups.set('dl-player-1-5', genGroup(1, 5, playerFilenames, 'dl-player-1-5'));45 groups.set('dl-player-2-5', genGroup(2, 5, playerFilenames, 'dl-player-2-5'));46 // Row 6 (blank)47 // Row 748 groups.set('dl-player-0-7', genGroup(0, 7, playerFilenames, 'dl-player-0-7'));49 groups.set('dl-player-1-7', genGroup(1, 7, playerFilenames, 'dl-player-1-7'));50 groups.set('dl-player-2-7', genGroup(2, 7, playerFilenames, 'dl-player-2-7'));51 groups.set('dl-player-3-7', genGroup(3, 7, playerFilenames, 'dl-player-3-7'));52 groups.set('dl-player-4-7', genGroup(4, 7, playerFilenames, 'dl-player-4-7'));53 groups.set('dl-player-5-7', genGroup(5, 7, playerFilenames, 'dl-player-5-7'));54 groups.set('dl-player-6-7', genGroup(6, 7, playerFilenames, 'dl-player-6-7'));55 groups.set('dl-player-7-7', genGroup(7, 7, playerFilenames, 'dl-player-7-7'));56 // Row 857 groups.set('dl-player-0-8', genGroup(0, 8, playerFilenames, 'dl-player-0-8'));58 groups.set('dl-player-1-8', genGroup(1, 8, playerFilenames, 'dl-player-1-8'));59 groups.set('dl-player-2-8', genGroup(2, 8, playerFilenames, 'dl-player-2-8'));60 groups.set('dl-player-3-8', genGroup(3, 8, playerFilenames, 'dl-player-3-8'));61 groups.set('dl-player-4-8', genGroup(4, 8, playerFilenames, 'dl-player-4-8'));62 groups.set('dl-player-5-8', genGroup(5, 8, playerFilenames, 'dl-player-5-8'));63 groups.set('dl-player-6-8', genGroup(6, 8, playerFilenames, 'dl-player-6-8'));64 groups.set('dl-player-7-8', genGroup(7, 8, playerFilenames, 'dl-player-7-8'));65 // Row 9 (blank)66 // Row 10 (blank)67 // Row 1168 groups.set('dl-player-0-11', genGroup(0, 11, playerFilenames, 'dl-player-0-11'));69 groups.set('dl-player-1-11', genGroup(1, 11, playerFilenames, 'dl-player-1-11'));70 groups.set('dl-player-2-11', genGroup(2, 11, playerFilenames, 'dl-player-2-11'));71 groups.set('dl-player-3-11', genGroup(3, 11, playerFilenames, 'dl-player-3-11'));72 groups.set('dl-player-4-11', genGroup(4, 11, playerFilenames, 'dl-player-4-11'));73 groups.set('dl-player-5-11', genGroup(5, 11, playerFilenames, 'dl-player-5-11'));74 groups.set('dl-player-6-11', genGroup(6, 11, playerFilenames, 'dl-player-6-11'));75 groups.set('dl-player-7-11', genGroup(7, 11, playerFilenames, 'dl-player-7-11'));76 // Row 1277 groups.set('dl-player-0-12', genGroup(0, 12, playerFilenames, 'dl-player-0-12'));78 groups.set('dl-player-1-12', genGroup(1, 12, playerFilenames, 'dl-player-1-12'));79 groups.set('dl-player-2-12', genGroup(2, 12, playerFilenames, 'dl-player-2-12'));80 groups.set('dl-player-3-12', genGroup(3, 12, playerFilenames, 'dl-player-3-12'));81 groups.set('dl-player-4-12', genGroup(4, 12, playerFilenames, 'dl-player-4-12'));82 groups.set('dl-player-5-12', genGroup(5, 12, playerFilenames, 'dl-player-5-12'));83 groups.set('dl-player-6-12', genGroup(6, 12, playerFilenames, 'dl-player-6-12'));84 groups.set('dl-player-7-12', genGroup(7, 12, playerFilenames, 'dl-player-7-12'));85 // Row 1386 groups.set('dl-player-0-13', genGroup(0, 13, playerFilenames, 'dl-player-0-13'));87 groups.set('dl-player-1-13', genGroup(1, 13, playerFilenames, 'dl-player-1-13'));88 // Row 1489 groups.set('dl-player-0-12', genGroup(0, 14, playerFilenames, 'dl-player-0-12'));90 groups.set('dl-player-1-12', genGroup(1, 14, playerFilenames, 'dl-player-1-12'));91 groups.set('dl-player-2-12', genGroup(2, 14, playerFilenames, 'dl-player-2-12'));92 groups.set('dl-player-3-12', genGroup(3, 14, playerFilenames, 'dl-player-3-12'));93 groups.set('dl-player-4-12', genGroup(4, 14, playerFilenames, 'dl-player-4-12'));94 groups.set('dl-player-5-12', genGroup(5, 14, playerFilenames, 'dl-player-5-12'));95 groups.set('dl-player-6-12', genGroup(6, 14, playerFilenames, 'dl-player-6-12'));96 groups.set('dl-player-7-12', genGroup(7, 14, playerFilenames, 'dl-player-7-12'));97 return groups;98}99/**100 * Should match the structure of *.json files.101 */102function genGroup(xoff: number, yoff: number, filenames: string[], name: string): EntityAnimationGroup {103 return new EntityAnimationGroup(name, {104 animations: genRawAnimations(xoff, yoff),105 filenames,106 });107}108/**109 * Should match the structure of the *.json files.110 */111function genRawAnimations(xoff: number, yoff: number): any[] {112 const walkDelay = 250;113 const runDelay = 125;114 const rawAnimations: any[] = [];115 rawAnimations.push(116 genRawAnimation(117 'default', 'default',118 [119 genRawFrame(0, xoff, yoff), // Same as stand-left.120 ],121 ),122 );123 rawAnimations.push(124 genRawAnimation(125 'stand-left', 'stand-left',126 [127 genRawFrame(0, xoff, yoff),128 ],129 ),130 );131 rawAnimations.push(132 genRawAnimation(133 'stand-right', 'stand-right',134 [135 genRawFrame(0, xoff, yoff, null, true),136 ],137 ),138 );139 rawAnimations.push(140 genRawAnimation(141 'walk-left', 'walk-left',142 [143 genRawFrame(0, xoff, yoff, walkDelay),144 genRawFrame(1, xoff, yoff, walkDelay),145 ],146 ),147 );148 rawAnimations.push(149 genRawAnimation(150 'walk-right', 'walk-right',151 [152 genRawFrame(0, xoff, yoff, walkDelay, true),153 genRawFrame(1, xoff, yoff, walkDelay, true),154 ],155 ),156 );157 rawAnimations.push(158 genRawAnimation(159 'run-left', 'run-left',160 [161 genRawFrame(0, xoff, yoff, runDelay),162 genRawFrame(1, xoff, yoff, runDelay),163 ],164 ),165 );166 rawAnimations.push(167 genRawAnimation(168 'run-right', 'run-right',169 [170 genRawFrame(0, xoff, yoff, runDelay, true),171 genRawFrame(1, xoff, yoff, runDelay, true),172 ],173 ),174 );175 return rawAnimations;176}177/**178 * Should match the structure of the *.json files.179 */180function genRawAnimation(name: string, next: string, rawFrames: any[]) {181 return {182 frames: rawFrames,183 name,184 next,185 };186}187/**188 * Should match the structure of the *.json files.189 */190function genRawFrame(191 imageIndex: number,192 x: number,193 y: number,194 delay?: number,195 flipped?: boolean,196): any {197 const rawFrame: any = { imageIndex, x, y };198 if (delay) {199 rawFrame.delay = delay;200 }201 if (flipped) {202 rawFrame.flipped = flipped;203 }204 return rawFrame;...
mv-controller.js
Source:mv-controller.js
1'use strict';2const DefaultParser = require('./mv-parser');3const DefaultRenamer = require('./mv-renamer');4const DefaultMover = require('./mv-mover');5/**6 * Creates a mv-controller object that moves files on file system using glob patterns.7 * @param [parser] {Object} Object with a resolve(glob) method where:8 * 'glob' is a string.9 * @param [renamer] {Object} Object with a computeName(names, srcGlob, dstGlob) method where:10 * 'names': array of strings11 * 'srcGlob': string12 * 'dstGlob': string13 * @param [mover] {Object} Object with a commit(oldNames, newNames, callback) method where:14 * 'oldNames': array of strings15 * 'newNames': array of strings16 * 'callback': function17 * @return {Object} A mv-controller object18 */19function createController(parser, renamer, mover) {20 let _parser = null;21 let _renamer = null;22 let _mover = null;23 function _fetchFilenames(glob) {24 return _parser.resolve(glob);25 }26 function _buildNewFilenames(filenames, srcGlob, dstGlob) {27 return _renamer.computeName(filenames, srcGlob, dstGlob);28 }29 function _moveFiles(oldFilenames, newFilenames, callback) {30 callback = typeof callback === 'function' ? callback : null;31 return _mover.commit(oldFilenames, newFilenames, null, callback);32 }33 function _moveFilesAsync(oldNames, newNames) {34 return _mover.commitAsync(oldNames, newNames);35 }36 function _prepParams(src, dst) {37 if (typeof src !== 'string' || typeof dst !== 'string' || !src.length || !dst.length) {38 throw new TypeError("Invalid arguments. Glob patterns must be non-empty strings.");39 }40 // Normalize the path separators:41 // 1. If on Windows, then convert Windows path separators to posix separator42 // This is required for consistency because the glob module we rely on always uses posix separator.43 // 2. Collapse multiple '/' into a single one.44 let srcPattern = (process.platform === 'win32') ? src.replace(/\\/g, '/').replace(/\/+/g, '/') : src.replace(/\/+/g, '/');45 let dstPattern = (process.platform === 'win32') ? dst.replace(/\\/g, '/').replace(/\/+/g, '/') : dst.replace(/\/+/g, '/');46 // Removing trailing '/' to work around an inconsistency with fs.renameSync(), which is used in mv-mover module.47 // On Windows, renaming to 'filename.ext/' would succeed and filename.ext (without trailing '/') would be created.48 // On MacOS, such operation would fail with an Error: ENOENT: no such file or directory49 dstPattern = dstPattern.endsWith('/') ? dstPattern.slice(0, -1) : dstPattern;50 return {51 srcPattern,52 dstPattern,53 }54 }55 /**56 * Injects parser, renamer and mover objects into the mv-controller object.57 * @method init58 * @param p {Object} parser59 * @param r {Object} renamer60 * @param m {Object} mover61 */62 function init(p, r, m) {63 _parser = p || _parser;64 _renamer = r || _renamer;65 _mover = m || _mover;66 }67 /**68 * Moves files on file system.69 * @method exec70 * @param src {String} Glob pattern specifying files to move71 * @param dst {String} Glob pattern characterizing the new names72 * @param [cb] {Function} Function to be invoked after each move attempt; callback arguments: error, oldName, newName, index.73 * @return {Number | null} Number of successful move operations. Null if no source file found.74 * @throws {Error} An Error object75 */76 function exec(src, dst, cb) {77 let newFilenames = [];78 let successList = [];79 let returnVal;80 const { srcPattern, dstPattern } = _prepParams(src, dst);81 const filenames = _fetchFilenames(srcPattern);82 if (filenames.length) {83 newFilenames = _buildNewFilenames(filenames, srcPattern, dstPattern);84 successList = _moveFiles(filenames, newFilenames, cb);85 returnVal = successList.length;86 }87 else {88 returnVal = null;89 }90 return returnVal;91 }92 /**93 * Moves files on file system. This is the async version of exec().94 * The returned Promise resolves to the number of files moved.95 * Any error during the operation results in returned Promise rejecting to an array containing Error for each failed move attempt.96 * @method execAsync97 * @param src {String} Glob pattern specifying files to move98 * @param dst {String} Glob pattern characterizing the new names99 * @return {Promise}100 */101 function execAsync(src, dst) {102 let newFilenames = [];103 let returnVal;104 try {105 const { srcPattern, dstPattern } = _prepParams(src, dst);106 const filenames = _fetchFilenames(srcPattern);107 if (filenames.length) {108 newFilenames = _buildNewFilenames(filenames, srcPattern, dstPattern);109 returnVal = _moveFilesAsync(filenames, newFilenames);110 }111 else {112 returnVal = Promise.reject([new Error('No file found.')]) ;113 }114 }115 catch (err) {116 returnVal = Promise.reject([err]);117 }118 return returnVal;119 }120 _parser = parser || DefaultParser.create();121 _renamer = renamer || DefaultRenamer.create();122 _mover = mover || DefaultMover.create();123 return {124 exec,125 execAsync,126 init,127 };128}...
board.main.test.js
Source:board.main.test.js
1/* global describe it */2const fs = require('fs')3const path = require('path')4const boardModel = require('../../src/js/models/board')5const assert = require('assert')6const fixturesPath = path.join(__dirname, '..', 'fixtures')7const scene = JSON.parse(8 fs.readFileSync(9 path.join(fixturesPath, 'audio', 'audio.storyboarder')10 )11)12const shotGeneratorScene = JSON.parse(13 fs.readFileSync(14 path.join(fixturesPath, 'shot-generator', 'shot-generator.storyboarder')15 )16)17describe('boardModel', () => {18 describe('#getMediaDescription', () => {19 describe('when reading from scene data', () => {20 let board = scene.boards[0]21 let media = boardModel.getMediaDescription(board)22 it('lists media files', () => {23 assert(media.layers.reference.length)24 assert(media.layers.notes.length)25 assert(media.audio.length)26 assert(media.link === board.link)27 })28 it('excludes board.url', () => {29 assert(media.url == null)30 })31 it('includes link if present', () => {32 let boardWithLink = {33 ...board,34 link: 'board.psd'35 }36 let boardWithLinkMedia = boardModel.getMediaDescription(boardWithLink)37 assert(boardWithLinkMedia.link.length)38 assert(boardWithLinkMedia.link === boardWithLink.link)39 })40 it('does not include sg key for non-shot generator boards', () => {41 let board = scene.boards[0]42 let media = boardModel.getMediaDescription(board)43 assert(media.sg == null)44 })45 it('includes sg key for shot generator boards', () => {46 let board = shotGeneratorScene.boards[0]47 let media = boardModel.getMediaDescription(board)48 assert(media.sg != null)49 })50 })51 describe('edge cases', () => {52 // for old iPad app boards53 it('can handle a missing layers object', () => {54 let board = {55 ...scene.boards[0],56 layers: undefined57 }58 let media = boardModel.getMediaDescription(board)59 assert(Object.keys(media.layers).length === 0)60 })61 it('can handle a blank layers object', () => {62 let board = {63 ...scene.boards[0],64 layers: {}65 }66 let media = boardModel.getMediaDescription(board)67 assert(Object.keys(media.layers).length === 0)68 })69 })70 })71 describe('#getMediaFilenames', () => {72 describe('when reading from scene data', () => {73 let board = scene.boards[0]74 let filenames = boardModel.getMediaFilenames(board)75 it('lists media files', () => {76 assert(filenames.length === 5)77 assert(filenames.includes('board-1-1ABCD-reference.png'))78 assert(filenames.includes('1ABCD-audio-1234567890000.wav'))79 })80 it('includes sg files for shot generator boards', () => {81 let board = shotGeneratorScene.boards[0]82 let filenames = boardModel.getMediaFilenames(board)83 assert(filenames.includes('board-1-UDRF3-camera-plot.png'))84 })85 })86 describe('edge cases', () => {87 // for old iPad app boards88 it('can handle a missing layers object', () => {89 let board = {90 ...scene.boards[0],91 layers: undefined92 }93 let filenames = boardModel.getMediaFilenames(board)94 assert(filenames.length === 3)95 assert(!filenames.includes('board-1-1ABCD-reference.png'))96 })97 it('can handle a blank layers object', () => {98 let board = {99 ...scene.boards[0],100 layers: {}101 }102 let filenames = boardModel.getMediaFilenames(board)103 assert(filenames.length === 3)104 assert(!filenames.includes('board-1-1ABCD-reference.png'))105 })106 })107 })108 describe('shot generator layer and thumbnail', () => {109 const scene = JSON.parse(110 fs.readFileSync(111 path.join(fixturesPath, 'shot-generator', 'shot-generator.storyboarder')112 )113 )114 const board = scene.boards[0]115 describe('#getMediaDescription', () => {116 let media = boardModel.getMediaDescription(board)117 it('includes layerThumbnails', () => {118 assert(media.layerThumbnails['shot-generator'].length)119 })120 })121 describe('#getMediaFilenames', () => {122 let filenames = boardModel.getMediaFilenames(board)123 it('includes shot-generator layer thumbnail', () => {124 assert(125 filenames.includes('board-1-UDRF3-shot-generator-thumbnail.jpg'),126 'thumbnail should exist'127 )128 })129 })130 })...
contractDiff.js
Source:contractDiff.js
1const fs = require("fs");2const chalk = require("chalk");3const diff = require("diff");4function readFileSync(filename) {5 return fs.readFileSync(filename, "utf8");6}7function getFilenamesFromCode(code) {8 // find all lines with prefix "// File:"9 const filenames = code.match(/\/\/\s*File:\s*\S+\n/gi);10 for (let i = 0; i < filenames.length; i++) {11 // remove prefix "// File: ".12 filenames[i] = filenames[i].replace(/\/\/\s*File:\s*/i, "");13 filenames[i] = filenames[i].replace(/\s+/i, "");14 // directory openzeppelin-solidity is inside node_modules15 if (filenames[i].match(/openzeppelin-solidity/)) {16 filenames[i] = "node_modules/" + filenames[i];17 }18 // directory zos-lib is inside node_modules19 if (filenames[i].match(/zos-lib/)) {20 filenames[i] = "node_modules/" + filenames[i];21 }22 // add ./ prefix23 filenames[i] = "./" + filenames[i];24 console.log(filenames[i]);25 }26 return filenames;27}28function createCodeFile(filenames) {29 let code = "";30 for (let i = 0; i < filenames.length; i++) {31 try {32 console.log("Reading file " + filenames[i]);33 } catch (err) {34 console.log("Could not read file " + filenames[i]);35 return "";36 }37 code = code + readFileSync(filenames[i]) + "\n";38 }39 return code;40}41function diffText(code1, code2) {42 const diffOutput = diff.diffTrimmedLines(code1, code2);43 for (let i = 0; i < diffOutput.length; i++) {44 const diffLine = diffOutput[i];45 if (diffLine.added) {46 process.stdout.write(chalk.green(`+ ${diffLine.value}`));47 } else if (diffLine.removed) {48 process.stdout.write(chalk.red(`- ${diffLine.value}`));49 }50 }51}52function removeExtraComments(code) {53 const modified = code.replace(/\/\/\s*File:\s*\S+\n/gi, "");54 return modified;55}56function validate(filename) {57 let code = readFileSync(filename);58 const filenames = getFilenamesFromCode(code);59 const expectedCode = createCodeFile(filenames);60 code = removeExtraComments(code);61 diffText(code, expectedCode);62}63function printUsage() {64 console.log("node contractDiff <file1> <file2> .... <fileN>");65}66function main() {67 if (process.argv.length < 3) {68 printUsage();69 return;70 }71 let fail = 0;72 const total = process.argv.length - 2;73 let goodFiles = "";74 let badFiles = "";75 for (let i = 2; i < process.argv.length; i++) {76 const filename = process.argv[i];77 console.log("Checking: " + filename);78 try {79 validate(filename);80 goodFiles = goodFiles + filename + "\n";81 } catch (err) {82 console.log("Error validating file " + filename);83 console.log(err.msg);84 badFiles = badFiles + filename + "\n";85 ++fail;86 }87 }88 if (total - fail > 0) {89 process.stdout.write(90 chalk.green("\n\nSuccessfully processed " + (total - fail) + " files.\n")91 );92 process.stdout.write(chalk.green(goodFiles));93 }94 if (fail > 0) {95 process.stdout.write(96 chalk.red("\n\nFailed to process " + fail + " files.\n")97 );98 process.stdout.write(chalk.red(badFiles + "\n"));99 }100}...
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var sync = false;5reporter.addAll(['text-summary', 'html']);6collector.add(global.__coverage__);7reporter.write(collector, sync, function () {8 console.log('All reports generated');9});10{11 "scripts": {12 },13 "devDependencies": {14 }15}16Statements : 0% ( 0/0 )17Branches : 0% ( 0/0 )18Functions : 0% ( 0/0 )19Lines : 0% ( 0/0 )20var assert = require('assert');21describe('Array', function() {22 describe('#indexOf()', function() {
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var sync = false;5var fileNames = collector.getFinalCoverage().fileNames();6console.log(fileNames);
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var reportOpts = { dir: 'coverage' };5collector.add(istanbul.utils.summarizeCoverage(istanbul.utils6 .loadCoverage('coverage/coverage.json')));7reporter.add(reportType);8reporter.write(collector, sync, reportOpts);
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var sync = false;5var coverage = require('./coverage/coverage.json');6collector.add(coverage);7reporter.add('html');8reporter.addAll(['lcov', 'json']);9reporter.write(collector, sync, function () {10 console.log('All reports generated');11});12var istanbul = require('istanbul');13var collector = new istanbul.Collector();14var reporter = new istanbul.Reporter();15var sync = false;16var coverage = require('./coverage/coverage.json');17collector.add(coverage);18reporter.add('html');19reporter.addAll(['lcov', 'json']);20reporter.write(collector, sync, function () {21 console.log('All reports generated');22});23var istanbul = require('istanbul');24var collector = new istanbul.Collector();25var reporter = new istanbul.Reporter();26var sync = false;27var coverage = require('./coverage/coverage.json');28collector.add(coverage);29reporter.add('html');30reporter.addAll(['lcov', 'json']);31reporter.write(collector, sync, function () {32 console.log('All reports generated');33});34var istanbul = require('istanbul');35var collector = new istanbul.Collector();36var reporter = new istanbul.Reporter();37var sync = false;38var coverage = require('./coverage/coverage.json');39collector.add(coverage);40reporter.add('html');41reporter.addAll(['lcov', 'json']);42reporter.write(collector, sync, function () {43 console.log('All reports generated');44});45var istanbul = require('istanbul');46var collector = new istanbul.Collector();47var reporter = new istanbul.Reporter();
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4var reports = ['text-summary'];5var fileNames = collector.getFinalCoverage().fileNames();6console.log(fileNames);7reporter.addAll(reports);8reporter.write(collector, sync, function () {9 console.log('All reports generated');10});11var istanbul = require('istanbul');12var collector = new istanbul.Collector();13var reporter = new istanbul.Reporter();14var reports = ['text-summary'];15var fileNames = collector.getFinalCoverage().fileNames();16console.log(fileNames);17reporter.addAll(reports);18reporter.write(collector, sync, function () {19 console.log('All reports generated');20});21var istanbul = require('istanbul');22var collector = new istanbul.Collector();23var reporter = new istanbul.Reporter();24var reports = ['text-summary'];25var fileNames = collector.getFinalCoverage().fileNames();26console.log(fileNames);27reporter.addAll(reports
Using AI Code Generation
1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3collector.add(istanbul.utils.summarizeCoverage(__coverage__));4var fileNames = collector.getFinalCoverage().map(function (coverage) {5 return coverage.path;6});7console.log(fileNames);8coverageReporter: {9}
Using AI Code Generation
1const istanbul = require('istanbul-api');2const report = istanbul.libReport.create('json');3const istanbulUtils = istanbul.libReport.utils;4const files = istanbulUtils.summarizers.files(istanbulUtils.loadCoverage('coverage/coverage-final.json'));5report.writeReport(files, true);6{7 "scripts": {8 },9 "devDependencies": {
Using AI Code Generation
1const istanbul = require('istanbul-api');2const mapStore = istanbul.libReport.create('json');3const tree = istanbul.libReport.summarizers.pkg(mapStore);4const context = istanbul.libReport.createContext({5});6tree.visit(context, {});7const files = mapStore.mapStore.files;8const istanbul = require('istanbul-api');9const mapStore = istanbul.libReport.create('json');10const tree = istanbul.libReport.summarizers.pkg(mapStore);11const context = istanbul.libReport.createContext({12});13tree.visit(context, {});14const files = mapStore.mapStore.files;15const istanbul = require('istanbul-api');16const mapStore = istanbul.libReport.create('json');17const tree = istanbul.libReport.summarizers.pkg(mapStore);18const context = istanbul.libReport.createContext({19});20tree.visit(context, {});21const files = mapStore.mapStore.files;22const istanbul = require('istanbul-api');23const mapStore = istanbul.libReport.create('json');24const tree = istanbul.libReport.summarizers.pkg(mapStore);25const context = istanbul.libReport.createContext({26});27tree.visit(context, {});28const files = mapStore.mapStore.files;29const istanbul = require('istanbul-api');30const mapStore = istanbul.libReport.create('json');31const tree = istanbul.libReport.summarizers.pkg(mapStore);32const context = istanbul.libReport.createContext({33});34tree.visit(context, {});35const files = mapStore.mapStore.files;
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!!