1.0.2 • Published 9 years ago

rgu v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

rgu

set argument type requirements and defaults

read: 'argue'.

What

rgu allows you to define the types of arguments you expect in a function, assign them correctly, and default them if they are missing.

rgu is a thought experiment and probably shouldn't be used in production.

Usage

function x(a,b,c){
    var result = rgu(this, arguments, [
        ['string', 'bar'], // expect a string, default to 'bar'
        ['number', 0], // expect a number, default to 0
        'function' // expect a function, default to undefined
    ]);

    if(result) return result(); // If rgu was required to fix the arguments, return its result.

    a -> 'foo'
    b -> 0
    c -> {baz:'bazinga'}

    return 'majigger';
}

x('foo', {baz:'bazinga'}) -> 'majigger'
1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago