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 isObj(val){ | |
return val !== null && typeof val === "object"; | |
} | |
function recurse(acc, obj){ | |
for (var p in obj) { | |
acc[p] = isObj(obj[p]) ? recurse(acc[p] || {}, obj[p]) : obj[p]; | |
} | |
return acc; |
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 getId = (start): (() => number) => (): number => start++; | |
export class SomeData { | |
static getId = getId(0); | |
public icon: string; | |
public text: string = ""; | |
public color: string; | |
public idPrefix: string = 'data-'; | |
public id: string; |
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 StylingComponent { | |
} | |
StylingComponent.$$styleContext = { | |
classNames: "", | |
userProps: { | |
width: null, | |
height: null, | |
paddingLeft: 10, | |
paddingRight: 10 |
I hereby claim:
- I am cenkce on github.
- I am cenkce (https://keybase.io/cenkce) on keybase.
- I have a public key ASC-gr0h_WL5mVX2DVovhlHULn_2Ts-nUed-Ucdtm9S05wo
To claim this, I am signing this object:
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 firstArray = ['a', 'b', 'c', 'd', 'e']; | |
const secondArray = ['a', 'b', 'c', 'x', 'a', 'k', 'x','a','r']; | |
const acc = {}; | |
const table = {}; | |
function explore(val){ | |
if(val !== undefined && !acc[val]){ | |
table[val] = true; | |
} else if(val !== undefined) { |
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 shareLinks: { | |
socialMedia: { | |
twitter: "twitter", | |
facebook: "facebook" | |
}, | |
email: "email", | |
anotherWay: "anotherWay" | |
} | |
// or more complex types |
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
// We can't pass single provider name like Facebook | |
// Because it waits a complete object of the complexDataType | |
declare function share(provider: complexDataType):void; |
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 ValuesOfType = "any prop 1" | "any prop 2" | "any prop 3" // ... |
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
// Extracts only non nested values | |
type ExtractValue<T extends {[key:string]: any}> = T extends {[key:string]: any} ? T[keyof T] : T; | |
// Recusively extracts values | |
type ExtractValues<T extends {[key:string]: any}> = T extends {[key:string]: any} ? ExtractValue<T[keyof T]> : never; | |
type ValuesOfComplexType = ExtractValues<ComplexType>; | |
// or | |
type ValuesOfComplexType = ExtractValues<typeof ComplexConstants>; | |
// assings the values | |
// "any value 1" | "any value 2" | "any value 3" | "any value 4" ... |
OlderNewer