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 fs = require('fs') | |
| const R = require('ramda') | |
| // Utils | |
| const log = R.tap(console.log) | |
| const emptyArray = () => [] | |
| // getObjectFromFile | |
| const parseJSONFromFile = R.compose(JSON.parse, fs.readFileSync) | |
| const handleError = R.compose(emptyArray, log) |
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 fs = require('fs') | |
| const R = require('ramda') | |
| const parseJSONFromFile = R.pipe(fs.readFileSync, JSON.parse) | |
| const products = parseJSONFromFile('../products.json') | |
| console.log(products) |
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 fs = require('fs') | |
| const R = require('ramda') | |
| const parseJSONFromFile = R.compose(JSON.parse, fs.readFileSync) | |
| const products = parseJSONFromFile('../products.json') | |
| console.log(products) |
NewerOlder