Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
assert.equals(javascript, awesome)

Avichay Eyal eavichay

💻
assert.equals(javascript, awesome)
View GitHub Profile
@eavichay
eavichay / mock-local-storage-issue-reproduce.js
Created Oct 13, 2020
mock-local-storage API incomaptible with browser
View mock-local-storage-issue-reproduce.js
// node.js
import 'mock-local-storage';
localStorage.setItem('some-value');
/*
In browser environment, this should throw TypeError:
Uncaught TypeError: Failed to execute 'setItem' on 'Storage': 2 arguments required, but only 1 present
*/
@eavichay
eavichay / detect.js
Last active Apr 17, 2019
Mutations Detection
View detect.js
// first approach: MutationObserver
!(function () {
// IIFE
const serverEndpoint = 'http://localhost:3000//get-report/';
if (!typeof MutationObserver === 'function') {
// second approach - using DOMSubtreeModified event (buggy, unstable and deprecated for MutationObserver API)
document.body.addEventListener('DOMSubtreeModified', (e) => {
const data = {
@eavichay
eavichay / dearXXX.txt
Created Nov 22, 2018
What to answer to emails after you purchase a domain name
View dearXXX.txt
Hello XXXXXX
I appreciate your email.
I would like to know if you could help me with the following.
I require a time estimation for production-ready product and estimated cost.
The application should be available via web browser (all browsers should be supported, including Internet Explorer version 6+) - as the customers includes also financial groups, i.e. banks.
It should support all modern frameworks: Angular, React, PHP and jQuery.
It should be fully compatible with all modern libraries like moment.js, node.js, typescript and java.
@eavichay
eavichay / build.js
Created Sep 4, 2018
Typescript compiler output to browser es-modules + watch
View build.js
const fs = require('fs');
const watch = require('node-watch');
const { execSync } = require('child_process');
const StaticServer = require('static-server');
const walker = function(dir, fn) {
const files = fs.readdirSync(dir);
files.forEach((file) => {
if (fs.statSync(dir + '/' + file).isDirectory()) {
walker(dir + '/' + file + '/', fn);
@eavichay
eavichay / .babelrc
Created May 16, 2018
Decorators only for browser-es native modules
View .babelrc
{
"plugins": ["transform-decorators-legacy"]
}
View gist:cafb6cbf53129a9c46b36dfcda018bef
// code
const foo = function(target) {
target.prototype.foo = function() {
console.log("foo");
}
}
const bar = function(myText) {
return function(target) {
You can’t perform that action at this time.