This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Monad<V> { | |
value: V; | |
static of = <T>(value: T): Monad<T> => new Monad(value); | |
constructor(value: V) { | |
this.value = value; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reduce = require("./reduce"); | |
/** | |
* Performs right-to-left function composition. The rightmost function may have | |
* any arity; the remaining functions must be unary. | |
* compose(f, g)(x) >> f(g(x)) | |
* | |
* @example | |
* const doubleNegative = compose(x => x * -1, x => x * 2); | |
* doubleNegative(5); // -10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js.jsx': | |
'ReactJS Component Unit Test Template': | |
'prefix': 'compspec' | |
'body': """ | |
/** | |
* components/$1.spec.js | |
*/ | |
import React from 'react'; | |
import {shallow} from 'enzyme'; | |
import $1 from './$1'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* components/SafeRender.js | |
*/ | |
import React, {Component, PropTypes} from 'react'; | |
import {getDisplayName} from '../utils'; | |
import {Alert} from '../generic'; | |
import Translate from './Translate'; | |
import logger from '../logger'; | |
const TRANSLATE_RENDER_FALLBACK = 'There was a an Error.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* components/Combo.js | |
*/ | |
import React, {Component, PropTypes} from 'react'; | |
/** | |
* Gets the displayname of a Component | |
* @param {ReactClass} WrappedComponent - component to get display name from | |
* @returns {string} Display name of WrappedComponent | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* General purpose functional utilties | |
* @module utils/fn | |
*/ | |
import hasProperty from './hasProperty'; | |
export const map = (fn, arr) => { | |
if (typeof arr !== 'undefined') return Array.prototype.map.call(arr, fn); | |
return map.bind({}, fn); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @module {Function} utils/bimap | |
* @flow | |
*/ | |
type MapKeyType = typeof BiMap.FORWARD | typeof BiMap.REVERSE; | |
// always sets Array<value> | |
// merges instead of overwrites by default | |
export default class BiMap<K, V> { | |
stores: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hoistStatics from 'hoist-non-react-statics'; | |
import React from 'react'; | |
/** | |
* Allows two animation frames to complete to allow other components to update | |
* and re-render before mounting and rendering an expensive `WrappedComponent`. | |
*/ | |
export default function deferComponentRender(WrappedComponent) { | |
class DeferredRenderWrapper extends React.Component { | |
constructor(props, context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Upload extends Component { | |
/** | |
* Renders one of [renderProgress, renderEnd, renderUnknown] depending on | |
* the XMLHttpRequest.status | |
* @returns {Object} Video placeholder with progress bar | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply(compiler) { | |
compiler.plugin('after-emit', (compilation, callback) => { | |
const file = 'some data'; | |
compilation.assets['foo.js'] = { | |
source: () => file, | |
size: () => Buffer.byteLength(file), | |
}; | |
}); | |
} |