-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathhelloWorld-strings.js
More file actions
39 lines (28 loc) · 925 Bytes
/
helloWorld-strings.js
File metadata and controls
39 lines (28 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function () {
"use strict";
var nools = require("../index");
var flow = nools.flow("Hello World", function (flow) {
//find any message that starts with hello
this.rule("Hello", [String, "s", "s =~ /^hello(\\s*world)?$/"], function (facts) {
var s = facts.s + " goodbye";
this.assert(s);
});
//find all messages then end in goodbye
this.rule("Goodbye", [String, "s", "s =~ /.*goodbye$/"], function (facts) {
console.log(facts.s);
});
});
var session = flow.getSession();
//assert your different messages
session.assert("goodbye");
session.assert("hello");
session.assert("hello world");
session.match();
//same as above getSession will assert the passed in objects
var session2 = flow.getSession(
"goodbye",
"hello",
"hello world"
);
session2.match();
})();