Skip to content

Instantly share code, notes, and snippets.

View hg-pyun's full-sized avatar
🎯
Focusing

Haegul Pyun hg-pyun

🎯
Focusing
View GitHub Profile
@skt-t1-byungi
skt-t1-byungi / abbr.txt
Last active May 23, 2021 05:33
내가 코딩때 쓰는 약어 모음
app => application
acc => accumulate
arr => array
abs => absolute
addr => address
arg => argument
args => arguments
attr => attribute
attrs => attributes
auth => authenticate
@indongyoo
indongyoo / reduce+generator.js
Last active December 6, 2018 07:44
reduce+generator
function reduce(f, acc, iter) {
if (arguments.length == 2) {
iter = acc[Symbol.iterator]();
acc = iter.next().value;
}
for (const a of iter) acc = f(acc, a);
return acc;
}
reduce((a, b) => a + b, function*() {
// ES6
function* foo(){
yield bar();
}
// ES5 Compiled
"use strict";
var _marked = /*#__PURE__*/ regeneratorRuntime.mark(foo);
@hg-pyun
hg-pyun / async-wait.01.js
Created October 7, 2018 05:05
async-wait.01.js
// ES7
async function foo() {
await bar();
}
// ES5 complied
let foo = (() => {
var _ref = _asyncToGenerator(function*() {
yield bar();
});
@hg-pyun
hg-pyun / iterator.07.js
Created October 4, 2018 15:32
iterator.07.js
function* idMaker(){
var index = 0;
while(index < 3)
yield index++;
}
const gen = idMaker();
console.log(gen.next().value); // 0
console.log(gen.next().value); // 1
@hg-pyun
hg-pyun / iterator.04.js
Created October 4, 2018 15:12
iterator.04.js
const arr = [];
for(let i=0; i<100; i++) {
arr.push(0);
}
console.log(arr);
@hg-pyun
hg-pyun / iterator.03.js
Created October 4, 2018 14:58
iterator.03.js
const iterable = {
[Symbol.iterator]() {
return {
i: 0,
next() {
if (this.i < 3) {
return { value: this.i++, done: false };
}
return { value: undefined, done: true };
}
@hg-pyun
hg-pyun / iterator.01.js
Created October 4, 2018 14:25
iterator.01.js
/* array */
let iterable = [10, 20, 30];
for (let value of iterable) {
console.log(value); // 10 20 30
}
/* string */
let iterable = "boo";
@hg-pyun
hg-pyun / currying.12.js
Created September 16, 2018 12:50
currying.12.js
// react
const handleChange = (fieldName) => (event) => {aveField(fieldName, event.target.value)}
<input type="text" onChange={handleChange('email')} ... />
@hg-pyun
hg-pyun / currying.11.js
Created September 16, 2018 12:49
currying.11.js
getters: {
// ...
getTodoById: (state, getters) => (id) => {
return state.todos.find(todo => todo.id === id) }}
store.getters.getTodoById(2) // -> { id: 2, text: '...', done: false }