# @compute.ts/function

> Provide function operators for the computeTS package

Latest version **2.0.3** (published 2021-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @compute.ts/function
pnpm add @compute.ts/function
yarn add @compute.ts/function
bun add @compute.ts/function
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2021-06-25 |
| First published | 2021-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 74.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mathieu BERTHELLEMY |
| Maintainers | mberthellemy |
| Keywords | incremental computation, incremental engine, incremental calculation, incremental, computation, engine, calculation, mathematics, graph, dag, directed acyclic graph, affectation, evaluation, affect, eval |

## Links

- npm: https://www.npmjs.com/package/@compute.ts/function
- npm.io page: https://npm.io/package/@compute.ts/function

## Dependencies (7)

- [@compute.ts/core](https://npm.io/package/@compute.ts/core.md) ^2.0.0
- [@compute.ts/date](https://npm.io/package/@compute.ts/date.md) ^2.0.0
- [@compute.ts/array](https://npm.io/package/@compute.ts/array.md) ^2.0.0
- [@compute.ts/number](https://npm.io/package/@compute.ts/number.md) ^2.0.0
- [@compute.ts/string](https://npm.io/package/@compute.ts/string.md) ^2.0.0
- [@compute.ts/boolean](https://npm.io/package/@compute.ts/boolean.md) ^2.0.0
- [@compute.ts/dictionary](https://npm.io/package/@compute.ts/dictionary.md) ^2.0.0

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2021-06-25
- 2.0.2 — 2021-06-23
- 2.0.1 — 2021-06-23
- 2.0.0 — 2021-06-21
- 1.0.4 — 2021-06-18
- 1.0.3 — 2021-06-18
- 1.0.2 — 2021-06-15
- 1.0.1 — 2021-06-14
- 1.0.0 — 2021-06-14

## README

![](https://colibri-engine.com/assets/img/compute.png)


![](https://img.shields.io/npm/types/@compute.ts/boolean)
![](https://img.shields.io/npm/v/@compute.ts/boolean)
![](https://img.shields.io/npm/l/@compute.ts/boolean)
![](https://img.shields.io/badge/coverage-73.73%25-4cc41f.svg)
![](https://img.shields.io/badge/files-15-orange)
![](https://img.shields.io/badge/lines-1534-orange)
![](https://img.shields.io/badge/made%20in-France-blue)


## Presentation
The engine is based on incremental computation algorithms. When a calculation is submitted to the engine, all the computed values are memorized. So, if you change some variable and query an evaluation, the engine is able to compute the result very fast because it recomputes only what has changed.

[compute.ts](https://www.npmjs.com/package/compute.ts)

## Libraries
The project provides several libraries that each comes with dozens of operators. Please note the cross-compatibility of the libraries.
- [@compute.ts/boolean](https://www.npmjs.com/package/@compute.ts/boolean)
- [@compute.ts/number](https://www.npmjs.com/package/@compute.ts/number)
- [@compute.ts/string](https://www.npmjs.com/package/@compute.ts/string)
- [@compute.ts/date](https://www.npmjs.com/package/@compute.ts/date)
- [@compute.ts/dictionary](https://www.npmjs.com/package/@compute.ts/dictionary)
- [@compute.ts/array](https://www.npmjs.com/package/@compute.ts/array)
- [@compute.ts/math](https://www.npmjs.com/package/@compute.ts/math)
- [@compute.ts/structural](https://www.npmjs.com/package/@compute.ts/structural)



## Imports
### Typescript
```typescript
import {/* required operators */} from '@compute.ts/function';
```

### Javascript
```javascript
const {/* required operators */} = require('@compute.ts/function');
```

## Operators

### Function

<code>Function.take*Type*.return*Type*.code(value) ➜ x<sub>function</sub></code>  

The **Function** operator allows you to create an expression which evals to the result of the given fuction. If no value is provided the expression is a variable of the model

```typescript
import {Function} from "@compute.ts/function";

const x = Function
    .takeNumberArray
    .takeNumber
    .returnNumberArray
    .code((array: number[], threshold: number) => {
        return array.filter(value => value < threshold);
    });
```

* * *

### apply

<code>x<sub>function</sub>.apply(x<sup>0</sup><sub>type-A</sub>, x<sup>1</sup><sub>type-B</sub>, x<sup>2</sup><sub>type-C</sub>) ➜ x<sub>*type-return*</sub></code>

The **apply** operator allows to create a boolean expression which evals to the result of the function according to the value of the agument(s)

```typescript
import {Function} from "@compute.ts/function";
import {array} from "@compute.ts/array";
import {number} from "@compute.ts/number";

const x = Function
    .takeNumberArray
    .takeNumber
    .returnNumberArray
    .code((y1: number[], y2: number) => {
        return y1.filter(v => v < y2);
    });

const y1 = array.ofNumber([1, 2, 3, 4]);
const y2 = number();
const z = x.apply(y1, y2);

y2.affect(3)
const value = z.eval(); // [1, 2]
```


## About the author
I am a software developer with 4 years of project specializing in the development of web solutions. Digital Nomad, I work while traveling.  After 3 years into the french industry, I've started to work as a freelance software architect or fullstack developer.

Based on state-of-the-art web technologies, I offer you to architect & develop the best version of your project. My experience in the web app development assure you to build a nice looking, performant and stable product.

Minimalist, I like to travel, to meet people, learn new things and handmade stuff. Scuba & sky diving licenced. I like also hamburgers, Kinder chocolate and crepes. Karate black belt.

https://berthellemy.com/

* * *

![](https://colibri-engine.com/assets/img/brand/logo_animated.gif)

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