This file contains 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 sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
(async () => { | |
const reportGC = async () => { | |
global.gc(); | |
await sleep(1000); | |
console.log('GC\nb() results:\n', process.memoryUsage()); | |
}; | |
let endPromise = Promise.resolve(); |
This file contains 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 options = { | |
...this.compilerOptions, | |
target: ts.ScriptTarget.ES5, | |
}; | |
// @ts-expect-error foo | |
const scriptTransformers = ts.getTransformers(options).scriptTransformers; | |
const transformer: ts.TransformerFactory<ts.SourceFile> = (context) => { | |
return (sourceFile) => { | |
const visitor = (node: ts.Node): ts.Node => { |
This file contains 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
{ | |
"indentation": { | |
"character": " " | |
}, | |
"wrapping": { | |
"maxLineLength": 80, | |
"implementsExtends": { | |
"defaultWrap": "fillLine", | |
"rules": [ | |
{ |
This file contains 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
// RUN WITH | |
// node --expose_gc memoryLeakTest.js | |
class A { | |
async b() { | |
return { foo: "bar".repeat(1000) }; | |
} | |
async c() { | |
return Promise.resolve({ foo: "bar".repeat(1000) }); |
This file contains 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
// tslint:disable: no-any | |
export type Thunkify< | |
Actions extends { [key: string]: (...args: any) => any } | |
> = { | |
[actionKey in keyof Actions]: ReturnType<Actions[actionKey]> extends (( | |
...args: any | |
) => Promise<any>) | |
? | |
| (( | |
...args: Parameters<Actions[actionKey]> |
This file contains 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 from "react"; | |
/* | |
// Usage: | |
export type WithPleasure = { | |
pleasure: number; | |
}; | |
const PleasureContext = React.createContext<WithPleasure>({ | |
pleasure: 13 |
This file contains 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 { | |
CANCEL_ACTION_REQUESTS, | |
CANCEL_ALL_ACTION_REQUESTS | |
} from './constants'; | |
export function cancelActionRequest(actionType) { | |
return { type: CANCEL_ACTION_REQUESTS, actionType }; | |
} | |
export function cancelAllActionRequests() { |
This file contains 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
/* | |
Usage (I however think that the code is self explanatory) | |
<ReactComment text={` | |
Very long comment with html link | |
<a href="https://gist.github.com/alexeychikk/bfe72a072a9a962f2da900b6151e4aae">Star me :)</a> | |
`} /> | |
*/ | |
import React, {Component, PropTypes} from 'react'; |
This file contains 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
/** | |
* Usage | |
* | |
import React, { Component, PropTypes } from 'react'; | |
import ReduxContextFix from '../util/reduxContextFix'; | |
class ScreenSizeAware extends Component { | |
static childContextTypes = { | |
screenData: PropTypes.object | |
}; |