summaryrefslogtreecommitdiff
path: root/file.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-05-05 23:31:56 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-05-05 23:31:56 +0200
commitc8d900349a2a518c5fee9610b6a903a2ff546e50 (patch)
tree3e99c3f388068e78743653dec46cf106437a7052 /file.js
parent075c26e94f16379b302570e689d244edef94cb04 (diff)
downloadbrokentalents-c8d900349a2a518c5fee9610b6a903a2ff546e50.tar.gz
brokentalents-c8d900349a2a518c5fee9610b6a903a2ff546e50.zip
cache many small periods on disk and aggregate them
Diffstat (limited to 'file.js')
-rw-r--r--file.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/file.js b/file.js
index 16f2c94..b750921 100644
--- a/file.js
+++ b/file.js
@@ -1,12 +1,13 @@
#!/usr/bin/node
const R = require('ramda'),
- Future = require('fluture')
+ Future = require('fluture'),
+ fs = require('fs'),
fsPath = require('fs-path');
function loadFPayloads(config) {
return R.curry((file) =>
- Future.node((cb) => fsPath.readFile(file, 'utf8', cb))
+ Future.node((cb) => fs.readFile(file, 'utf8', cb))
.chain(Future.encase(JSON.parse))
);
}
@@ -14,6 +15,7 @@ function loadFPayloads(config) {
function saveFPayloads(config) {
return R.curry((file, data) =>
Future.node((cb) => fsPath.writeFile(file, JSON.stringify(data), cb))
+ .map(() => data)
);
}
@@ -23,8 +25,15 @@ function saveFPayloadsTimestamped(config) {
);
}
+function loadFPayloadsTimestamped(config) {
+ return R.curry((timestamp) =>
+ loadFPayloads(config)(config.pattern(timestamp))
+ );
+}
+
module.exports = {
loadFPayloads,
+ loadFPayloadsTimestamped,
saveFPayloads,
saveFPayloadsTimestamped,
};