Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//:: String -> LazyEither (Either e [String])
const ls = path => LazyEither(resolve =>
fs.readdir(path, (err, files) => resolve(err ? S.Left(err) : S.Right(S.map(join(path), files)))))
//:: String -> LazyEither (Either e String)
const cat = file => LazyEither(resolve =>
fs.readFile(file, {encoding: 'utf8'}, (err, data) => resolve(err ? S.Left(err) : S.Right(data))))
//:: String -> LazyEither (Either e String)
const catDir =
S.pipe([ls,
S.chain(S.traverse(LazyEither, cat)),
S.map(S.unlines)])
// A LazyEither instance is executed when value gets called:
catDir(os.homedir()).value(S.either(console.error, console.log))
return new LazyEither(resolve => {
self._value(S.compose(resolve, S.either(leftFn, rightFn)))
})
}
return new LazyEither(resolve => {
self._value(S.either(a => resolve(S.Left(a)), b => f(b)._value(resolve)))
})
}