Skip to content

Instantly share code, notes, and snippets.

View Freak613's full-sized avatar

Pavel Martynov Freak613

  • San Francisco, CA
View GitHub Profile
// Fork of https://github.com/shiningjason/react-enhanced-reducer-hook/blob/master/index.js
const useHandler = fn => {
const ref = useRef({
fn,
handler: (...args) => ref.current.fn(...args)
});
ref.current.fn = fn;
return ref.current.handler;
};
// utils
const curry = (fn, arity = fn.length, ...args) => {
return arity <= args.length
? fn(...args)
: curry.bind(null, fn, arity, ...args);
};
const append = curry((item, array = []) => {
return [...array, item];
}, 2);
const createInstance = () => {
const queue = [];
return {
schedule: effect => queue.push(effect),
getQueue: () => queue
};
};
const NoOp = {
const createStore = () => {
let subscriptions = [];
let state;
let age = 0;
const getSubscriptions = () => subscriptions;
const getState = () => state;
const getAge = () => age;
const subscribe = fn => {
@Freak613
Freak613 / index.html
Last active April 19, 2019 00:31
childNodes indexOf #jsbench #jsperf (https://jsbench.github.io/#91a09b3ee7a080d7f7aa8ceaceeb1a1d) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>childNodes indexOf #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>function scope</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>arguments object perf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>array vs linked list</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>get-props</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>array-push</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>