# @compute.ts/string

> Provide string operators for the computeTS package

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

## Install

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

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

## Dependencies (3)

- [@compute.ts/core](https://npm.io/package/@compute.ts/core.md) ^2.0.0
- [@compute.ts/number](https://npm.io/package/@compute.ts/number.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.0.3 (latest) — 2021-06-26
- 2.0.2 — 2021-06-25
- 2.0.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

## README

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


![](https://img.shields.io/npm/types/@compute.ts/string)
![](https://img.shields.io/npm/v/@compute.ts/string)
![](https://img.shields.io/npm/l/@compute.ts/string)
![](https://img.shields.io/badge/coverage-98,79%25-4cc41f.svg)
![](https://img.shields.io/badge/files-5-orange)
![](https://img.shields.io/badge/lines-323-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/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/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/string';
```

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

## Operators


### string

<code>string(value) ➜ x<sub>string</sub></code>  
<code>string() ➜ x<sub>string</sub></code>

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

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

const x = string('Hello world') | string();

x.affect('World Hello');
```

* * *

### is

<code>is(x<sub>string</sub>, y<sub>string</sub>) ➜ z<sub>boolean</sub></code>  
<code>x<sub>string</sub>.is(y<sub>string</sub>) ➜ z<sub>boolean</sub></code>

The **is** operator allows to create a boolean expression which evals to `true` if x equals y

```typescript
import {string, is} from "@compute.ts/string"

const x = string();  
const y = string();  
const z = is(x, y) | x.is(y);

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

* * *

### isNot

<code>isNot(x<sub>string</sub>, y<sub>string</sub>) ➜ z<sub>boolean</sub></code>  
<code>x<sub>string</sub>.isNot(y<sub>string</sub>) ➜ z<sub>boolean</sub></code>

The **isNot** operator allows to create a boolean expression which evals to `true` if x is not y

```typescript
import {string, isNot} from "@compute.ts/string"

const x = string();  
const y = string();  
const z = isNot(x, y) | x.isNot(y);

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

* * *

### chatAt

<code>charAt(x<sub>string</sub>, y<sub>number</sub>) ➜ z<sub>string</sub></code>  
<code>x<sub>string</sub>.charAt(y<sub>number</sub>) ➜ z<sub>string</sub></code>

The **charAt** operator allows to create a string expression which evals to the character fo x at the y position

```typescript
import {number} from "@compute.ts/number";  
import {string, charAt} from "@compute.ts/string"

const x = string();  
const y = number();  
const z = charAt(x, y) | x.charAt(y);

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

* * *

### indexOf

<code>indexOf(x<sub>string</sub>, y<sub>string</sub>) ➜ z<sub>number</sub></code>  
<code>x<sub>string</sub>.indexOf(y<sub>string</sub>) ➜ z<sub>number</sub></code>

The **indexOf** operator allows to create a number expression which evals to the position of y in x

```typescript
import {string, indexOf} from "@compute.ts/string"

const x = string();  
const y = string();  
const z = indexOf(x, y) | x.indexOf(y)

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

* * *

### concat

<code>concat(x<sup>0</sup><sub>string</sub>, x<sup>1</sup><sub>string</sub>, ..., x<sup>n</sup><sub>string</sub>) ➜ y<sub>string</sub></code>  
<code>x<sup>0</sup><sub>string</sub>.concat(x<sup>1</sup><sub>string</sub>, ..., x<sup>n</sup><sub>string</sub>) ➜ y<sub>boolean</sub></code>

The **concat** operator allows to create a string expression which evals to the concatenation of the given expressions

```typescript
import {string, concat} from "@compute.ts/string"

const x0 = string();  
const x1 = string();  
// ...  
const xn = string();

const y = concat(x0, x1, ..., xn) | x0.concat(x1, ..., xn);

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

* * *

### include

<code>include(x<sub>string</sub>, y<sub>string</sub>) ➜ z<sub>boolean</sub></code>  
<code>x<sub>string</sub>.include(y<sub>string</sub>) ➜ z<sub>boolean</sub></code>

The **include** operator allows to create a boolean expression which evals to `true` if x includes y

```typescript
import {string, include} from "@compute.ts/string"

const x = string();  
const y = string();  
const z = include(x, y) | x.include(y);

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

* * *

### startsWith

<code>startsWith(x<sub>string</sub>, y<sub>string</sub>) ➜ z<sub>boolean</sub></code>  
<code>x<sub>string</sub>.startsWith(y<sub>string</sub>) ➜ z<sub>boolean</sub></code>

The **startsWith** operator allows to create a boolean expression which evals to `true` if x starts with y

```typescript
import {string, startsWith} from "@compute.ts/string"

const x = string();  
const y = string();  
const z = startsWith(x, y) | x.startsWith(y);

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

* * *

### endsWith

<code>endsWith(x<sub>string</sub>, y<sub>string</sub>) ➜ z<sub>boolean</sub></code>  
<code>x<sub>string</sub>.endsWith(y<sub>string</sub>) ➜ z<sub>boolean</sub></code>

The **endsWith** operator allows to create a boolean expression which evals to `true` if x ends with y

```typescript
import {string, endsWith} from "@compute.ts/string"

const x = string();  
const y = string();  
const z = endsWith(x, y) | x.endsWith(y);

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

* * *

### padStart

<code>padStart(x<sub>string</sub>, y<sup>1</sup><sub>string</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>  
<code>x<sub>string</sub>.padStart(y<sup>1</sup><sub>string</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>

The **start** operator allows to create a string expression which evals to x with y1 repetated by the start until the size reach y2

```typescript
import {string, include} from "@compute.ts/string"  
import {number} from "@compute.ts/number";

const x = string();  
const y1 = string();  
const y2 = number();  
const z = padStart(x, y1, y2) | x.padStart(y1, y2);

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

* * *

### padEnd

<code>padEnd(x<sub>string</sub>, y<sup>1</sup><sub>string</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>  
<code>x<sub>string</sub>.padEnd(y<sup>1</sup><sub>string</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>

The **padEnd** operator allows to create a string expression which evals to x with y1 repetated by the end until the size reach y2

```typescript
import {string, include} from "@compute.ts/string"  
import {number} from "@compute.ts/number";

const x = string();  
const y1 = string();  
const y2 = number();  
const z = padEnd(x, y1, y2) | x.padEnd(y1, y2);

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

* * *

### length

<code>length(x<sub>string</sub>) ➜ y<sub>number</sub></code>  
<code>x<sub>string</sub>.length() ➜ y<sub>number</sub></code>

The **length** operator allows to create a number expression which evals to the length of x

```typescript
import {string, length} from "@compute.ts/string"

const x = string();  
const y = length(x) | x.length();

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

* * *

### trim

<code>trim(x<sub>string</sub>) ➜ y<sub>string</sub></code>  
<code>x<sub>string</sub>.trim() ➜ y<sub>string</sub></code>

The **trim** operator allows to create a string expression which evals to x where the left and right spaces has been removed

```typescript
import {string, trim} from "@compute.ts/string"

const x = string();  
const y = trim(x) | x.trim();

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

* * *

### replace

<code>replace(x<sub>string</sub>, y<sup>1</sup><sub>string</sub>, y2string) ➜ z<sub>string</sub></code>  
<code>x<sub>string</sub>.replace(y<sup>1</sup><sub>string</sub>, y2string) ➜ z<sub>string</sub></code>

The **replace** operator allows to create a string expression which evals to x where y1 has been replaced by y2

```typescript
import {string, replace} from "@compute.ts/string"

const x = string();  
const y1 = string();  
const y2 = string();  
const z = replace(x, y1, y2) | x.replace(y1, y2);

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

* * *

### subString

<code>subString(x<sub>string</sub>, y<sup>1</sup><sub>number</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>  
<code>x<sub>string</sub>.subString(y<sup>1</sup><sub>number</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>

The **slice** operator allows to create a string expression which evals to a substring of x where the starting index is y1 and the length is y2

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

import {string, subString} from "@compute.ts/string"

const x = string();  
const y1 = number();  
const y2 = number();  
const y = subString(x, y1, y2) | x.subString(y1, y2);

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

* * *

### slice

<code>slice(x<sub>string</sub>, y<sup>1</sup><sub>number</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>  
<code>x<sub>string</sub>.slice(y<sup>1</sup><sub>number</sub>, y<sup>2</sup><sub>number</sub>) ➜ z<sub>string</sub></code>

The **slice** operator allows to create a string expression which evals to a substring of x where the starting index is y1 and the end is y2

```typescript
import {number} from "@compute.ts/number";  
import {string, slice} from "@compute.ts/string"

const x = string();  
const y1 = number();  
const y2 = number();  
const y = slice(x, y1, y2) | x.slice(y1, y2);

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

* * *

### toUppercase

<code>toUppercase(x<sub>string</sub>) ➜ y<sub>string</sub></code>  
<code>x<sub>string</sub>.toUppercase() ➜ y<sub>string</sub></code>

The **toLowercase** operator allows to create a string expression which evals to x uppercased

```typescript
import {string, toUppercase} from "@compute.ts/string"

const x = string();  
const y = toUppercase(x) | x.toUppercase();

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

* * *

### toLowercase

<code>toLowercase(x<sub>string</sub>) ➜ y<sub>string</sub></code>  
<code>x<sub>string</sub>.toLowercase() ➜ y<sub>string</sub></code>

The **toLowercase** operator allows to create a string expression which evals to x lowercased

```typescript
import {string, toLowercase} from "@compute.ts/string"

const x = string();  
const y = toLowercase(x) | x.toLowercase();

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


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