gr2m / initials

extract initials from and add initials to names
https://gr2m.github.io/initials
MIT License
44 stars 14 forks source link

same initials for different names #12

Closed zoepage closed 9 years ago

zoepage commented 9 years ago

For different names same initials appear. We need not just compare the Strings, but also the length of the name.

// scheme ['Moe Minutes', 'Moe Min'] -> ['MMi', 'MMi']

// test

  t.deepEqual(initials(['Moe Minutes', 'Moe Min'], 3), ['MMi', 'MMi'], 'not same name')
  t.deepEqual(initials(['Moe Minutes', 'Moe Mina'], 3), ['MMi', 'MoM'], 'not same name')

Start: function initialsForMultipleNames (names, options)

zoepage commented 9 years ago

@gr2m could you verify this or is this "a feature"? :)

gr2m commented 9 years ago

Good catch! Yes, this is a bug!

initials([['Moe Minutes', 'Moe Min'])
// returns ["MMi", "MMi"]
// should return sth like ["MoM", "MMi"]

I think this is rather an edge case, so it's not a top priority to fix, but something nice for the backlog.

zoepage commented 9 years ago

It breaks here:https://github.com/gr2m/initials/blob/gh-pages/initials.js#L176 splice changes the array dynamically in the for-loop.

possible solution: possibleInitials[i] = undefined and possibleInitials = possibleInitials.filter(Boolean) breaks 13 tests.

gr2m commented 9 years ago

closing in favor of https://github.com/gr2m/initials/issues/14

zoepage commented 9 years ago

A great idea @gr2m :)