diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 23:31:56 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 23:31:56 +0200 |
| commit | c8d900349a2a518c5fee9610b6a903a2ff546e50 (patch) | |
| tree | 3e99c3f388068e78743653dec46cf106437a7052 /file.js | |
| parent | 075c26e94f16379b302570e689d244edef94cb04 (diff) | |
| download | brokentalents-c8d900349a2a518c5fee9610b6a903a2ff546e50.tar.gz brokentalents-c8d900349a2a518c5fee9610b6a903a2ff546e50.zip | |
cache many small periods on disk and aggregate them
Diffstat (limited to 'file.js')
| -rw-r--r-- | file.js | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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, }; |
