Comparing version 0.5.1 to 0.5.2
@@ -47,2 +47,3 @@ "use strict"; | ||
} | ||
console.log("combineMatchers", args); | ||
return function (match) { | ||
@@ -69,2 +70,3 @@ return rxjs_1.Observable.from(args) | ||
var _this = _super.call(this) || this; | ||
_this.matchers = []; | ||
if (args.length < 1) { | ||
@@ -81,4 +83,4 @@ console.error("rules must at least have a handler"); | ||
var _this = this; | ||
console.log("trying to match a rule"); | ||
return this.matchers | ||
console.log("SimpleRule.tryMatch", this.matchers); | ||
return this.matchers.length | ||
? combineMatchers.apply(void 0, this.matchers)(match) | ||
@@ -96,2 +98,3 @@ .do(function (m) { return console.log("match", m); }) | ||
SimpleRule.prototype.prependMatcher = function (matcher) { | ||
console.log("SimpleRule.prependMatcher", matcher); | ||
return new (SimpleRule.bind.apply(SimpleRule, [void 0, matcher].concat(this.matchers, [this.handler])))(); | ||
@@ -98,0 +101,0 @@ }; |
{ | ||
"name": "prague", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "experimental Rx-based bot technology", | ||
@@ -5,0 +5,0 @@ "main": "dist/prague.js", |
@@ -61,2 +61,3 @@ import { Observable } from 'rxjs'; | ||
export function combineMatchers<M extends Match>(... args: Matcher[]): Matcher<M, any> { | ||
console.log("combineMatchers", args); | ||
return match => | ||
@@ -77,3 +78,3 @@ Observable.from(args) | ||
export class SimpleRule<M extends Match> extends BaseRule<M> { | ||
private matchers: Matcher[]; | ||
private matchers: Matcher[] = []; | ||
private handler: Handler; | ||
@@ -93,4 +94,4 @@ | ||
tryMatch(match: M): Observable<RuleResult> { | ||
console.log("trying to match a rule"); | ||
return this.matchers | ||
console.log("SimpleRule.tryMatch", this.matchers); | ||
return this.matchers.length | ||
? (combineMatchers<M>(... this.matchers)(match) as Observable<Match>) | ||
@@ -109,2 +110,3 @@ .do(m => console.log("match", m)) | ||
prependMatcher<L extends Match>(matcher: Matcher<L, M>) { | ||
console.log("SimpleRule.prependMatcher", matcher); | ||
return new SimpleRule<L>( | ||
@@ -151,3 +153,3 @@ matcher, | ||
return observize(this.matcher(match)) | ||
.flatMap(m => this.rule.tryMatch(m)); | ||
.flatMap(m => this.rule.tryMatch(m)); | ||
} | ||
@@ -154,0 +156,0 @@ } |
Sorry, the diff of this file is not supported yet
123532
2028