使用示例:
timeTrigger(5000, 1000, function (percent) {
console.log(percent);
});
回调函数中的 percent 用来返回当前执行的进度,数值在 0 - 1 之间,执行结果如下:
0
0.2002
/** | |
* trans | |
* 将valine导出的评论转换成CSV格式 | |
* @param {String} input - 从 valine 导出的 JSON 文本 | |
* @return {String} CSV 文本 | |
*/ | |
const trans = input => { | |
let output = []; | |
const field = [ | |
"nick", |
const { map, groupBy } = require("rambda"); | |
const nestGroupBy = ([fn, ...fns], list) => { | |
if (!fn) { | |
return list; | |
} | |
const g = groupBy(fn, list); | |
return map(v => { | |
return nestGroupBy(fns, v); | |
}, g); |
# Define samplingRate | |
samplingRate = (interval) -> | |
mark = 0 | |
-> | |
now = Date.now() | |
return false if now - mark < interval | |
mark = now | |
# How to use | |
sampling = samplingRate 1000 |
使用示例:
timeTrigger(5000, 1000, function (percent) {
console.log(percent);
});
回调函数中的 percent 用来返回当前执行的进度,数值在 0 - 1 之间,执行结果如下:
0
0.2002