Best JavaScript code snippet using ava
wyweb.js
Source:wyweb.js
1'use strict';2function wyweb$compiler$Request$BBBQ6stringaQ6string$Q7Request(verify, check, counterexamples, code, deps) {3 return new Wy.Record({code: Wy.copy(code), verify: verify, counterexamples: counterexamples, quickcheck: check, dependencies: Wy.copy(deps)});4}5const wyweb$main$EG_NAMES$static = ["", "Hello World", "Absolute", "IndexOf"];6const wyweb$main$EG_TEXT$static = ["", "import std::io\nimport std::ascii\n\nmethod main():\n io::println(\"hello world\")", "function abs(int x) -> (int r)\nensures r >= 0\nensures (r == x) || (r == -x):\n //\n if x >= 0:\n return x\n else:\n return -x", "type nat is (int x) where x >= 0\n\nfunction indexOf(int[] items, int item) -> (int r)\n// If valid index returned, element matches item\nensures r >= 0 ==> items[r] == item\n// If invalid index return, no element matches item\nensures r < 0 ==> all { i in 0..|items| | items[i] != item }\n// Return value is between -1 and size of items\nensures r >= -1 && r < |items|:\n //\n nat i = 0\n while i < |items|\n where all { k in 0 .. i | items[k] != item }:\n // \n if items[i] == item:\n return i\n i = i + 1\n //\n return -1"];7const wyweb$main$READY$static = 0;8const wyweb$main$READY_RUN$static = 1;9const wyweb$main$COMPILING$static = 2;10const wyweb$main$SUCCESS$static = 3;11const wyweb$main$ERROR$static = 4;12const wyweb$main$FAILURE$static = 5;13function wyweb$main$toggle_verification$Q10MouseEventQ5State$Q5StateaQ6Action(e, s) {14 let as;15 let sp;16 {17 const $0 = !s.verification;18 s.verification = $0;19 }20 return [Wy.copy(s), []];21}22function wyweb$main$toggle_check$Q10MouseEventQ5State$Q5StateaQ6Action(e, s) {23 let as;24 let sp;25 {26 const $1 = !s.check;27 s.check = $1;28 }29 return [Wy.copy(s), []];30}31function wyweb$main$toggle_counterexamples$Q10MouseEventQ5State$Q5StateaQ6Action(e, s) {32 let as;33 let sp;34 {35 const $2 = !s.counterexamples;36 s.counterexamples = $2;37 }38 return [Wy.copy(s), []];39}40function wyweb$main$toggle_javascript$Q10MouseEventQ5State$Q5StateaQ6Action(e, s) {41 let as;42 let sp;43 {44 const $3 = !s.javascript;45 s.javascript = $3;46 }47 return [Wy.copy(s), []];48}49function wyweb$main$load_example$Q10MouseEventQ5State$Q5StateaQ6Action(e, s) {50 let as;51 let sp;52 return [Wy.copy(s), [web$io$call$mQ3dom6WindowV$Q6Action(function() {53 return function(w) {54 return wyweb$main$set_editor_text$Q3dom6Window$V(w);55 };56 }())]];57}58function wyweb$main$compile_clicked$Q10MouseEventQ5State$Q5StateaQ6Action(e, s) {59 let as;60 let sp;61 s.state = wyweb$main$COMPILING$static;62 return [Wy.copy(s), [web$io$query$Q5queryQ8consumer$Q6Action(wyweb$main$get_editor_text$Q3dom6Window$Q6string, wyweb$main$compile_begin$Q5StateQ6string$Q5StateaQ6Action), web$io$call$mQ3dom6WindowV$Q6Action(wyweb$main$save_current_state$Q3dom6Window$V)]];63}64function wyweb$main$compile_begin$Q5StateQ6string$Q5StateaQ6Action(s, text) {65 let as;66 let sp;67 let cr = wyweb$compiler$Request$BBBQ6stringaQ6string$Q7Request(s.verification, s.check, s.counterexamples, Wy.copy(text), Wy.copy(s.dependencies));68 let r = js$JSON$stringify(Wy.copy(cr));69 return [Wy.copy(s), [web$io$post$Q6stringQ6stringQ8consumerQ7handler$Q6Action("/compile", Wy.copy(r), wyweb$main$compile_success$Q5StateQ6string$Q5StateaQ6Action, wyweb$main$compile_error$Q5State$Q5StateaQ6Action)]];70}71function wyweb$main$compile_success$Q5StateQ6string$Q5StateaQ6Action(s, response) {72 let as;73 let sp;74 let cr = js$JSON$parse(Wy.copy(response));75 if(Wy.equals(cr.result, Wy.toString("success"))) {76 Wy.assert(is$Q8compiler8Responser2Q6string6resultQ6string2js(cr));77 s.state = wyweb$main$SUCCESS$static;78 s.binary = Wy.copy(cr.js);79 return [Wy.copy(s), [web$io$call$mQ3dom6WindowV$Q6Action(function(s) {80 return function(w) {81 return wyweb$main$clear_editor_markers$Q3dom6WindowaQ4uint$V(w, Wy.copy(s.markers));82 };83 }(s)), web$io$timeout$Q4uintQ7handler$Q6Action(1000, wyweb$main$compile_readyrun$Q5State$Q5StateaQ6Action)]];84 } else {85 if(Wy.equals(cr.result, Wy.toString("errors"))) {86 Wy.assert(is$Q8compiler8Responser2Q6string6resultaQ5Error6errors(cr));87 s.state = wyweb$main$ERROR$static;88 return [Wy.copy(s), [web$io$call$mQ3dom6WindowV$Q6Action(function(s) {89 return function(w) {90 return wyweb$main$clear_editor_markers$Q3dom6WindowaQ4uint$V(w, Wy.copy(s.markers));91 };92 }(s)), web$io$query$Q5queryQ8consumer$Q6Action(function(cr) {93 return function(w) {94 return wyweb$main$set_editor_markers$Q3dom6WindowaQ8compiler5Error$aQ4uint(w, Wy.copy(cr.errors));95 };96 }(cr), wyweb$main$compile_failure$Q5StateaQ4uint$Q5StateaQ6Action), web$io$timeout$Q4uintQ7handler$Q6Action(1000, wyweb$main$compile_ready$Q5State$Q5StateaQ6Action)]];97 } else {98 Wy.assert(is$Q8compiler8Responser2Q6string6resultQ6string4text(cr));99 s.state = wyweb$main$FAILURE$static;100 s.error = Wy.copy(cr.text);101 return [Wy.copy(s), [web$io$timeout$Q4uintQ7handler$Q6Action(1000, wyweb$main$compile_ready$Q5State$Q5StateaQ6Action)]];102 }103 }104}105function wyweb$main$compile_failure$Q5StateaQ4uint$Q5StateaQ6Action(s, markers) {106 let as;107 let sp;108 s.markers = Wy.copy(markers);109 return [Wy.copy(s), []];110}111function wyweb$main$compile_error$Q5State$Q5StateaQ6Action(s) {112 let as;113 let sp;114 s.state = wyweb$main$ERROR$static;115 return [Wy.copy(s), [web$io$timeout$Q4uintQ7handler$Q6Action(1000, wyweb$main$compile_ready$Q5State$Q5StateaQ6Action)]];116}117function wyweb$main$compile_readyrun$Q5State$Q5StateaQ6Action(s) {118 let as;119 let sp;120 s.state = wyweb$main$READY_RUN$static;121 return [Wy.copy(s), []];122}123function wyweb$main$compile_ready$Q5State$Q5StateaQ6Action(s) {124 let as;125 let sp;126 s.state = wyweb$main$READY$static;127 return [Wy.copy(s), []];128}129function wyweb$main$view$Q5State$Q4Node(s) {130 let editor = wyweb$main$create_editor$Q5State$Q4Node(Wy.copy(s));131 let toolbar = wyweb$main$create_toolbar$Q5State$Q4Node(Wy.copy(s));132 let msgbox = wyweb$main$create_msgbox$Q5State$Q4Node(Wy.copy(s));133 let js = wyweb$main$create_javascript$Q5State$Q4Node(Wy.copy(s));134 return web$html$div$aQ4Node$Q4Node([Wy.copy(editor), Wy.copy(toolbar), Wy.copy(msgbox), Wy.copy(js)]);135}136function wyweb$main$create_editor$Q5State$Q4Node(s) {137 return web$html$div$aQ9AttributeQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("code")], "");138}139const wyweb$main$LOADING$static = web$html$img$aQ9AttributeaQ4Node$Q4Node([new Wy.Record({key: "src", value: "images/loading.gif"})], [""]);140function wyweb$main$create_toolbar$Q5State$Q4Node(s) {141 let l;142 let cb;143 switch(s.state) {144 case wyweb$main$READY$static:145 case wyweb$main$READY_RUN$static:146 case wyweb$main$SUCCESS$static:147 case wyweb$main$ERROR$static: {148 cb = web$html$button$aQ9AttributeQ4Node$Q4Node([web$html$click$Q7handler$Q9Attribute(wyweb$main$compile_clicked$Q10MouseEventQ5State$Q5StateaQ6Action)], "Compile");149 l = "";150 break;151 }152 default: {153 cb = web$html$button$aQ9AttributeQ4Node$Q4Node([web$html$click$Q7handler$Q9Attribute(wyweb$main$compile_clicked$Q10MouseEventQ5State$Q5StateaQ6Action), web$html$disabled$V$Q9Attribute()], "Compile");154 l = Wy.copy(wyweb$main$LOADING$static);155 break;156 }157 }158 let vt = wyweb$main$toggle$Q6stringQ6Toggle$Q4Node("Verification", wyweb$main$toggle_verification$Q10MouseEventQ5State$Q5StateaQ6Action);159 let qt = wyweb$main$toggle$Q6stringQ6Toggle$Q4Node("Check", wyweb$main$toggle_check$Q10MouseEventQ5State$Q5StateaQ6Action);160 let et = wyweb$main$toggle$Q6stringQ6Toggle$Q4Node("Counterexamples", wyweb$main$toggle_counterexamples$Q10MouseEventQ5State$Q5StateaQ6Action);161 let jt = wyweb$main$toggle$Q6stringQ6Toggle$Q4Node("JavaScript", wyweb$main$toggle_javascript$Q10MouseEventQ5State$Q5StateaQ6Action);162 let cf = web$html$div$aQ9AttributeaQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("configbar")], [Wy.copy(vt), Wy.copy(qt), Wy.copy(et), Wy.copy(jt)]);163 let el = web$html$div$aQ9AttributeQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("elastic")], "");164 let egs = wyweb$main$create_examples$aQ6stringQ6Toggle$Q4Node(Wy.copy(wyweb$main$EG_NAMES$static), wyweb$main$load_example$Q10MouseEventQ5State$Q5StateaQ6Action);165 return web$html$div$aQ9AttributeaQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("cmdbar")], [Wy.copy(cb), Wy.copy(cf), Wy.copy(l), Wy.copy(el), Wy.copy(egs)]);166}167function wyweb$main$toggle$Q6stringQ6Toggle$Q4Node(lab, onclick) {168 let t = web$html$input$aQ9AttributeaQ4Node$Q4Node([new Wy.Record({key: "type", value: "checkbox"}), web$html$click$Q7handler$Q9Attribute(onclick)], [""]);169 let l = web$html$label$Q4Node$Q4Node(Wy.copy(lab));170 return web$html$div$aQ9AttributeaQ4Node$Q4Node([web$html$style$Q6string$Q9Attribute("display: inline;")], [Wy.copy(t), Wy.copy(l)]);171}172function wyweb$main$create_examples$aQ6stringQ6Toggle$Q4Node(labels, onchange) {173 let children = Wy.array("", labels.length);174 for(let i = 0;i < labels.length;i = i + 1) {175 children[i] = web$html$option$Q4Node$Q4Node(Wy.copy(labels[i]));176 }177 return web$html$div$aQ9AttributeaQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("egbar")], ["Examples: ", web$html$select$aQ9AttributeaQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("egselect"), web$html$change$Q7handler$Q9Attribute(onchange)], Wy.copy(children))]);178}179function wyweb$main$create_msgbox$Q5State$Q4Node(s) {180 let contents = "";181 switch(s.state) {182 case wyweb$main$SUCCESS$static: {183 contents = web$html$div$aQ9AttributeQ4Node$Q4Node([web$html$class$Q6string$Q9Attribute("message success")], "Success!");184 break;185 }186 case wyweb$main$ERROR$static: {187 contents = web$html$div$aQ9AttributeQ4Node$Q4Node([web$html$class$Q6string$Q9Attribute("message error")], "Error!");188 break;189 }190 case wyweb$main$FAILURE$static: {191 contents = web$html$div$aQ9AttributeQ4Node$Q4Node([web$html$class$Q6string$Q9Attribute("message error")], Wy.copy(s.error));192 break;193 }194 }195 return web$html$div$aQ9AttributeaQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("messages")], [Wy.copy(contents)]);196}197function wyweb$main$create_javascript$Q5State$Q4Node(s) {198 if(s.javascript) {199 return web$html$div$aQ9AttributeQ4Node$Q4Node([web$html$id$Q6string$Q9Attribute("bin")], Wy.copy(s.binary));200 } else {201 return web$html$div$Q4Node$Q4Node("");202 }203}204function wyweb$main$run(root, window, deps) {205 let state = new Wy.Record({state: wyweb$main$READY$static, verification: false, check: false, counterexamples: false, javascript: false, binary: "binary", output: "output", error: "", dependencies: Wy.copy(deps), markers: []});206 let app = new Wy.Record({model: Wy.copy(state), view: wyweb$main$view$Q5State$Q4Node});207 web$app$run(Wy.copy(app), root, window);208 wyweb$main$configure_editor$Q3dom6Window$V(window);209 wyweb$main$load_saved_state$Q3dom6Window$V(window);210}211function wyweb$main$configure_editor$Q3dom6Window$V(w) {212 let div = w.document.getElementById("code");213 let aceEditor = ace$ace$edit$u2Q6stringQ7Element$Q6Editor(div);214 aceEditor.setTheme("ace/theme/eclipse");215 aceEditor.getSession().setMode("ace/mode/whiley");216 div.addEventListener("mouseup", function(aceEditor) {217 return function(e) {218 return aceEditor.resize(true);219 };220 }(aceEditor));221}222function wyweb$main$get_editor_text$Q3dom6Window$Q6string(w) {223 let div = w.document.getElementById("code");224 let aceEditor = ace$ace$edit$u2Q6stringQ7Element$Q6Editor(div);225 return aceEditor.getValue();226}227function wyweb$main$set_editor_text$Q3dom6Window$V(w) {228 let sel = w.document.getElementById("egselect");229 Wy.assert(is$Q3dom4Nodeqr31m2Q6stringQ13EventListenerV16addEventListenerm2Q6stringQ13EventListenerV19removeEventListenerI8nodeTypeQ6string8nodeNameu2NQ7Element6parentaQ4Node10childNodesQ4Node10firstChildQ4Node9lastChildQ4Node11nextSiblingQ4Node15previousSiblingB11isConnectedfVB13hasChildNodesQ6string9nodeValueu2NQ6string11textContentmQ4NodeV11appendChildmQ4NodeV11removeChildm2Q4NodeQ4NodeV12replaceChildQ19CssStyleDeclaration5styleaQ7Element8childrenQ6string9innerTextm2Q6stringQ6stringV12setAttributeI4colsQ6string12defaultValueB8disabledI9maxLengthQ6string4nameB8readOnlyB8requiredI4rowsQ6string5valueB4wrap(sel));230 let label = sel.value;231 let text = "";232 for(let i = 0;i < Wy.copy(wyweb$main$EG_NAMES$static).length;i = i + 1) {233 if(Wy.equals(label, Wy.copy(wyweb$main$EG_NAMES$static)[i])) {234 text = Wy.copy(Wy.copy(wyweb$main$EG_TEXT$static)[i]);235 break;236 }237 }238 let div = w.document.getElementById("code");239 let aceEditor = ace$ace$edit$u2Q6stringQ7Element$Q6Editor(div);240 aceEditor.setValue(Wy.copy(text), 0);241}242function wyweb$main$load_saved_state$Q3dom6Window$V(w) {243 let db = w.localStorage;244 let st = db.getItem("whileyweb$saved");245 if((typeof st) === "string") {246 let div = w.document.getElementById("code");247 let aceEditor = ace$ace$edit$u2Q6stringQ7Element$Q6Editor(div);248 aceEditor.setValue(Wy.copy(st), 0);249 }250}251function wyweb$main$save_current_state$Q3dom6Window$V(w) {252 let db = w.localStorage;253 let st = wyweb$main$get_editor_text$Q3dom6Window$Q6string(w);254 db.setItem("whileyweb$saved", Wy.copy(st));255}256function wyweb$main$clear_editor_markers$Q3dom6WindowaQ4uint$V(w, markers) {257 let div = w.document.getElementById("code");258 let editor = ace$ace$edit$u2Q6stringQ7Element$Q6Editor(div);259 let session = editor.getSession();260 session.clearAnnotations();261 for(let i = 0;i < markers.length;i = i + 1) {262 session.removeMarker(markers[i]);263 }264}265function wyweb$main$set_editor_markers$Q3dom6WindowaQ8compiler5Error$aQ4uint(w, errors) {266 let div = w.document.getElementById("code");267 let editor = ace$ace$edit$u2Q6stringQ7Element$Q6Editor(div);268 let session = editor.getSession();269 let markers = Wy.array(0, errors.length);270 let annotations = std$collections$vector$Vector$V$Q6Vector();271 for(let i = 0;i < errors.length;i = i + 1) {272 let error = Wy.copy(errors[i]);273 let ann = ace$session$error$Q6stringQ4uintQ4uint$Q10Annotation(Wy.copy(error.text), error.line - 1, error.start);274 {275 const $4 = std$collections$vector$push$Q6Vectorv1T$Q6Vector(Wy.copy(annotations), Wy.copy(ann));276 annotations = $4;277 }278 let range = ace$range$Range$IIII$Q5Range(error.line - 1, error.start, error.line - 1, error.end + 1);279 markers[i] = session.addMarker(Wy.copy(range), "error-message", "error", true);280 }281 session.setAnnotations(std$collections$vector$to_array$Q6Vector$av1T(Wy.copy(annotations)));282 return Wy.copy(markers);283}284function is$Q8compiler8Responser2Q6string6resultaQ5Error6errors(v) {285 if(Object.keys(v).length !== 2) {286 return false;287 } else if(((typeof v.result) === "undefined") || ((typeof v.result) !== "string")) {288 return false;289 } else if(((typeof v.errors) === "undefined") || (!is$aQ5Error(v.errors))) {290 return false;291 }292 return true;293}294function is$Q3dom4Nodeqr31m2Q6stringQ13EventListenerV16addEventListenerm2Q6stringQ13EventListenerV19removeEventListenerI8nodeTypeQ6string8nodeNameu2NQ7Element6parentaQ4Node10childNodesQ4Node10firstChildQ4Node9lastChildQ4Node11nextSiblingQ4Node15previousSiblingB11isConnectedfVB13hasChildNodesQ6string9nodeValueu2NQ6string11textContentmQ4NodeV11appendChildmQ4NodeV11removeChildm2Q4NodeQ4NodeV12replaceChildQ19CssStyleDeclaration5styleaQ7Element8childrenQ6string9innerTextm2Q6stringQ6stringV12setAttributeI4colsQ6string12defaultValueB8disabledI9maxLengthQ6string4nameB8readOnlyB8requiredI4rowsQ6string5valueB4wrap(v) {295 return true;296}297function is$Q8compiler8Responser2Q6string6resultQ6string2js(v) {298 if(Object.keys(v).length !== 2) {299 return false;300 } else if(((typeof v.result) === "undefined") || ((typeof v.result) !== "string")) {301 return false;302 } else if(((typeof v.js) === "undefined") || ((typeof v.js) !== "string")) {303 return false;304 }305 return true;306}307function is$Q8compiler8Responser2Q6string6resultQ6string4text(v) {308 if(Object.keys(v).length !== 2) {309 return false;310 } else if(((typeof v.result) === "undefined") || ((typeof v.result) !== "string")) {311 return false;312 } else if(((typeof v.text) === "undefined") || ((typeof v.text) !== "string")) {313 return false;314 }315 return true;316}317function is$aQ5Error(v) {318 if((v !== null) && (v.constructor === Array)) {319 for(let i = 0;i < v.length;i = i + 1) {320 if(!is$r5Q6string4textQ4uint5startQ4uint3endQ4uint4lineu2Q6stringN14counterExample(v[i])) {321 return false;322 }323 }324 return true;325 }326 return false;327}328function is$r5Q6string4textQ4uint5startQ4uint3endQ4uint4lineu2Q6stringN14counterExample(v) {329 if((v === null) || ((v.constructor !== Wy.Record) && (v.constructor !== Object))) {330 return false;331 } else if(((typeof v.text) === "undefined") || ((typeof v.text) !== "string")) {332 return false;333 } else if(((typeof v.start) === "undefined") || (!is$Q4uint(v.start))) {334 return false;335 } else if(((typeof v.end) === "undefined") || (!is$Q4uint(v.end))) {336 return false;337 } else if(((typeof v.line) === "undefined") || (!is$Q4uint(v.line))) {338 return false;339 } else if(((typeof v.counterExample) === "undefined") || (!is$u2Q6stringN(v.counterExample))) {340 return false;341 }342 return true;343}344function is$u2Q6stringN(v) {345 return ((typeof v) === "string") || (v === null);346}347function is$Q4uint(v) {348 return ((typeof v) === "number") && std$integer$uint$type(v);...
gulpfile.js
Source:gulpfile.js
1// Gulp Components2const { series, parallel, src, dest, watch } = require("gulp")3// Image Minimization4const gulpImageMin = require("gulp-imagemin"),5 uglify = require("gulp-uglify"),6 sass = require("gulp-sass"),7 babel = require("gulp-babel"),8 imagemin = require("imagemin"),9 imageMinWebp = require("imagemin-webp"),10 fileinclude = require("gulp-file-include"),11 cache = require("gulp-cached")12const // Source Roots13 Source = {14 main: "src",15 images: "images",16 sass: "sass",17 js: "js/pages",18 sassFiles: "pages/",19 fonts: "fonts",20 videos: "videos",21 },22 // Compile Roots23 Compile = {24 main: "assets",25 css: "css",26 images: Source.images,27 fonts: Source.fonts,28 js: "js",29 videos: "videos",30 }31// Scss Compile32const scssCompile = () =>33 src([34 `${Source.main}/${Source.sass}/${Source.sassFiles}*`,35 `${Source.main}/${Source.sass}/fonts.scss`,36 ])37 .pipe(38 sass({39 outputStyle: "compressed",40 }).on("error", sass.logError)41 )42 .pipe(dest(`${Compile.main}/${Compile.css}/`))43// Javascript Minify / Concatinating44const jsCompile = () =>45 src(`./${Source.main}/${Source.js}/*`)46 .pipe(47 fileinclude({48 prefix: "~",49 basepath: "@file",50 })51 )52 .pipe(cache("linting"))53 .pipe(54 babel({55 presets: ["@babel/preset-env"],56 })57 )58 .pipe(uglify())59 .pipe(dest(`./${Compile.main}/${Compile.js}`))60 .pipe(dest(`./${Compile.main}/${Compile.js}`))61//Image Minimization62const imageMin = () => (63 src(`${Source.main}/${Source.images}/**/*`)64 //.pipe(imagemin())65 .pipe(66 gulpImageMin({67 interlaced: true,68 progressive: true,69 optimizationLevel: 5,70 svgoPlugins: [71 {72 removeViewBox: true,73 },74 ],75 })76 )77 .pipe(dest(`./${Compile.main}/${Compile.images}`)),78 imagemin(79 [80 `${Source.main}/${Source.images}/*.{jpg,png,tiff,webp}`,81 `${Source.main}/${Source.images}/**/*.{jpg,png,tiff,webp}`,82 ],83 `${Compile.main}/${Compile.images}/webp/`,84 {85 use: [86 imageMinWebp({87 quality: 50,88 }),89 ],90 }91 ).then(() => {92 console.log("Webp Images converted / optimized")93 })94)95// Copy Fonts96const copyFonts = () =>97 src(`./${Source.main}/${Source.fonts}/*`).pipe(98 dest(`./${Compile.main}/${Compile.fonts}`)99 )100// Videos101const copyVideos = () =>102 src(`./${Source.main}/${Source.videos}/*`).pipe(103 dest(`./${Compile.main}/${Compile.videos}`)104 )105const tasks = () => (106 // Watch Different Files And Perform Related Task107 watch(108 [109 `./${Source.main}/js/*.js`,110 `./${Source.main}/js/**/*.js`,111 `./${Source.main}/js/**/**/*.js`,112 `./${Source.main}/js/**/**/**/*.js`,113 ],114 jsCompile115 ),116 watch(117 [118 `./${Source.main}/${Source.sass}/**/**/**/*.scss`,119 `./${Source.main}/${Source.sass}/**/**/*.scss`,120 `./${Source.main}/${Source.sass}/**/*.scss`,121 `./${Source.main}/${Source.sass}/*.scss`,122 ],123 scssCompile124 ),125 watch(`./${Source.main}/${Source.font}/*`, copyFonts),126 watch(127 [128 `./${Source.main}/${Source.images}/*.{jpg,png,tiff,gif,svg}`,129 `./${Source.main}/${Source.images}/**/*.{jpg,png,tiff,gif,svg}`,130 `./${Source.main}/${Source.images}/**/**/*.{jpg,png,tiff,gif,svg}`,131 ],132 imageMin133 ),134 watch(`./${Source.main}/${Source.videos}/*`, copyVideos)135)136// Tasks137exports.tasks = series(tasks)138exports.scssCompile = series(scssCompile)139exports.jsCompile = series(jsCompile)140exports.copyFonts = series(copyFonts)141exports.imageMin = series(imageMin)142exports.copyVideos = series(copyVideos)143// Default Task...
Using AI Code Generation
1var main = require('main');2var compiler = main.compile('test.java');3compiler.compile(function (err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var main = require('main');11var compiler = main.compile('test.java');12compiler.run(function (err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var main = require('main');20var compiler = main.compileAndRun('test.java');21compiler.compileAndRun(function (err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});
Using AI Code Generation
1const test = require('ava');2const avaCompile = require('ava-compile');3test('compiles', t => {4 t.plan(1);5 t.is(avaCompile.compile('test.js'), true);6});7### avaCompile.compile(filePath)8MIT © [Rajat S](
Using AI Code Generation
1var main = require('main');2var compiler = main.getCompiler('js');3var compiled = compiler.compile('var a = 5;');4console.log(compiled);5var main = require('main');6var compiler = main.getCompiler('coffee');7var compiled = compiler.compile('a = 5');8console.log(compiled);9var main = require('main');10var compiler = main.getCompiler('ls');11var compiled = compiler.compile('a = 5');12console.log(compiled);13### main.getCompiler(language)14### main.getCompilerNames()15### main.getCompilerExtensions()16### Compiler.compile(code)17### Compiler.getCompiledCode()18### Compiler.getCompiledCodeMap()19### Compiler.getCompiledCodeMapWithSourceMap()20### Compiler.getCompiledCodeWithSourceMap()21### Compiler.getCompiledCodeWithSourceMapAsDataUrl()22### Compiler.getCompiledCodeWithSourceMapAsObject()23### Compiler.getCompiledCodeWithSourceMapAsUrl()24### Compiler.getCompiledCodeWithSourceMapAsV3()25### Compiler.getCompiledCodeWithSourceMapAsVlq()26### Compiler.getCompiledCodeWithSourceMapAsVlqAndUrl()27### Compiler.getCompiledCodeWithSourceMapAsVlqAndDataUrl()28### Compiler.getCompiledCodeWithSourceMapAsVlqAndObject()29### Compiler.getCompiledCodeWithSourceMapAsVlqAndComment()
Using AI Code Generation
1var compiler = require('compiler');2var code = "console.log('hello world');";3compiler.compile(code, 'javascript', 'node', function(err, result) {4 if(err) {5 console.log(err);6 } else {7 console.log(result);8 }9});
Using AI Code Generation
1var main = require("./main.js");2var fs = require("fs");3var path = require("path");4var file = fs.readFileSync(path.join(__dirname, "test.c"), "utf8");5var compiler = new main.compiler();6var result = compiler.compile(file, "c", "cpp");7console.log(result);
Using AI Code Generation
1const test = require('ava');2const main = require('./main');3test('main.compile', t => {4 t.is(main.compile(), 'Hello World!');5});6const test = require('ava');7const main = require('./main');8test('main.compile', t => {9 return main.compile().then(result => {10 t.is(result, 'Hello World!');11 });12});13const test = require('ava');14const main = require('./main');15test('main.compile', async t => {16 const result = await main.compile();17 t.is(result, 'Hello World!');18});19const test = require('ava');20const main = require('./main');21test('main.compile', async t => {22 const result = await t.throws(main.compile(), Error);23 t.is(result.message, 'Hello World!');24});25const test = require('ava');26const main = require('./main');27test('main.compile', async t => {28 const promise = main.compile();29 await t.throwsAsync(promise, {instanceOf: Error, message: 'Hello World!'});30});31const test = require('ava');32const main = require('./main');33test('main.compile', async t => {34 const promise = main.compile();35 await t.throwsAsync(promise, {instanceOf: Error, message: 'Hello World!'});36});37const test = require('ava');
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!!