Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Fn #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Fn #15

wants to merge 5 commits into from

Conversation

mstade
Copy link
Owner

@mstade mstade commented May 2, 2014

An effort to implement a function constructor, possibly including multiple and/or predicate dispatch.

mstade added 5 commits May 1, 2014 14:51
Previously, `rest` was always defined and passed, even if the
original call didn't supply enough arguments to reach `rest`.
This poses some problems when you expect the length of
`arguments` to match that of the original call to the variadic
function, so now `rest` is only supplied if there are actual
arguments to fill it up with. This means it'll be undefined
otherwise, and `arguments` will be identical to the original
call.

Additionally, I changed `variadic` so that it'll correctly
report `length` for the wrapped function, provided the wrapped
function `length` is 26 or below. I'd be hard pressed to
remember ever seeing a function with more than even 10
parameters, but still. This isn't an ideal solution of course,
but probably hits home 99.99% of the time which is enough.
Eventually, there will be some standard metadata, possibly
different for different types of objects. Likely, the only
distinction will be made for functions, which may have useful
metadata such as composition information or other things which
could be useful when debugging.
@mstade
Copy link
Owner Author

mstade commented May 2, 2014

Some mildly interesting benchmarks available here:
http://jsperf.com/property-access-vs-if-else-vs-switch

Main takeaway from this is that the map-based approach is probably the best from a performance vs. flexibility standpoint.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 1d415a6 on fn into 85adb2f on master.

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

Successfully merging this pull request may close these issues.

2 participants