npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@compute.ts/array

v2.1.1

Published

Provide array operators for the computeTS package

Downloads

15

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.

compute.ts

Libraries

The project provides several libraries that each comes with dozens of operators. Please note the cross-compatibility of the libraries.

Imports

Typescript

import {/* required operators */} from '@compute.ts/array';

Javascript

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

Operators

array

array.ofType() ➜ x[type]
array.ofType(values) ➜ x[type]

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

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

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

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

access

x[type].access(ynumber) ➜ ztype

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.

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

x[type].accessFirst() ➜ ztype

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

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

x[type].accessLast() ➜ ztype

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

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

x[type].concatRight(y0type, y1type, ..., yntype) ➜ z[type]

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

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

x[type].leftTail(ytype) ➜ z[type]

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

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

x[type].concatLeft(y0type, y1type, ..., yntype) ➜ z[type]

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

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

x[type].rightTail(y0type, y1type, ..., yntype) ➜ z[type]

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

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

x[type].firstIndexOf(ytype) ➜ znumber

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

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

x[type].indexesOf(ytype) ➜ z[number]

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

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

x[type].lastIndexOf(ytype) ➜ znumber

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

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

x[type].includes(ytype) ➜ zboolean

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

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

x[type].reverse() ➜ y[type]

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

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

x[type].size() ➜ ynumber

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

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

x[type].isEmpty() ➜ yboolean

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

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

x[type].subArray(y1number, y2number) ➜ z[type]

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

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

x[type].shuffle() ➜ z[type]

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

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/