Skip to content

Commit 1352536

Browse files
committed
feat(connect): add junction example
1 parent f33eb8f commit 1352536

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/connect/junction-example.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use strict";
2+
import Junction from "./junction";
3+
import assert from "power-assert";
4+
let junction = new Junction();
5+
junction.use(function toUpperCase(res, next) {
6+
res.value = res.value.toUpperCase();
7+
next();
8+
});
9+
junction.use(function exclamationMark(res, next) {
10+
res.value = res.value + "!";
11+
next();
12+
});
13+
junction.use(function (error, res, next) {
14+
console.error(error.stack);
15+
next();
16+
});
17+
18+
let text = "hello world";
19+
junction.process(text, function (error, result) {
20+
if (error) {
21+
console.error(error);
22+
}
23+
let value = result.value;
24+
assert.equal(value, "HELLO WORLD!");
25+
});

0 commit comments

Comments
 (0)