# function-as

> Pass functions as if they had, one or more, constant args

Latest version **1.0.0** (published 2017-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install function-as
pnpm add function-as
yarn add function-as
bun add function-as
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-05-21 |
| First published | 2017-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ecman |
| Maintainers | ecman |
| Keywords | function arguments, argument binding, argument, callbacks, pass by reference, function parameters, bind-arguments, utility function, higher order function, utility, function, ecman |

## Links

- npm: https://www.npmjs.com/package/function-as
- Repository: https://github.com/ecman/function-as
- Homepage: https://github.com/ecman/function-as#readme
- Issues: https://github.com/ecman/function-as/issues
- npm.io page: https://npm.io/package/function-as

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-05-21

## README

# function-as

[![build status](https://api.travis-ci.org/ecman/function-as.png)](https://travis-ci.org/ecman/function-as) [![codecov](https://codecov.io/gh/ecman/function-as/branch/master/graph/badge.svg)](https://codecov.io/gh/ecman/function-as) [![Code Climate](https://codeclimate.com/github/ecman/function-as/badges/gpa.svg)](https://codeclimate.com/github/ecman/function-as)

Pass functions as if they had, one or more, constant args

# Usage

```js
function run_callback(callback) {
  // run callback with five strings and no error (i.e. null)
  callback(null, "one", "two", 'three', 'four', 'five');
}

// Will be passed as callback function
function five_strings(err, one, two, three, four, five) {
  console.log('result:', err, one, two, three, four, five);
  console.log("\n");
}

console.log( "A normal call" );
run_callback(five_strings);

console.log( "Set first params as '0'" );
run_callback(five_strings.asfirst('0'));

console.log( "Set first params as [caller specified] and '1'" );
run_callback(five_strings.asfirst(undefined, '1'));

console.log( "Set last params as '5'" );
run_callback(five_strings.aslast('5'));

console.log( "Set last params as '4' and [caller specified]" );
run_callback(five_strings.aslast('4', undefined));

console.log( "Set first params as '0' and last as '5'" );
run_callback(five_strings.as(['0'], ['5']));

console.log( "Set first params as [caller specified],'1', '2'\n" +
             "and last as '4', '5'" );
run_callback(five_strings.as([undefined, '1', "2"], ["4", '5']));

console.log( "Set first params as 'ZERO' and last as 'FIVE'\n" +
             "by chaining calls to asfirst() and aslast()" );
run_callback(five_strings.asfirst('ZERO').aslast('FIVE'));
```

Output:

```text
A normal call
result: null one two three four five

Set first params as '0'
result: 0 one two three four five

Set first params as [caller specified] and '1'
result: null 1 two three four five

Set last params as '5'
result: null one two three four 5

Set last params as '4' and [caller specified]
result: null one two three 4 five

Set first params as '0' and last as '5'
result: 0 one two three four 5

Set first params as [caller specified],'1', '2'
and last as '4', '5'
result: null 1 2 three 4 5

Set first params as 'ZERO' and last as 'FIVE'
by chaining calls to asfirst() and aslast()
result: ZERO one two three four FIVE
```

---
_Source: https://npm.io/package/function-as · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
