
Web, Mobile, IoT: all JS things since 00's - opinions are my own β’ Principal SW Engineer @anacondainc working on OSS stack π¦
- Tweets44.7K
- Following1.3K
- Followers10.2K
- Likes15.7K

ALT import watTag from 'https://esm.run/@webreflection/utils/wat-tag'; const wat = watTag({ import: { my_namespace: { imported_func: arg => console.log(arg), }, }, }); { using result = await wat` (module (func $i (import "my_namespace" "imported_func") (param i32)) (func (export "exported_func") i32.const 42 call $i)) `; result.instance.exports.exported_func(); }
![// @see https://webreflection.github.io/utils/src/#dom-diff
const diff = (current, future, pin) => {
const { isConnected, parentNode } = pin;
const { moveBefore = parentNode.insertBefore } = parentNode;
// remove nodes that are not in the future array
for (let node, i = current.length; i--;) {
node = current[i];
if (!future.includes(node))
node.remove();
}
for (let node, i = future.length; i--;) {
node = future[i];
// only work on nodes that are not ordered like before
if (node.nextSibling !== pin) {
// moveBefore constraints to avoid errors
if (isConnected && node.parentNode === parentNode)
moveBefore.call(parentNode, node, pin);
// safe fallback for all other cases
else
parentNode.insertBefore(node, pin);
}
pin = node;
}
return future;
};](https://pbs.twimg.com/media/HPCiV-UX0AAJT_w.jpg?name=small&format=webp)
ALT // @see https://webreflection.github.io/utils/src/#dom-diff const diff = (current, future, pin) => { const { isConnected, parentNode } = pin; const { moveBefore = parentNode.insertBefore } = parentNode; // remove nodes that are not in the future array for (let node, i = current.length; i--;) { node = current[i]; if (!future.includes(node)) node.remove(); } for (let node, i = future.length; i--;) { node = future[i]; // only work on nodes that are not ordered like before if (node.nextSibling !== pin) { // moveBefore constraints to avoid errors if (isConnected && node.parentNode === parentNode) moveBefore.call(parentNode, node, pin); // safe fallback for all other cases else parentNode.insertBefore(node, pin); } pin = node; } return future; };
![export default (current, future, pin) => {
const { parentNode } = pin;
for (let node, i = current.length; i--;) {
node = current[i];
if (!future.includes(node))
node.remove();
}
for (let node, i = future.length; i--;) {
node = future[i];
if (node.nextSibling !== pin) {
if (node.parentNode !== parentNode)
parentNode.insertBefore(node, pin);
else
parentNode.moveBefore(node, pin);
}
pin = node;
}
return future;
};](https://pbs.twimg.com/media/HO_Bxi4XcAAM_A4.png?name=small&format=webp)
ALT export default (current, future, pin) => { const { parentNode } = pin; for (let node, i = current.length; i--;) { node = current[i]; if (!future.includes(node)) node.remove(); } for (let node, i = future.length; i--;) { node = future[i]; if (node.nextSibling !== pin) { if (node.parentNode !== parentNode) parentNode.insertBefore(node, pin); else parentNode.moveBefore(node, pin); } pin = node; } return future; };







