Git Product home page Git Product logo

parg-js's Introduction

#parg-js Javascript's functions are incredibly flexible parameter wise - they accept any number of arguments of any type and can be accessed in the local arguments variable even if none are named in the declaration.

Unfortunately there is no universal way to wrangle these arguments when you want to dynamically handle them. This is where parg comes in. parg parses the arguments to your function and returns an object with the named parameters set to the value of the argument they matched.

Formats

Simply put parg expects a formatted array of objects. These objects are simple, they are merely the name of the parameter (p) and the criteria for matching the value at that index of the arguments array. For example, if you wanted to match the first parameter of your function as a string you would do something like the following.

function something () {
  return parg(arguments, {p: 'arg1', t: 'string'});
}

// This should return 'hello world' as 'arg1' in the object
// {arg1: 'hello world'}
something('hello world');

Roadmap

  • Function handlers for specific configurations that will spit out to the individually named arguments of the target functions from one core function eg. `parg.func(this, 'functionName', {... groups with handler function ...}
  • Default handlers on a specific parameter matching, eg. if arg1 is set then arg3 should be this value.

License

This projected is licensed under the terms of the MIT license.

parg-js's People

Contributors

cleversoap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.