Skip to content

Instantly share code, notes, and snippets.

View helabenkhalfallah's full-sized avatar
🎯
Focusing

Héla Ben Khalfallah helabenkhalfallah

🎯
Focusing
View GitHub Profile
const target = {
name: 'Alice',
age: 30,
}
const handler = {
get: function(target, prop, receiver) {
console.log(`Getting property ${prop}`);
return Reflect.get(target, prop, receiver);
const target = { name: 'Alice', age: 30 };
const handler = {
ownKeys: function(target) {
console.log('Getting property keys.');
return Reflect.ownKeys(target);
}
};
const proxy = new Proxy(target, handler);
const target = function(a, b) {
return a + b;
};
const handler = {
apply: function(target, thisArg, argumentsList) {
console.log(`Called with arguments: ${argumentsList}`);
return target.apply(thisArg, argumentsList);
}
};
const target = { name: 'Alice', age: 30 };
const handler = {
deleteProperty: function(target, prop) {
console.log(`Deleting property ${prop}.`);
delete target[prop];
return true;
}
};
const target = { name: 'Alice', age: 30 };
const handler = {
has: function(target, prop) {
console.log(`Checking if property ${prop} is in target.`);
return prop in target;
}
};
const proxy = new Proxy(target, handler);
@helabenkhalfallah
helabenkhalfallah / BasicProxyAssignment.js
Last active May 20, 2024 16:20
Basic Proxy Assignment (set)
const target = { message: "Hello, World!" };
const handler = {
set: function(target, prop, value, receiver) {
console.log(`Setting property ${prop} to ${value}.`);
target[prop] = value;
return true;
}
};
@helabenkhalfallah
helabenkhalfallah / BasicProxy.js
Created May 20, 2024 15:57
Basic creation of a Proxy
const target = { message: "Hello, World!" };
const handler = {
get: function(target, prop, receiver) {
console.log(`Property ${prop} was accessed.`);
return Reflect.get(target, prop, receiver);
}
};
const proxy = new Proxy(target, handler);
import fs from 'fs';
import React from 'react';
import 'jest-styled-components';
// https://gist.github.com/helabenkhalfallah/6616ad01d544e1c1ed64f879c6e5e485
import JestHelper from './JestHelper';
const {
getHtmlPageWrapper,
getHtmlW3CComplianceMessage,
isHtmlW3CCompliant,
// eslint-disable-next-line import/no-extraneous-dependencies
import ReactDOMServer from 'react-dom/server';
import HtmlStringPrettifier from './HtmlStringPrettifier';
const isHtmlW3CCompliant = (w3cValidation) => w3cValidation && !w3cValidation.error;
const getHtmlW3CComplianceMessage = ({
html,
error,
}) => {
@helabenkhalfallah
helabenkhalfallah / SimpleLoadMoreList.js
Last active April 28, 2024 19:26
Simple Load More List
import {
createSignal,
createResource,
For,
Match,
Switch,
Show,
} from "solid-js";
import { render } from "solid-js/web";