# @compute.ts/array

> Provide array operators for the computeTS package

Latest version **2.1.1** (published 2021-06-26) · MIT license · 0 weekly downloads

## Install

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

## 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.1.1 |
| Published | 2021-06-26 |
| First published | 2021-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 55.1 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/array
- npm.io page: https://npm.io/package/@compute.ts/array

## Dependencies (5)

- [@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/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

## 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.1.1 (latest) — 2021-06-26
- 2.1.0 — 2021-06-25
- 2.0.2 — 2021-06-23
- 2.0.0 — 2021-06-21
- 1.0.2 — 2021-06-18
- 1.0.1 — 2021-06-18

## README

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

![](https://img.shields.io/npm/types/@compute.ts/array)
![](https://img.shields.io/npm/v/@compute.ts/array)
![](https://img.shields.io/npm/l/@compute.ts/array)
![](https://img.shields.io/badge/coverage-88.41%25-4cc41f.svg)
![](https://img.shields.io/badge/files-5-orange)
![](https://img.shields.io/badge/lines-245-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/function](https://www.npmjs.com/package/@compute.ts/function)
- [@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/array';
```

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

## Operators


### array

<code>array.of*Type*() ➜ x<sub>[*type*]</sub></code>  
<code>array.of*Type*(values) ➜ x<sub>[*type*]</sub></code>

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

```typescript
import {array} from "@compute.ts/array"

const x = string('Hello');
const y = array.ofString([x1, 'World'])

const value = y.eval() // ['Hello', 'World']
```

* * *

### access

<code>x<sub>*[type]*</sub>.access(y<sub>number</sub>) ➜ z<sub>*type*</sub></code>

The **access** operator allows to create an expression which eval to the node value of the element at the given position of the given array.

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

const x = array.ofNumber([1, 2, 3]);  
const y = number();  
const z = x.access(y);

y.affect(1);
const value = z.eval(); // 2
```

* * * 


### accessFirst

<code>x<sub>*[type]*</sub>.accessFirst() ➜ z<sub>*type*</sub></code>

The **accessFirst** operator allows to create an expression which eval to the first element of the given array.

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

const x = array.ofNumber([1, 2, 3]);  
const z = y.accessFirst(y);

const value = y.eval(); // 1
```

* * * 


### accessLast

<code>x<sub>*[type]*</sub>.accessLast() ➜ z<sub>*type*</sub></code>

The **accessLast** operator allows to create an expression which eval to the last element of the give array.

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

const x = array.ofNumber([1, 2, 3]);  
const z = y.accessLast();

const value = y.eval(); // 3
```

* * *
### concatRight

<code>x<sub>*[type]*</sub>.concatRight(y<sup>0</sup><sub>type</sub>, y<sup>1</sup><sub>type</sub>, ..., y<sup>n</sup><sub>type</sub>) ➜ z<sub>*[type]*</sub></code>

The **concatRight** operator allows to create an expression which eval given array with the given elements at the end.

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

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

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

* * *
### leftTail

<code>x<sub>*[type]*</sub>.leftTail(y<sub>type</sub>) ➜ z<sub>*[type]*</sub></code>

The **leftTail** operator allows to create an expression which eval to the given array without the last element.

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

const x = array.ofNumber([1, 2, 3]);
const y = x.leftTail();

const value = y.eval(); // [1, 2]
```

* * *
### concatLeft

<code>x<sub>*[type]*</sub>.concatLeft(y<sup>0</sup><sub>type</sub>, y<sup>1</sup><sub>type</sub>, ..., y<sup>n</sup><sub>type</sub>) ➜ z<sub>*[type]*</sub></code>

The **concatLeft** operator allows to create an expression which eval to the given array with the given elements at the begining.

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

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

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

* * *
### rightTail

<code>x<sub>*[type]*</sub>.rightTail(y<sup>0</sup><sub>type</sub>, y<sup>1</sup><sub>type</sub>, ..., y<sup>n</sup><sub>type</sub>) ➜ z<sub>*[type]*</sub></code>

The **rightTail** operator allows to create an expression which eval to the given array without the first element.

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

const x = array.ofNumber([1, 2, 3]);
const y = x.rightTail();

const value = y.eval(); // [2, 3]
```


* * *
### firstIndexOf

<code>x<sub>*[type]*</sub>.firstIndexOf(y<sub>type</sub>) ➜ z<sub>number</sub></code>

The **firstIndexOf** operator allows to create an expression which eval to the first index of the given node value.

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

const x = array.ofNumber([1, 2, 3, 2, 1]);
const y = number(2);
const z = x.firstIndexOf(y);

const value = z.eval(); // 1
```


* * *
### indexesOf

<code>x<sub>*[type]*</sub>.indexesOf(y<sub>type</sub>) ➜ z<sub>[number]</sub></code>

The **indexesOf** operator allows to create an expression which eval to the indexes of the given node value.

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

const x = array.ofNumber([1, 2, 3, 2, 1]);
const y = number(2);
const z = x.firstIndexOf(y);

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

* * *
### lastIndexOf

<code>x<sub>*[type]*</sub>.lastIndexOf(y<sub>type</sub>) ➜ z<sub>number</sub></code>

The **lastIndexOf** operator allows to create an expression which eval to the last index of the given node value.

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

const x = array.ofNumber([1, 2, 3, 2, 1]);
const y = number(2);
const z = x.lastIndexOf(y);

const value = z.eval(); // 3
```


* * *
### includes

<code>x<sub>*[type]*</sub>.includes(y<sub>type</sub>) ➜ z<sub>boolean</sub></code>

The **includes** operator allows to create an expression which eval to true if the given element is in the given array.

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

const x = array.ofNumber([1, 2, 3, 2, 1]);
const y = number(2);
const z = x.includes(y);

const value = z.eval(); // true
```


* * *
### reverse

<code>x<sub>*[type]*</sub>.reverse() ➜ y<sub>*[type]*</sub></code>

The **reverse** operator allows to create an expression which evals to the reverse of the given array.

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

const x = array.ofNumber([1, 2, 3]);
const y = x.reverse();

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


* * *
### size

<code>x<sub>*[type]*</sub>.size() ➜ y<sub>number</sub></code>

The **size** operator allows to create an expression which evals to the size of the given array.

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

const x = array.ofNumber([1, 2, 3]);
const y = x.size();

const value = y.eval(); // 3
```


* * *
### isEmpty

<code>x<sub>*[type]*</sub>.isEmpty() ➜ y<sub>boolean</sub></code>

The **isEmpty** operator allows to create an expression which evals to true if the given array is empty.

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

const x = array.ofNumber([1, 2, 3]);
const y = x.isEmpty();

const value = y.eval(); // false
```


* * *
### subArray

<code>x<sub>*[type]*</sub>.subArray(y<sup>1</sup><sub>number</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>*[type]*</sub></code>

The **subArray** operator allows to create an expression which evals to true if the given array is empty.

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

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

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

* * *
### shuffle

<code>x<sub>*[type]*</sub>.shuffle() ➜ z<sub>*[type]*</sub></code>

The **shuffle** operator allows to create an expression which evals to the given array shuffled.

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

const x = array.ofNumber([1, 2, 3, 2, 1]);
const y = x.shuffle();

const value = z.eval(); // [1, 3, 1, 2, 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/array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
