Skip to content

Commit

Permalink
feat(connect): add junction example
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Sep 18, 2015
1 parent f33eb8f commit 1352536
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/connect/junction-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";
import Junction from "./junction";
import assert from "power-assert";
let junction = new Junction();
junction.use(function toUpperCase(res, next) {
res.value = res.value.toUpperCase();
next();
});
junction.use(function exclamationMark(res, next) {
res.value = res.value + "!";
next();
});
junction.use(function (error, res, next) {
console.error(error.stack);
next();
});

let text = "hello world";
junction.process(text, function (error, result) {
if (error) {
console.error(error);
}
let value = result.value;
assert.equal(value, "HELLO WORLD!");
});

0 comments on commit 1352536

Please sign in to comment.