Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bugs and optimized code #4

Merged
merged 4 commits into from
Nov 27, 2013
Merged

Conversation

LarryBattle
Copy link
Contributor

I had some free time during my lunch to look over your code and here's what I fixed.

  • Used hash tables instead of Array.prototype.some() for looking up suffix and salutation.
  • Created function to convert from lexical to western order
  • Used Array.prototype.shift() and Array.prototype.pop() instead of Array.prototype.splice()
  • Forced input to .parse() to a string.
  • Returns empty object is no input is supplied.
  • Bug fix: Trimmed input to avoid creating empty tokens

Example without trimmed input
Input:

whosit.parse(" Larry Battle ")

Returns:

Object {first: "", middle: "Larry", last: "Battle "}

Example with trimmed input
Input:

whosit.parse(" Larry Battle ")

Returns:

Object {first: "Larry", last: "Battle"}

- Used hash tables instead of Array.prototype.some() for looking up suffix and salutation.
- Created function to convert from lexical to western order
- Used `Array.prototype.shift()` and `Array.prototype.pop()` instead of `Array.prototype.splice()`
- Forced input to `.parse()` to a string.
- Returns empty object is no input is supplied.
- Replaced `.trim()` and `.replace()` calls with `.match()`
- Converted `"` to `'`
@LarryBattle
Copy link
Contributor Author

Check out 11b16a7. Most of the bugs are fixed now.

@freshlogic
Copy link
Member

Looks good. Thanks!

Gonna merge this in and clean it up a bit.

freshlogic added a commit that referenced this pull request Nov 27, 2013
Fixed bugs and optimized code
@freshlogic freshlogic merged commit b8960a8 into mediocre:master Nov 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants