Skip to content

Instantly share code, notes, and snippets.

Avatar

Max Winderbaum max-winderbaum

  • Seattle, WA
View GitHub Profile
View Request.spec.ts
import { Request, rewireRequest } from "./Request";
const mockRequest = { fake: true };
rewireRequest(mockRequest);
// Use mocked request here
@max-winderbaum
max-winderbaum / rename_js_to_ts
Created Jun 29, 2017
Rename all js files to ts typescript recursively
View rename_js_to_ts
rename "s/\.js/\.ts/" **/*.js && git add **/*.ts && git rm **/*.js
@max-winderbaum
max-winderbaum / depInj.js
Last active Sep 24, 2017
Poor Man's Dependency Injection
View depInj.js
import dep1 from '../dep1';
import dep2 from '../dep2';
const defaultDeps = {
dep1,
dep2,
};
export function _myModuleFactory({ dep1, dep2 } = defaultDeps) {
const myModule = {};
View getPhrasesByBlock.js
import { Map, List } from 'immutable';
export default function getPhrasesByBlock(phrases) {
return phrases.reduce(
(phrasesByBlock, phrase) => phrasesByBlock.update(
phrase.get(`blockKey`),
new List(),
(blockPhrases) => blockPhrases.push(phrase)
),
new Map(),
View getHighlightStrategy.js
const handlers = new Map({
handlePhraseMouseEnter(phrase) {
hoverState.handleMouseEnter(phrase);
phraseConfig.handleMouseEnter(phrase);
},
handlePhraseMouseLeave(phrase) {
hoverState.handleMouseLeave(phrase);
phraseConfig.handleMouseLeave(phrase);
},
handlePhraseClick: phraseConfig.handlePhraseClick,
View es6PipelineSimpleMiddleware.js
const pipeline = (...funcs) =>
value => funcs.reduce((a, b) => b(a), value);
You can’t perform that action at this time.