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

Add "guard" parameters #9

Open
ryanve opened this issue Dec 16, 2013 · 0 comments
Open

Add "guard" parameters #9

ryanve opened this issue Dec 16, 2013 · 0 comments

Comments

@ryanve
Copy link
Owner

ryanve commented Dec 16, 2013

Methods whose signature is (value [, number]) cannot be used directly as array iterators whose 2nd argument is the array index. It'd be useful add guard params that allow the following examples to work with standard array methods:

array.filter(verge.inViewport)
array.some(verge.inViewport)
array.map(verge.rectangle)

We can achieve this similar to how underscore uses guard params. For example:

function rectangle(el, pad, guard) {
  pad = !guard && +pad || 0; // number and not NaN

We had some partial undocumented support for this in some versions. We should add it to all applicable methods with this signature and document the usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant