Bugs fixed

This commit is contained in:
Abdussamed 2023-06-18 15:09:09 +03:00
parent 360a89993d
commit d20f8dc25f
3 changed files with 35 additions and 9 deletions

3
package.json Normal file → Executable file
View File

@ -5,9 +5,6 @@
"private": false, "private": false,
"description": "Dont use variable, use smart variable wires !", "description": "Dont use variable, use smart variable wires !",
"main": "wire.js", "main": "wire.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://git.saqut.com/saqut/wirejs.git" "url": "https://git.saqut.com/saqut/wirejs.git"

0
readme.md Normal file → Executable file
View File

41
wire.js Normal file → Executable file
View File

@ -67,7 +67,35 @@
} }
é.fingerPrint = Symbol("wire"); é.fingerPrint = Symbol("wire");
é.isWire = n => n?.fp == é.fingerPrint; é.isWire = n => n?.fp == é.fingerPrint;
é.extract = (e,v) => typeof e=='function'?e(v):e; é.extract = (e,v) => {
if(typeof e=='function')
{
return é.freeze(e(v))
}else{
return é.freeze(e);
}
};
é.freeze = a => {
if(Object.isFrozen(a))
{
return a;
}
switch(typeof a)
{
case "object":{
let k = Object.assign({}, a);
for (const [name, value] of Object.entries(k)) {
if(typeof value == "object")
{
k[name]=é.freeze(value);
}
};
Object.freeze(k);
return k;
}
default: return a;
};
};
é.isSame = (a,b) => !é.diff(a,b); é.isSame = (a,b) => !é.diff(a,b);
é.watch = (fn, assoc) => { é.watch = (fn, assoc) => {
for (const wireVar of assoc) for (const wireVar of assoc)
@ -149,17 +177,17 @@
{ {
case "undefined": case "undefined":
case "function":{ case "function":{
return typeof a == typeof b ? é.cDiff.some : é.cDiff.different return typeof a == typeof b ? cDiff.some : cDiff.different
} }
case "symbol": case "symbol":
case "bigint": case "bigint":
case "boolean": case "boolean":
case "number": case "number":
case "string":{ case "string":{
return a === b ? é.cDiff.some : é.cDiff.different; return a === b ? cDiff.some : cDiff.different;
} }
case "object":{ case "object":{
return é.cDiff.adiff; return cDiff.adiff;
} }
}; };
} }
@ -209,7 +237,7 @@
}; };
const schedule = function(fn){ const schedule = function(fn){
schedule.jobs.push(fn) schedule.jobs.push(fn)
if(!é.schedule.executing) if(!schedule.executing)
{ {
requestAnimationFrame(()=>{ requestAnimationFrame(()=>{
for (const fn of schedule.jobs) { for (const fn of schedule.jobs) {
@ -218,7 +246,8 @@
}catch(e){ }catch(e){
console.error(e) console.error(e)
} }
} };
schedule.jobs=[];
}) })
} }
}; };