On Mon, Mar 18, 2013 at 6:45 AM, Eric Muyser <[email protected]> wrote:
> I've done a lot of programming and this is definitely useful. I've come up
> with a few times but never follow through with using it. The jQuery core
> has a lot of argument type checking and should probably use something like
> this so it's cleaner and clear which arguments it accepts,
No thanks. The arguments hockey jungle in jQuery is painstakingly designed
for fastest possible code execution path, while simultaneously maintaining
support for insane user requests over the last 6 years.
In a nutshell: jQuery isn't implementing to asserts (ie. function asserts)
anytime soon.
> but that's why it has docs.
Which are _really_ exhaustive—every single function signature and
polymorphic "overload" is described in a consistent form in the docs.
> If you don't have docs, this is more useful. If you only accept 1
> argument, usually options, eg. options = {myParam: 4, isThis: 10} so you
> can use it as such: myFunction({myParam: 10, isThis: function() {}}); then
> that's the case where I always want to use something like this. I don't
> like how argument lists can get long and polluted, eg.
> myFunctionDoesAwesome('with this', 'and this argument', null, null, 10, 20,
> 303, null, null, true); and so I would use 1 param options with default
> values, and in that case I want validation against each possible argument.
+1, it's easiest API design win: single options object as primary
signature, optional special cased parametric polymorphism if you're feeling
sassy.
Rick
>
>
> On Mon, Mar 18, 2013 at 7:31 PM, chakrit <[email protected]> wrote:
>
>> The use case is just to simplify arguments validation, which for me, is
>> getting repetitive and cumbersome in a project I'm currently building.
>>
>> So I wrote the module.
>>
>> Added an example.js here:
>> https://github.com/chakrit/have/blob/master/example.js if it'll helps.
>>
>> On Sunday, March 17, 2013 1:35:38 PM UTC+7, Pavel Kostenko wrote:
>>>
>>> Didn't get it, can you provide a real life use case with explanation?
>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.