node-emoji
node-emoji copied to clipboard
Feature: allow search to take in a RegExp
Change emoji.search()
to return emoji whose name contains the search string. I can imagine two approaches:
- Always treat the argument as a substring. E.g.,
emoji.search('evil')
→[{ key: 'see_no_evil', emoji: '🙈' }, { key: 'see_no_evil', emoji: '🙈' }, { key: 'see_no_evil', emoji: '🙈' }]
. (Example results not exhaustive.)- This is probably easiest and most lightweight to implement, but is not backwards compatible with old code that uses this library.
- Allow standard regular expressions in the argument. E.g.,
emoji.search('.*evil')
→[{ key: 'see_no_evil', emoji: '🙈' }, { key: 'see_no_evil', emoji: '🙈' }, { key: 'see_no_evil', emoji: '🙈' }]
. (Example results not exhaustive.)- This may be more complicated, but it will be backwards compatible and it won't return unexpected results.
Always treat the argument as a substring
I think that is the current behaviour.
Allow standard regular expressions in the argument
We could allow RegExp objects to be passed that are evaluated for each emoji.