https://github.com/coderaiser/anyorder
Call function with any order of arguments
https://github.com/coderaiser/anyorder
arguments functional javascript order
Last synced: 9 months ago
JSON representation
Call function with any order of arguments
- Host: GitHub
- URL: https://github.com/coderaiser/anyorder
- Owner: coderaiser
- License: mit
- Created: 2015-01-26T08:00:19.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-02-20T14:21:27.000Z (about 8 years ago)
- Last Synced: 2025-05-26T23:15:29.144Z (10 months ago)
- Topics: arguments, functional, javascript, order
- Language: JavaScript
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
# Anyorder
Call function with any order of arguments.
## What for?
`Anyorder` could be used when order of parameters need to be other then it is. It's not very common situation, but sometimes it could be useful.
For example to avoid [boolean trap](http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html "hall of api shame: boolean trap") in `addEventListener`.
## How to use?
In `node.js`:
```js
const anyorder = require('anyorder');
const fs = require('fs');
const read = anyorder('function, string', fs.readFile);
read((error, data) => {
console.log(error || data)
}, 'README.md');
```
In `browser`:
```js
const addListener = window.addEventListener.bind(window);
const add = anyorder('string, function, boolean', addListener);
add('load', true, (event) => {
console.log(event);
});
```
## Environments
In old `node.js` environments that supports `es5` only, `anyorder` could be used with:
```js
var anyorder = require('anyorder/legacy');
```
## License
MIT