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

Fix #265 #361

Merged
merged 1 commit into from
Feb 9, 2015
Merged

Fix #265 #361

merged 1 commit into from
Feb 9, 2015

Conversation

gregglind
Copy link
Contributor

  1. We didn't throw on 'too many args' before. Should we now? If so, what?
  2. (Do docs run as tests, if so how?)
  3. (Tests inbound. WIP mostly to claim the bug :) )

@gregglind
Copy link
Contributor Author

See #265

}
} else {
keys = Array.prototype.slice.call(arguments);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might read clearer to use the _.type function:

if (_.type(keys) === 'object') {
    keys = Object.keys(keys);
} else if (arguments.length > 1) {
    keys = Array.prototype.slice.call(arguments);
}

@gregglind
Copy link
Contributor Author

Went to switch based, using _.type. I think it's very explicit now, for good or ill.

? keys
: Array.prototype.slice.call(arguments);
, ok = true
, mixedArgsMsg = "keys: if first argument is instanceof Array|Object, must be only argument."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error needs rephrasing, maybe to something like 'keys must be given single argument of Array, Object, or multiple String arguments'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephased to:

    var mixedArgsMsg = 'keys must be given single argument of Array|Object|String, or multiple String arguments'

I think that is accurate. I do wonder if we should emphasize the 'multiple arguments' part, because that is what triggered the error.

- `.keys(object)n => .keys(Object.keys(Object)`
- added exceptions for 'if first arg is non-string, then it must be only
arg.  => `.keys(Array|Object, ...)`

Warning:  `Object.keys` must exist on systems to use this functionality.
@keithamus
Copy link
Member

I'd say this is good to go. Let's get it merged in. 👍

keithamus added a commit that referenced this pull request Feb 9, 2015
@keithamus keithamus merged commit 5753ecb into chaijs:master Feb 9, 2015
@keithamus keithamus mentioned this pull request Feb 12, 2015
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