diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 18:52:59 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-05-05 18:52:59 +0200 |
| commit | 075c26e94f16379b302570e689d244edef94cb04 (patch) | |
| tree | 08a0edad5703910f557707b16f8f9a032df34e84 /file.js | |
| parent | 63da93e9f443a799208c8e706616a828fa528a3e (diff) | |
| download | brokentalents-075c26e94f16379b302570e689d244edef94cb04.tar.gz brokentalents-075c26e94f16379b302570e689d244edef94cb04.zip | |
save data to file
Diffstat (limited to 'file.js')
| -rw-r--r-- | file.js | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -0,0 +1,30 @@ +#!/usr/bin/node + +const R = require('ramda'), + Future = require('fluture') + fsPath = require('fs-path'); + +function loadFPayloads(config) { + return R.curry((file) => + Future.node((cb) => fsPath.readFile(file, 'utf8', cb)) + .chain(Future.encase(JSON.parse)) + ); +} + +function saveFPayloads(config) { + return R.curry((file, data) => + Future.node((cb) => fsPath.writeFile(file, JSON.stringify(data), cb)) + ); +} + +function saveFPayloadsTimestamped(config) { + return R.curry((timestamp, data) => + saveFPayloads(config)(config.pattern(timestamp), data) + ); +} + +module.exports = { + loadFPayloads, + saveFPayloads, + saveFPayloadsTimestamped, +}; |
