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/number

v2.0.3

Published

Provide number operators for the computeTS package

Downloads

14

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/number';

Javascript

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

Operators

number

number(value) ➜ xnumber
number() ➜ xnumber

The number operator allows to create a number expression which evals to the given value. If no value is provided the expression is a variable and can be affected

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

const x = number(5) | number();  

x.affect(8);

randomNumber

randomNumber(xnumber, ynumber) ➜ znumber

The randomNumber operator allows to create a number expression which evals to a random number between the given boundaries

import {number, randomNumber} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = randomNumber(x, y);

const value = z.eval();

zero

zero ➜ xnumber

The zero operator allows to create a number expression which evals to 0

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

const x = zero;  

x.affect(2);

one

one ➜ xnumber

The one operator allows to create a number expression which evals to 1

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

const x = one;  

x.affect(2);

opposite

opposite(xnumber) ➜ ynumber
xnumber.opposite() ➜ ynumber

The opposite operator allows to create a number expression which evals to the opposite of the given expression

import {number, opposite} from "@compute.ts/number";

const x = number();  
const y = opposite(x) | x.opposite() ;

const value = y.eval();

plus

plus(x0number, x1number, ..., xnnumber) ➜ ynumber
xnumber.plus(x0number, x1number, ..., xnnumber) ➜ ynumber

The plus operator allows to create a number expression which evals to the sum of all the given expressions

import {number, plus} from "@compute.ts/number";

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

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

const value = y.eval();

multiply

multiply(x0number, x1number, ..., xnnumber) ➜ ynumber
xnumber.multiply(x0number, x1number, ..., xnnumber) ➜ ynumber

The multiply operator allows to create a number expression which evals to the multiplication of all the given expressions

import {number, multiply} from "@compute.ts/number";

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

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

const value = y.eval();

minus

minus(x0number, x1number, ..., xnnumber) ➜ ynumber
xnumber.minus(x0number, x1number, ..., xnnumber) ➜ ynumber

The minus operator allows to create a number expression which evals to the first given element minus all the elements which comes after

import {number, minus} from "@compute.ts/number";

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

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

const value = y.eval();

divide

divide(xnumber, ynumber) ➜ znumber
xnumber.divide(ynumber) ➜ znumber

The divide operator allows to create a number expression which evals to the division of x by y

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

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

const value = z.eval();

modulo

modulo(xnumber, ynumber) ➜ znumber
xnumber.modulo(ynumber) ➜ znumber

The modulo operator allows to create a number expression which evals to the rest of the division of x by y

import {number, modulo} from "@compute.ts/number";

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

const value = z.eval();

lessThan

lessThan(xnumber, ynumber) ➜ zboolean
xnumber.lessThan(ynumber) ➜ zboolean

The lessThan operator allows to create a boolean expression which evals to true if x is less than y

import {number, lessThan} from "@compute.ts/number";

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

const value = z.eval();

lessOrEqualThan

lessOrEqualThan(xnumber, ynumber) ➜ zboolean
xnumber.lessOrEqualThan(ynumber) ➜ zboolean

The lessOrEqualThan operator allows to create a boolean expression which evals to true if x is less or equal than y

import {number, lessOrEqualThan} from "@compute.ts/number";

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

const value = z.eval();

greaterThan

greaterThan(xnumber, ynumber) ➜ zboolean
xnumber.greaterThan(ynumber) ➜ zboolean

The greaterOrEqualThan operator allows to create a boolean expression which evals to true if x is greater y

import {number, greaterThan} from "@compute.ts/number";

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

const value = z.eval();

greaterOrEqualThan

greaterOrEqualThan(xnumber, ynumber) ➜ zboolean
xnumber.greaterOrEqualThan(ynumber) ➜ zboolean

The greaterOrEqualThan operator allows to create a boolean expression which evals to true if x is greater or equal y

import {number, greaterOrEqualThan} from "@compute.ts/number";

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

const value = z.eval();

equal

equal(xnumber, ynumber) ➜ zboolean
xnumber.equal(ynumber) ➜ zboolean

The equals operator allows to create a boolean expression which evals to true if x and y are the same equals

import {number, equal} from "@compute.ts/number";

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

const value = z.eval();

isZero

isZero(xnumber) ➜ yboolean
xnumber.isZero() ➜ yboolean

The isZero operator allows to create a boolean expression which evals to true if x is zero

import {number, isZero} from "@compute.ts/number";

const x = number();  
const y = isZero(x) | x.isZero();

const value = y.eval();

isPositive

isPositive(xnumber) ➜ yboolean
xnumber.isPositive() ➜ yboolean

The isPositive operator allows to create a boolean expression which evals to true if x is positive

import {number, isPositive} from "@compute.ts/number";

const x = number();  
const y = isPositive(x) | x.isPositive();

const value = y.eval();

isNegative

isNegative(xnumber) ➜ yboolean
xnumber.isNegative() ➜ yboolean

The isNegative operator allows to create a boolean expression which evals to true if x is negative

import {number, isNegative} from "@compute.ts/number";

const x = number();  
const y = isNegative(x) | x.isNegative();

const value = y.eval();

isEven

isEven(xnumber) ➜ yboolean
xnumber.isEven() ➜ yboolean

The isEven operator allows to create a boolean expression which evals to true if x is even

import {number, isEven} from "@compute.ts/number";

const x = number();  
const y = isEven(x) | x.isEven();

const value = y.eval();

isOdd

isOdd(xnumber) ➜ yboolean
xnumber.isOdd() ➜ yboolean

The isOdd operator allows to create a boolean expression which evals to true if x is odd

import {number, isOdd} from "@compute.ts/number";

const x = number();  
const y = isOdd(x) | x.isOdd();

const value = y.eval();

isPrime

isPrime(xnumber) ➜ yboolean
xnumber.isPrime() ➜ yboolean

The isPrime operator allows to create a boolean expression which evals to true if x is prime

import {number, isPrime} from "@compute.ts/number";

const x = number();  
const y = isPrime(x) | x.isPrime();

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/