This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const series = promises => new Promise((resolve, reject) => { | |
let len = promises.length | |
let i = 0 | |
let results = [] | |
const doPromise = () => | |
promises[i]() | |
.then(res => { | |
i++ | |
results.push(res) | |
return i < len ? doPromise() : resolve(results) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wait = ms => () => new Promise(resolve => setTimeout(() => resolve(ms), ms)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QueryString { | |
parse(search) { | |
let obj = {} | |
search = search.replace(/^\?/, "") | |
const pairs = search.split("&") | |
pairs.forEach(pair => { | |
const [key, val] = pair.split("=") | |
obj[key] = val | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from "lodash" | |
/** | |
* 1000.234 => 0010,000.234 | |
* @param val 元の値 | |
* @param payload | |
* @param keta ゼロ字詰する桁数 | |
* @param fixed 小数点以下の表示桁数 | |
*/ | |
export default (val, { keta = 0, fixed = 0 } = {}) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hira2kata(str) { | |
return str.replace(/[\u3041-\u3096]/g, (match) => { | |
const chr = match.charCodeAt(0) + 0x60; | |
return String.fromCharCode(chr); | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat ./tmp/pids/server.pid | xargs kill -9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* rootからtargetのスクロール量を計算する | |
*/ | |
export default function calcOffsetTop(target: HTMLElement, root: HTMLElement = document.body) { | |
if(!target) throw new Error('[no target]'); | |
let elm: HTMLElement = target | |
let offset: number = 0 | |
while(true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 数字に漢字の桁を付ける | |
* ex: 1234567890123 => 1兆2345億6789万123 | |
* @param {String | Number} num 数字 | |
* @return {String} 漢字付きの数字 | |
*/ | |
export default function num2ja(num) { | |
const keta = ['', '千', '万', '億', '兆'] | |
let jaNum = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ー |