Created
August 27, 2016 08:17
-
-
Save erdaldalkiran/7bda7016a2f48238f2bf68b8207e7533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyMatcher { | |
constructor(value) { | |
this.value = value; | |
} | |
[Symbol.match](string) { | |
var index = string.indexOf(this.value); | |
if (index === -1) { | |
return null; | |
} | |
return [`${this.value} altered`]; | |
} | |
} | |
console.log('foobar'.match('foo')) | |
var fooMatcher = 'foobar'.match(new MyMatcher('foo')); | |
console.log(fooMatcher) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment