3.21.0 • Published 3 years ago

argsbytype v3.21.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Provide some arguments, get back a hash object of the arguments indexed by their type. Very useful for agnostic argument orders.

Usage

Let's say your coding a function, and you want to accept arguments in any order. Traditionally this would look like:

https://github.com/bevry/argsbytype/blob/master/example/01.js

But what happens when you:

  • Start having arguments that are regular expressions or dates which typeof is still object instead of regexp or date
  • Or, when you start having multiple arguments of the same type, that you would like to accept (e.g. the first string should be the name property, the second string should be the keyword property)

At that point in time, it becomes too much trouble to bother with. Fortunately, argsbytype is to the rescue! Now you can do:

https://github.com/bevry/argsbytype/blob/master/example/02.js

Yay! Big win for agnostic argument order! But when would you actually want this? Well, it turns out that in CoffeeScript options come first, in JavaScript, options usually come last. By using this, we can support both conventions, for example:

https://github.com/bevry/argsbytype/blob/master/example/03.js

npm

jspm

<script type="module">
    import * as pkg from '//dev.jspm.io/argsbytype@3.21.0'
</script>

Discover the release history by heading on over to the HISTORY.md file.

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

These amazing people are maintaining this project:

No sponsors yet! Will you be the first?

These amazing people have contributed code to this project:

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Unless stated otherwise all works are:

and licensed under:

3.21.0

3 years ago

3.20.0

4 years ago

3.19.0

4 years ago

3.18.0

4 years ago

3.17.0

4 years ago

3.16.0

4 years ago

3.15.0

4 years ago

3.14.0

4 years ago

3.13.0

4 years ago

3.12.0

4 years ago

3.11.0

4 years ago

3.10.0

4 years ago

3.9.0

4 years ago

3.8.0

4 years ago

3.7.0

4 years ago

3.6.0

4 years ago

3.5.0

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.3.0

4 years ago

1.2.0

5 years ago

1.1.0

6 years ago

1.0.1

8 years ago

1.0.0

10 years ago