arg-schema

Helper for jQuery style arguments declaration

Usage no npm install needed!

<script type="module">
  import argSchema from 'https://cdn.skypack.dev/arg-schema';
</script>

README

This is the helper for function arguments parsing.

Install

npm install arg-schema

Usage example

function foo(){
    var args = new argSchema(arguments);
    if (args.checkin('string a', 'number b', 'opt bool c', 'object d', 'array e', 'opt function f')) {
        // Put code here
        // You can use args.a, args.b, ..., but optional arguments can be undefined
    }
    else if (args.checkin('bool a', 'opt array b', 'opt bool c', 'opt function d')) {
        // Put code here
        // You can use args.a, args.b, ..., but optional arguments can be undefined
    }
    else{
        // No schema matched
        // This the place for error returning
    }
}