Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds example for .map and update README.
- Loading branch information
Chakrit Wichian
committed
Sep 10, 2013
1 parent
97b375c
commit 04d918a
Showing
5 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a - First! I am the very very first file. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b - I am the second file, residing in B. 2nd's not a bad place, ain't it? |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
c - I'm the last one. I get to write the ending! |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
var FILES = 'file1.txt,file2.txt,file3.txt'.split(',') | ||
, jam = require('../lib/jam') | ||
, fs = require('fs'); | ||
|
||
// normal form | ||
var readFile = function(next, filename) { fs.readFile(filename, next); } | ||
, catResult = function(next, result) { | ||
process.stdout.write(result.join('')); | ||
next(); | ||
}; | ||
|
||
function normal(next) { | ||
console.log("NORMAL FORM ::"); | ||
jam(jam.map(FILES, readFile)) | ||
(catResult) | ||
(next); | ||
} | ||
|
||
function monad(next) { | ||
console.log("MONAD FORM ::"); | ||
jam(jam.return(FILES)) | ||
(jam.map(readFile)) | ||
(catResult) | ||
(next); | ||
} | ||
|
||
jam(normal)(monad)(function(e) { if (e) console.error(e); }); | ||
|