I hereby claim:
- I am smidhonza on github.
- I am smidhonza (https://keybase.io/smidhonza) on keybase.
- I have a public key whose fingerprint is EDFE 09AF A5C7 49E7 DD61 4E1C CF19 A0D6 6147 4AE9
To claim this, I am signing this object:
const has = <T extends object>(property: keyof T) => (obj: T) => !!obj[property]; | |
const head: <T>(array: T[]) => T | undefined = (array) => array[0]; | |
const prop = <T>(property: keyof T) => (object: T) => object[property]; | |
const path = (bits: string[]) => (object: any): any => { | |
const [property, ...rest] = bits; | |
const value = prop(property)(object); | |
if (head(rest)) { | |
return path(rest)(value); | |
} | |
return value; |
import React from 'react'; | |
const Demo = () => { | |
const [value, setValue] = React.useState(); | |
const [data, setData] = React.useState(); | |
React.useEffect(() => { | |
const fetchData = async () => { | |
if (value) { // dont call the fetch on initial load when value is empty | |
const result = await fetch('https://.....'); |
I hereby claim:
To claim this, I am signing this object:
export const curry = (fn) => { | |
const r = (args) => { | |
if (args.length >= fn.length) { | |
return fn(...args); | |
} | |
return (...secArgs) => r([...args, ...secArgs]); | |
}; | |
return (...args) => r(args); | |
}; |