Skip to content

Commit

Permalink
Update readme to put more emphasis on modular usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaq committed Jun 7, 2020
1 parent 6b7679f commit 1fcbcbd
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,6 @@ For more information:

> `npm install --save fluture`
On older environments you may need to polyfill one or more of the following
functions: [`Object.create`][JS:Object.create],
[`Object.assign`][JS:Object.assign] and [`Array.isArray`][JS:Array.isArray].

### CommonJS Module

Although the Fluture source uses the EcmaScript module system,
the `main` file points to a CommonJS version of Fluture.

```js
const fs = require ('fs')
const Future = require ('fluture')

const getPackageName = function (file) {
return Future.node (function (done) { fs.readFile (file, 'utf8', done) })
.pipe (Future.chain (Future.encase (JSON.parse)))
.pipe (Future.map (function (x) { return x.name }))
}

getPackageName ('package.json')
.pipe (Future.fork (console.error) (console.log))
```

### EcmaScript Module

Fluture is written as modular JavaScript.
Expand Down Expand Up @@ -110,6 +87,29 @@ of Fluture's dependencies pre-bundled.
[Fluture Module]: https://cdn.jsdelivr.net/gh/fluture-js/Fluture@12.2.1/dist/module.js
[Fluture Module Minified]: https://cdn.jsdelivr.net/gh/fluture-js/Fluture@12.2.1/dist/module.min.js

### CommonJS Module

Although the Fluture source uses the EcmaScript module system,
the `main` file points to a CommonJS version of Fluture.

On older environments you may need to polyfill one or more of the following
functions: [`Object.create`][JS:Object.create],
[`Object.assign`][JS:Object.assign] and [`Array.isArray`][JS:Array.isArray].

```js
const fs = require ('fs')
const Future = require ('fluture')

const getPackageName = function (file) {
return Future.node (function (done) { fs.readFile (file, 'utf8', done) })
.pipe (Future.chain (Future.encase (JSON.parse)))
.pipe (Future.map (function (x) { return x.name }))
}

getPackageName ('package.json')
.pipe (Future.fork (console.error) (console.log))
```

## Interoperability

[<img src="https://raw.github.com/fantasyland/fantasy-land/master/logo.png" align="right" width="82" height="82" alt="Fantasy Land" />][FL]
Expand Down

0 comments on commit 1fcbcbd

Please sign in to comment.