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
'use strict'; | |
var request = new XMLHttpRequest(); | |
request.open('GET', 'https://api.github.com/repos/' + args[0] + '/contributors', true); | |
request.onreadystatechange = function() | |
{ | |
if (request.readyState != 4) | |
return false; |
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
{ | |
"name": "ghcontribs3", | |
"endpoints": ["api.github.com"], | |
"scriptUrl": "https://rawgit.com/ncthis/6fa481eaceaf96ef6394/raw/0d8db4b2c6db266fed87b63d955d2947e2b1f0f2/contibutors.js" | |
} |
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
{ | |
user: { | |
name: "...", | |
email: "..." | |
}, | |
orders: { | |
count: 10, | |
items: [...] | |
}, | |
application: { |
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 invariant from 'invariant'; | |
const valueGetters = { | |
text: e => e.target.value, | |
checkbox: e => e.target.checked, | |
}; | |
export default (self, key) => { | |
invariant(key, 'key is required'); | |
invariant(self, 'self is required'); |
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
// from: http://www.typescriptlang.org/play/#src=function%20someFactory%3CT%3E()%20%7B%0D%0A%20%20return%20class%20%7B%0D%0A%20%20%20%20method(someParam%20%3A%20T)%20%7B%0D%0A%20%20%20%20%20%20%0D%0A%20%20%20%20%7D%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2F%20how%20to%20invoke%20this%20factory%20with%20a%20defined%20%3CT%3E%3F%0D%0A%0D%0Aconst%20SomeClass%20%3D%20someFactory%3C%7B%20whatever%3A%20string%20%7D%3E()%0D%0Aconst%20someInstance%20%3D%20new%20SomeClass()%0D%0AsomeInstance.method('will-error-here')%0D%0A | |
function someFactory<T>() { | |
return class { | |
method(someParam : T) { | |
} | |
} | |
} |
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 happyUsersWithHappiness | |
= _(users) | |
.map<IHappyUser>(user => ({ ...user, happiness: getHappiness(user.id) })) | |
.filter<RegExp>(/* filtering with RegExp */) | |
.reduce<HappyUsersObj>(/* some reducer, that will know iterator will be of type _.MemoIterator<HappyUsersObj, IHappyUser> */) | |
.value(); |
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
export type HOCType<P extends {}, V extends {}> = ( | |
BaseComponent: React.StatelessComponent<P>, | |
) => React.StatelessComponent<V>; | |
function withAuthentication<OwnProps extends {}>(): | |
HOCType<OwnProps & { user: IUser }, OwnProps> = /* ... /* |
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
export const AuthenticatedPage = withAuthentication(Page); // typeof AuthenticatedPage ? |
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
interface IPageProps { | |
title: string; | |
} | |
export const AuthenticatedPage = withAuthentication<IPageProps>(Page); | |
// typeof AuthenticatedPage is inferred as React.StatelessComponent<IPageProps> | |
// typeof IPageProps is inferred as React.StatelessComponent<IPageProps & { user: IUser }> |
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
interface IBody { | |
payload: { | |
changedUser: { | |
id: string; | |
name: string; | |
username: string; | |
}; | |
}; | |
} |