Merge pull request #777 from mintunitish/master

Minor Simplification
This commit is contained in:
Angelos Chalaris
2018-10-03 08:02:52 +03:00
committed by GitHub
2 changed files with 12 additions and 16 deletions

View File

@ -8,14 +8,12 @@ Adapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db5
```js
const isSimilar = (pattern, str) =>
[...str].reduce(
(matchIndex, char) =>
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase()
? matchIndex + 1
: matchIndex,
0
) === pattern.length
? true
: false;
(matchIndex, char) =>
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase()
? matchIndex + 1
: matchIndex,
0
) === pattern.length;
```
```js

View File

@ -1,11 +1,9 @@
const isSimilar = (pattern, str) =>
[...str].reduce(
(matchIndex, char) =>
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase()
? matchIndex + 1
: matchIndex,
0
) === pattern.length
? true
: false;
(matchIndex, char) =>
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase()
? matchIndex + 1
: matchIndex,
0
) === pattern.length;
module.exports = isSimilar;