Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.