Skip to content

Instantly share code, notes, and snippets.

export const delay = (time: number) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, time);
});
};
@JaeYeopHan
JaeYeopHan / plugin.js
Last active March 27, 2018 04:54
plugin.js
const minify = require('html-minifier').minify;
const fs = require('fs');
class HtmlMinifierPlugin {
constructor(options) {
this.options = options;
}
apply(compiler) {
compiler.plugin("emit", (compilation, callback) => {
fs.readFile(this.options.template, 'utf-8', (err, html) => {
@JaeYeopHan
JaeYeopHan / getFilterdPair.ts
Created March 8, 2018 07:40
Filtering object by passing checker function to util
export const getFilteredPair = (base: object, checker: (value: any) => boolean): object => {
return Object.keys(base).reduce((acc, key) => {
if (checker(key)) {
acc[key] = base[key];
}
return acc;
}, {});
}
@JaeYeopHan
JaeYeopHan / pipe.js
Created February 26, 2018 01:52
JavaScript functions - pipe
export function pipe(...fns) {
return param => fns.reduce(
(result, fn) => fn(result),
param
)
}
@JaeYeopHan
JaeYeopHan / requiredParam.js
Created February 26, 2018 01:50
JavaScript code snippets - Required parameter function
export function requiredParam (param) {
const requiredParamError = new Error(
`Required parameter, "${param}" is missing.`
)
// preserve original stack trace
if (typeof Error.captureStackTrace === ‘function’) {
Error.captureStackTrace(
requiredParamError,
requiredParam
)
@JaeYeopHan
JaeYeopHan / flatten.js
Created February 24, 2018 10:23
JavaScript function utils - Deep Flatten
function flatten(arr) {
return function f(arr, newArr) {
arr.forEach(function(v)) {
Array.isArray(v) ? f(v, newArr) : newArr.push(v);
});
return newArr;
}(arr, []);
}
@JaeYeopHan
JaeYeopHan / .gitconfig
Last active September 25, 2017 07:18
Git command alias
[user]
name = JaeYeopHan
email = ljyhanll@gmail.com
[color]
status = auto
branch = auto
diff = auto
ui = auto
@JaeYeopHan
JaeYeopHan / .eslintrc.js
Created June 2, 2017 01:25 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@JaeYeopHan
JaeYeopHan / test_template.java
Last active May 30, 2017 01:26
JUnit template
@Test
public void test() {
assertThat(testFunction(), is(""));
}
public String testFunction() {
return "";
}
@JaeYeopHan
JaeYeopHan / index.js
Created May 10, 2017 10:09
setting redux devtool
import React from 'react';
import ReactDOM from 'react-dom';
import App from './containers/App';
import './index.css';
import {createStore} from 'redux';
import reducers from './reducers';
import {Provider} from 'react-redux';
const store = createStore(reducers, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());