# calp

> Call Proxy

Latest version **1.2.0** (published 2016-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install calp
pnpm add calp
yarn add calp
bun add calp
```

## 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.2.0 |
| Published | 2016-11-15 |
| First published | 2016-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.8.1 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tolgahan Albayrak |
| Maintainers | tolgahan |
| Keywords | call, proxy, call-proxy |

## Links

- npm: https://www.npmjs.com/package/calp
- Repository: https://github.com/tlghn/calp
- Homepage: https://github.com/tlghn/calp#readme
- Issues: https://github.com/tlghn/calp/issues
- npm.io page: https://npm.io/package/calp

## Dependencies (1)

- [tupl](https://npm.io/package/tupl.md) ^1.2.0

## Recent versions

- 1.2.0 (latest) — 2016-11-15
- 1.1.1 — 2016-11-05
- 1.1.0 — 2016-11-05
- 1.0.1 — 2016-11-04
- 1.0.0 — 2016-11-04

## README

# calp
Call Proxy

## Installation
```
    npm i calp --save
```

## Usage
```
    const calp = require('calp');
    var host = calp(func[, target, ns])
```

### @ns parameter *(new in 1.1)*
calp is uses [tupl](https://www.npmjs.com/package/tupl) for caching and key mapping. 
Please see the [tupl#create(ns)](https://www.npmjs.com/package/tupl#create) for more details

## Examples

### Without Target

```
    const calp = require('calp');
    var obj = calp(function (name, a, b) {
        switch (name){
            case 'add':
                return a + b;
            case 'sub':
                return a - b;
            case 'mul':
                return a * b;
            case 'div':
                return a / b;
        }
    });

    var A = 10;
    var B = 5;

    assert(obj.add(A, B) === 15);
    assert(obj.sub(A, B) === 5);
    assert(obj.mul(A, B) === 50);
    assert(obj.div(A, B) === 2);    
```

### With Target

```
        class Test {

            _doMath(name, a, b){
                if(!(this instanceof Test)){
                    throw new TypeError('Invalid call!');
                }

                switch (name){
                    case 'add':
                        return a + b;
                    case 'sub':
                        return a - b;
                    case 'mul':
                        return a * b;
                    case 'div':
                        return a / b;
                }
            }

            get math(){
                return calp(this._doMath, this);
            }
        }
        
        var test = new Test();

        var A = 10;
        var B = 5;

        assert(test.math.add(A, B) === 15);
        assert(test.math.sub(A, B) === 5);
        assert(test.math.mul(A, B) === 50);
        assert(test.math.div(A, B) === 2);

```

## Notes
**Please see the tests for other examples**

## Change Log
- 1.1.0 Added namespace bounded key support
- 1.0.0 Initial release

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