Skip to content

Instantly share code, notes, and snippets.

View tusharmath's full-sized avatar
😑
Imploding

Tushar Mathur tusharmath

😑
Imploding
View GitHub Profile
@tusharmath
tusharmath / esnextbin.md
Last active April 11, 2017 09:33
esnextbin sketch
@tusharmath
tusharmath / esnextbin.md
Last active March 30, 2017 14:40
esnextbin sketch
@tusharmath
tusharmath / ActionLogger.ts
Created January 24, 2017 05:43
Logs actions
export function logger (action: any, state0: any, state1: any, effect: any) {
if (!getGlobalConfig().dispatcherLogs) return
let actionName: string[] = []
while (action instanceof Action) {
actionName.push(action.type)
action = action.value
}
console.groupCollapsed(actionName.join('/'))
console.log('ACTION', action)
function test () {
const cache = {}
function create (type) {return {type: type, value: new Date() }}
return function (type) {
if (cache[type]) return cache[type]
const c = create(type)
cache[type] = c
return c
}
}
@tusharmath
tusharmath / index.html
Last active December 9, 2016 11:17
call vs apply #jsbench #jsperf (http://jsbench.github.io/#be8317e0f4ad408024c4900a595c193d) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>call vs apply #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>
(function (ctx) {
'use strict'
ctx.TouchBM = function (selector, {min = 0, max = 300} = {min: 0, max: 300}) {
const nav = document.querySelector(selector)
class TouchEventCustom extends TouchEvent {
constructor(type, changedTouches) {
super(type)
this.__changedTouches = changedTouches
}
get changedTouches() { return this.__changedTouches }
/**
* Created by tushar on 29/11/16.
*/
import * as O from 'observable-air'
export class Action<T> {
constructor (public readonly type: string, public readonly value: T) {
}
static of<T> (type: string, value: T) {
/**
* Created by tushar on 29/11/16.
*/
import * as O from 'observable-air'
type faco = <F> (t: F) => Action<F>
export class Action<T> {
constructor (public readonly type: string, public readonly value: T) {
@tusharmath
tusharmath / perf-bind-vs-arrow.js
Last active November 6, 2016 03:27
performance comparison of creating bound functions
const assert = require('assert')
console.log('NODE:', process.version)
console.log('V8:', process.versions.v8, '\n--------------')
class Bind {
constructor () {
this.value = 1000
this.update = this.__update.bind(this)
}
__update () {
@tusharmath
tusharmath / esnextbin.md
Created October 19, 2016 12:26
esnextbin sketch