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 * as Sum from 'shared/facades/Sum'; | |
import * as t from 'shared/facades/io-ts'; | |
const TypeA = t.strict({ | |
a: t.string, | |
}); | |
interface TypeA extends t.TypeOf<typeof TypeA> {} | |
const TypeB = t.strict({ |
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
type Lens<O, V> = { | |
get: (o: O) => V | |
set: (value: V) => (o: O) => O, | |
update: (fn: (current: V) => V) => (o: O) => O | |
} | |
type Homework = {done: number}; | |
type Person = { | |
age: number; |
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
// By overriding a subset of the interfaces from the `@types/react` package, | |
// we're able to strictly type check what our JSX must look like and avoid inheriting from HTML elements (since they're not valid in our environment for instance). | |
import * as React from 'react'; | |
declare module 'react' { | |
namespace JSX { | |
interface ElementChildrenAttribute { | |
children: {}; | |
} |
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 ifNotReady = ifElse( | |
either( | |
propEq('status', 'init'), | |
propEq('status', 'pending'), | |
), | |
); | |
render() { | |
<> | |
{ifNotReady( |
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 propTypes = { | |
children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]), | |
}; | |
const defaultProps = { | |
children: null, | |
}; | |
const SaveButton = () => ... | |
const ActionsContainer = ({ children }) => ... |
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
{ | |
test: /\.js$/, | |
use: [ | |
{ | |
loader: 'babel-loader', | |
options: { | |
// Babel loader options | |
}, | |
}, | |
], |
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 React, { Component, PropTypes } from 'react'; | |
import ReactDOM from 'react-dom'; | |
import Loading from 'loading'; | |
export default function TimedOut(WrappedComponent) { | |
const propTypes = { | |
delay: PropTypes.number.isRequired, | |
}; | |
class Wrapper extends Component { |
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
/** | |
* Remove an index from an array. | |
* This creates a new array without the index we're removing. | |
* Because of that, indexes are re-created so there isn't any empty spot. | |
* | |
*/ | |
export function removeIndexFrom(array, indexToRemove) { | |
return [ | |
...array.slice(0, indexToRemove), | |
...array.slice(indexToRemove + 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
function promisify(fn) { | |
return (...args) => { | |
return new Promise((resolve, reject) => { | |
fn(...args, (error, result) => { | |
if (error) { | |
return reject(error); | |
} | |
return resolve(result); | |
}); |
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 original = [ | |
[0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0] | |
]; | |
const clone = [...original]; | |
console.log(original === clone); // false. | |
console.log(original[0] === clone[0]); // true. |