Skip to content

Instantly share code, notes, and snippets.

View hw0k's full-sized avatar
🎯

Hyunwook Nam hw0k

🎯
  • localhost
  • 15:35 (UTC +09:00)
View GitHub Profile
@hw0k
hw0k / index.ts
Created April 13, 2020 09:46
FP Intro 8
type Func = (par: number) => string;
function canBeParameter(func: Func) {
// do Something
}
function canReturn(): Func {
return (par) => par.toString();
}
@hw0k
hw0k / index.ts
Created April 13, 2020 09:04
FP Intro 7
function hello(name) {
return `Hello, ${name}.`;
}
function main() {
const helloString = hello('Henry');
console.log(helloString);
}
main();
@hw0k
hw0k / index.ts
Created April 13, 2020 09:02
FP Intro 6
const someName = 'Henry';
function hello() {
console.log(`Hello, ${someName}.`);
}
@hw0k
hw0k / index.ts
Created April 13, 2020 08:41
FP Intro 5
interface Person {
readonly name: string;
readonly age: number;
}
function addAge(person: Person) {
const newPerson: Person = {
...person,
age: person.age + 1,
};
@hw0k
hw0k / index.ts
Created April 13, 2020 08:34
FP Intro 4
interface Person {
name: string;
age: number;
}
function addAge(person: Person) {
person.age += 1;
return person;
}
@hw0k
hw0k / index.ts
Created April 13, 2020 08:09
FP Intro 3
let globalVariable = 10;
const impureFunction = (x: number, y: number) => {
globalVariable = y;
return x + y;
};
function main() {
console.log(impureFunction(1, 2)); // 3
console.log(impureFunction(1, 2)); // 3
@hw0k
hw0k / index.ts
Last active April 13, 2020 08:01
FP Intro 2
let globalVariable = 10;
const impureFunction = (x: number, y: number) => x + y + globalVariable;
function main() {
console.log(impureFunction(1, 2)); // 13
globalVariable = 20;
console.log(impureFunction(1, 2)); // 23
}
@hw0k
hw0k / index.ts
Created April 13, 2020 07:41
FP Intro 1
const pureFunction = (x: number, y: number) => x + y;
@hw0k
hw0k / config.js
Created April 9, 2020 07:17
RNSW 2
import { configure } from '@storybook/react';
configure(require.context('../src', true, /\.stories\.js?$/), module);
@hw0k
hw0k / package.json
Created April 9, 2020 07:03
RNSW 1
{
"name": "RNStorybookWeb",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"storybook": "start-storybook -p 9001 -c .storybook -s .storybook/assets", // 추가
"storybook:build": "build-storybook -c .storybook -s .storybook/assets", // 추가
"start": "react-native start",