@compute.ts/string
v2.0.3
Published
Provide string operators for the computeTS package
Downloads
17
Maintainers
Readme
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.
Libraries
The project provides several libraries that each comes with dozens of operators. Please note the cross-compatibility of the libraries.
- @compute.ts/boolean
- @compute.ts/number
- @compute.ts/date
- @compute.ts/dictionary
- @compute.ts/function
- @compute.ts/array
- @compute.ts/math
- @compute.ts/structural
Imports
Typescript
import {/* required operators */} from '@compute.ts/string';
Javascript
const {/* required operators */} = require('@compute.ts/string');
Operators
string
string(value) ➜ xstring
string() ➜ xstring
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
import {string} from "@compute.ts/string"
const x = string('Hello world') | string();
x.affect('World Hello');
is
is(xstring, ystring) ➜ zboolean
xstring.is(ystring) ➜ zboolean
The is operator allows to create a boolean expression which evals to true
if x equals y
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
isNot(xstring, ystring) ➜ zboolean
xstring.isNot(ystring) ➜ zboolean
The isNot operator allows to create a boolean expression which evals to true
if x is not y
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
charAt(xstring, ynumber) ➜ zstring
xstring.charAt(ynumber) ➜ zstring
The charAt operator allows to create a string expression which evals to the character fo x at the y position
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
indexOf(xstring, ystring) ➜ znumber
xstring.indexOf(ystring) ➜ znumber
The indexOf operator allows to create a number expression which evals to the position of y in x
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
concat(x0string, x1string, ..., xnstring) ➜ ystring
x0string.concat(x1string, ..., xnstring) ➜ yboolean
The concat operator allows to create a string expression which evals to the concatenation of the given expressions
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
include(xstring, ystring) ➜ zboolean
xstring.include(ystring) ➜ zboolean
The include operator allows to create a boolean expression which evals to true
if x includes y
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
startsWith(xstring, ystring) ➜ zboolean
xstring.startsWith(ystring) ➜ zboolean
The startsWith operator allows to create a boolean expression which evals to true
if x starts with y
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
endsWith(xstring, ystring) ➜ zboolean
xstring.endsWith(ystring) ➜ zboolean
The endsWith operator allows to create a boolean expression which evals to true
if x ends with y
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
padStart(xstring, y1string, y2number) ➜ zstring
xstring.padStart(y1string, y2number) ➜ zstring
The start operator allows to create a string expression which evals to x with y1 repetated by the start until the size reach y2
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
padEnd(xstring, y1string, y2number) ➜ zstring
xstring.padEnd(y1string, y2number) ➜ zstring
The padEnd operator allows to create a string expression which evals to x with y1 repetated by the end until the size reach y2
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
length(xstring) ➜ ynumber
xstring.length() ➜ ynumber
The length operator allows to create a number expression which evals to the length of x
import {string, length} from "@compute.ts/string"
const x = string();
const y = length(x) | x.length();
const value = y.eval();
trim
trim(xstring) ➜ ystring
xstring.trim() ➜ ystring
The trim operator allows to create a string expression which evals to x where the left and right spaces has been removed
import {string, trim} from "@compute.ts/string"
const x = string();
const y = trim(x) | x.trim();
const value = y.eval();
replace
replace(xstring, y1string, y2string) ➜ zstring
xstring.replace(y1string, y2string) ➜ zstring
The replace operator allows to create a string expression which evals to x where y1 has been replaced by y2
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
subString(xstring, y1number, y2number) ➜ zstring
xstring.subString(y1number, y2number) ➜ zstring
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
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
slice(xstring, y1number, y2number) ➜ zstring
xstring.slice(y1number, y2number) ➜ zstring
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
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
toUppercase(xstring) ➜ ystring
xstring.toUppercase() ➜ ystring
The toLowercase operator allows to create a string expression which evals to x uppercased
import {string, toUppercase} from "@compute.ts/string"
const x = string();
const y = toUppercase(x) | x.toUppercase();
const value = y.eval();
toLowercase
toLowercase(xstring) ➜ ystring
xstring.toLowercase() ➜ ystring
The toLowercase operator allows to create a string expression which evals to x lowercased
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/