diff --git a/src/values/base.ts b/src/values/base.ts index c143cb1..6775d44 100644 --- a/src/values/base.ts +++ b/src/values/base.ts @@ -32,14 +32,11 @@ export class LanguageSpecificValue { /** * Create a matcher function for this value and the specified language. * - * @param {Language} language + * @param language */ - public matcher(language: Language) { + public matcher(language: Language): Matcher { const value = this.factory(language); - - return function(text: string, options?: EncounterOptions) { - return value.matcher.match(text, options); - }; + return value.matcher; } } diff --git a/test/value-matchers.test.ts b/test/value-matchers.test.ts index 0d4c429..ebe8652 100644 --- a/test/value-matchers.test.ts +++ b/test/value-matchers.test.ts @@ -5,13 +5,13 @@ describe('Value: Matchers', () => { it('Can parse string', () => { const matcher = booleanValue().matcher(en); - return matcher('yes') + return matcher.match('yes') .then(v => expect(v).toEqual(true)); }); it('Can handle invalid value', () => { const matcher = booleanValue().matcher(en); - return matcher('cookies') + return matcher.match('cookies') .then(v => expect(v).toEqual(null)); });