Skip to content

Instantly share code, notes, and snippets.

View hw0k's full-sized avatar
🎯

Hyunwook Nam hw0k

🎯
  • localhost
  • 07:32 (UTC +09:00)
View GitHub Profile
function pipe(...functions) {
return input => functions.reduce((value, func) => func(value), input);
}
function compose(...functions) {
return input => functions.reduceRight((value, func) => func(value), input);
}
function createPage({
title = '', // 해당 값이 없을 때 기본으로 사용할 값
body = '',
tags = [],
actions = [],
} = {}) { /* ... */ }
// usage
createPage({
title: 'Hello world!',
@hw0k
hw0k / createPage.js
Last active June 28, 2020 09:53
FND 5
function createPage(title, body, tags, actions) { /* ... */ }
// usage
createPage('Hello world!', 'bodybodybody', ['onboarding'], []);
@hw0k
hw0k / createPage.js
Last active June 28, 2020 09:53
FND 6
function createPage({ title, body, tags, actions }) { /* ... */ }
// usage
createPage({
title: 'Hello world!',
body: 'bodybodybody',
tags: ['onboarding'],
actions: [],
});
@hw0k
hw0k / send.js
Last active June 28, 2020 09:14
FND 4
async function sendNotifications() {
const preferences = await UserPreferencesRepository.findAll();
preferences
.filter(isPreferenceHasAllowedNotification)
.forEach(NotificationModule.send);
}
function isPreferenceHasAllowedNotification(preference) {
return preference.hasAllowedNotification;
@hw0k
hw0k / send.js
Last active June 28, 2020 09:03
FND 3
async function sendNotifications() {
const preferences = await UserPreferencesRepository.findAll();
preferences.forEach(preference => {
if (preference.hasAllowedNotification) {
NotificationModule.send(preference);
}
});
}
@hw0k
hw0k / checkDevice.js
Last active June 28, 2020 08:33
FND 2
async function checkS10(deviceName) {
return deviceName.includes('Galaxy S10');
}
@hw0k
hw0k / checkDevice.js
Last active June 28, 2020 08:27
FND 1
import DeviceInfo from 'react-native-device-info';
async function checkS10() {
const deviceName = await DeviceInfo.getDeviceName();
return deviceName.includes('S10');
}
_ _ _
>(.)__ <(.)__ =(.)__
(___/ (___/ (___/
@hw0k
hw0k / index.ts
Last active April 13, 2020 10:25
FP Intro 9
function* infiniteValue(acc = 0) {
yield acc;
yield* infiniteValue(acc + 1);
}
const iter = infiniteValue();
console.log(iter.next().value); // 0
console.log(iter.next().value); // 1
console.log(iter.next().value); // 2
console.log(iter.next().value); // 3