Skip to content

Instantly share code, notes, and snippets.

/**
* TypeScript version of @istarkov's cancellable Promise wrapper.
*
* @see https://github.com/facebook/react/issues/5465#issuecomment-157888325
*/
const makeCancelable = <T>(promise: Promise<T>): { promise: Promise<T>; cancel(): void } => {
let hasCanceled = false;
const wrappedPromise = new Promise<T>((resolve, reject) => {
promise.then(
@superjose
superjose / .gitlab-ci.yml
Last active February 19, 2024 10:22
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.
@joshq00
joshq00 / .babelrc
Created October 29, 2015 23:39
Babel 6 : React / stage 0
{
"presets": [ "react", "es2015" ],
"plugins": [
"transform-es2015-modules-commonjs",
"transform-react-constant-elements",
]
}