Datasets:
Download verification/check_comparator.cjs from PureOne/ChronoSheaf-Input-Lag: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/PureOne/ChronoSheaf-Input-Lag/resolve/main/verification/check_comparator.cjs
- Command line
-
hf download hf://datasets/PureOne/ChronoSheaf-Input-Lag/verification/check_comparator.cjs
-
curl -L -o check_comparator.cjs https://huggingface.co/datasets/PureOne/ChronoSheaf-Input-Lag/resolve/main/verification/check_comparator.cjs
1.5 kB
| const fs=require("node:fs"), path=require("node:path"), vm=require("node:vm"), assert=require("node:assert/strict"); | |
| const html=fs.readFileSync(path.join(__dirname,"../Pulse_Comparator.html"),"utf8"); | |
| const blocks=Array.from(html.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/g),m=>m[1]); | |
| class Element{ | |
| constructor(){this.children=[];this.events={};this.attrs={};this.value="";this.textContent="";} | |
| addEventListener(k,f){this.events[k]=f;} setAttribute(k,v){this.attrs[k]=v;} | |
| append(...x){this.children.push(...x);} replaceChildren(){this.children=[];} focus(){} | |
| } | |
| const elements=new Map(["gain","loss","changes","err","sequence","period","shift","width","alternate","cluster"].map(k=>[k,new Element()])); | |
| for(const [k,v] of [["period","10"],["shift","4"],["width","9"]])elements.get(k).value=v; | |
| const ctx=vm.createContext({document:{getElementById:k=>elements.get(k),createElement:()=>new Element()}}); | |
| for(const x of blocks)vm.runInContext(x,ctx); | |
| assert.equal(elements.get("loss").textContent,"20.00%"); | |
| elements.get("cluster").events.click();assert.equal(elements.get("loss").textContent,"8.75%"); | |
| assert.equal(elements.get("gain").textContent,"2.00 ms"); | |
| elements.get("sequence").children[0].events.click();assert.equal(elements.get("gain").textContent,"2.50 ms"); | |
| elements.get("width").value="-1";elements.get("width").events.input();assert.equal(elements.get("gain").textContent,"—"); | |
| console.log("Embedded JavaScript passed alternating, grouped, changed poll and invalid width checks."); | |