# @compute.ts/dictionary

> Provide dictionary operators for the computeTS package

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

## Install

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

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

## Dependencies (6)

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

## 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.2.1 (latest) — 2021-06-26
- 2.2.0 — 2021-06-26
- 2.1.2 — 2021-06-25
- 2.1.1 — 2021-06-23
- 2.0.0 — 2021-06-21
- 1.0.5 — 2021-06-18
- 1.0.4 — 2021-06-18
- 1.0.3 — 2021-06-15
- 1.0.2 — 2021-06-14
- 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/dictionary)
![](https://img.shields.io/npm/v/@compute.ts/dictionary)
![](https://img.shields.io/npm/l/@compute.ts/dictionary)
![](https://img.shields.io/badge/coverage-80.81%25-4cc41f.svg)
![](https://img.shields.io/badge/files-5-orange)
![](https://img.shields.io/badge/lines-166-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/function](https://www.npmjs.com/package/@compute.ts/function)
- [@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/dictionary';
````
### Javascript
```javascript
const {/* required operators */} = require('@compute.ts/dictionary');
````
## Operators

### dictionary

<code>dictionary.of*Type*({key<sup>0</sup>: y<sup>0</sup><sub>*type*</sub>, key<sup>1</sup>: y<sup>1</sup><sub>*type*</sub>, ..., key<sup>n</sup>: y<sup>n</sup><sub>*type*</sub>}) ➜ z<sub>*{type}*</sub></code>  

The **dictionary** operator allows to create a dictionary expression. 

```typescript
import {dictionary} from "@compute.ts/dictionary";
import {boolean} from "@compute.ts/boolean";

const b = boolean();
const x = dictionary.ofBoolean({key1: true, key2: b});

const value = x.eval();

```
* * *

### get

<code>x<sub>*{type}*</sub>.get(y<sub>string</sub>) ➜ z<sub>*type*</sub></code>

The **get** operator allows to create a boolean expression which evals to the value accessed by the given key.

```typescript
import {dictionary} from "@compute.ts/dictionary";  
import {string} from "@compute.ts/string"

const x = dictionary.ofNumber({key: 12});
const y = string('key');
const z = x.get(y);

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

* * *

### has

<code>x<sub>*{type}*</sub>.has(y<sub>string</sub>) ➜ z<sub>boolean</sub></code>

The **has** operator allows to create a boolean expression which evals to true if the given dictionary has the given key.

```typescript
import {dictionary} from "@compute.ts/dictionary";  
import {string} from "@compute.ts/string"

const x = dictionary.ofString({hello: 'world'});
const y = string('hello');
const z = x.has(y);

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

* * *

### set

<code>x<sub>*{type}*</sub>.set(y<sup>0</sup><sub>string</sub>, y<sup>1</sup><sub>*type*</sub>) ➜ z<sub>*{type}*</sub></code>  

The **set** operator allows to create a dictionary expression which evals to the given dictionary with a new pair of key/value.

```typescript
import {dictionary} from "@compute.ts/dictionary";  
import {string} from "@compute.ts/string"
import {boolean} from "@compute.ts/boolean"

const x = dictionary.ofBoolean({key1: false});  

const y1 = string('key2');  
const y2 = boolean(true);
const z = x.set(y1, y2);

const value = z.eval(); // {key1: false, key2: true}
```


* * *

### merge

<code>x<sub>*{type}*</sub>.merge(y<sub>*{type}*</sub>) ➜ z<sub>*{type}*</sub></code>

The **merge** operator allows to create a dictionary expression which evals to the given dictionary merged with an other given dictionary.

```typescript
import {dictionary} from "@compute.ts/dictionary";  
import {string} from "@compute.ts/string"
import {boolean} from "@compute.ts/boolean"

const x0 = dictionary.ofBoolean({hello: true});  
const x1 = dictionary.ofBoolean({world: false});  

const y = x0.merge(x1);

const value = y.eval(); // {hello: true, world: false}
```
* * *

### keys

<code>x<sub>*{type}*</sub>.keys() ➜ y<sub>[string]</sub></code>

The **keys** operator allows to create a dictionary expression which evals to an array expression of the dictionary keys.

```typescript
import {dictionary} from "@compute.ts/dictionary";  
import {string} from "@compute.ts/string"
import {boolean} from "@compute.ts/boolean"

const x = dictionary.ofBoolean({key1: true, key2: false});  

const y = x.keys();

const value = y.eval(); // ['key1', 'key2']
```


* * *

### values

<code>x<sub>*{type}*</sub>.values() ➜ y<sub>*[type]*</sub></code>

The **values** operator allows to create a dictionary expression which evals to an array expression of the dictionary values.

```typescript
import {dictionary} from "@compute.ts/dictionary";  
import {string} from "@compute.ts/string"
import {boolean} from "@compute.ts/boolean"

const x = dictionary.ofBoolean({key1: true, key2: false});  

const y = x.values();

const value = y.eval(); // [true, false]
```


## 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/dictionary · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
