https://github.com/syzer/function-tools
Small (hopefully) lib for operating with files in functional programming style
https://github.com/syzer/function-tools
functional-programming library stream
Last synced: 11 days ago
JSON representation
Small (hopefully) lib for operating with files in functional programming style
- Host: GitHub
- URL: https://github.com/syzer/function-tools
- Owner: syzer
- Created: 2017-01-17T07:30:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-15T13:10:25.000Z (over 8 years ago)
- Last Synced: 2025-02-10T08:11:32.595Z (9 months ago)
- Topics: functional-programming, library, stream
- Language: JavaScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WAT [](https://travis-ci.org/syzer/function-tools)
Small (hopefully) library to interact with files in Functional Programming Style.
## AKA
All monad goodies of functional programing : `ramda`, `data.task` now combined with streams and node file programs.
# How
```bash
npm install function-file-tools --save
```
# Usage
## Using es2015 style with object-stream-tools
```js
const { readFileStream } = require('function-file-tools')
const ost = require('object-stream-tools')
const app = readFileStream(__dirname + '/README.md')
.map(ost.map(e => e.split(/\n|\t/gi))
.pipe(process.stdout))
app.fork(console.error, console.log)
```
## Using ramda curried functions
```js
const { readFileStream } = require('function-file-tools')
const ost = require('object-stream-tools')
const { split } = require('ramda')
const app = readFileStream(__dirname + '/README.md')
.map(ost.map(split(/\n|\t/gi))
.pipe(process.stdout))
app.fork(console.error, console.log)
```
## Using node v.7 with --harmony
```js
import { readFile, readFileStream, writeFile } from 'function-file-tools'
const app = readFile(__dirname + '/README.txt')
.map(e => e.split(/\n|\t/gi))
.chain(contents => writeFile(__dirname + '/.tmp.txt', contents))
// when you want to have side effect
app.fork(console.error, console.log)
```
# Test
```
ava test
```