Skip to content

Instantly share code, notes, and snippets.

@imkrish
imkrish / 03-tryCatch.js
Last active September 2, 2017 23:50
03-try-catch.js
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)
@imkrish
imkrish / 02-pipe.js
Created September 2, 2017 22:43
02-pipe.js
const fs = require('fs')
const R = require('ramda')
const parseJSONFromFile = R.pipe(fs.readFileSync, JSON.parse)
const products = parseJSONFromFile('../products.json')
console.log(products)
@imkrish
imkrish / 01-compose.js
Last active September 2, 2017 22:42
01-compose.js
const fs = require('fs')
const R = require('ramda')
const parseJSONFromFile = R.compose(JSON.parse, fs.readFileSync)
const products = parseJSONFromFile('../products.json')
console.log(products)