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

v2.0.3

Published

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 be

Downloads

10

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.

Usage

Imports

The engine library permits you to import the operators in a very simple way.

import {/* required operators */} from "@compute.ts/{library}" ;

Variable

The engine API permits you to define some special scalars called variables. There are special because once the model is loaded into the engine, you are able to change its values with the affect operation.

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

const x = number();

x.affect(12);

Expression

The library allows you to create expressions such as "and", "sum", "isLessThan". An expression represents a step of the computation of the calculation. There, take a set of nodes (variables or expressions) and return a single value—the expressions value.

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

const x = number();
const y = number();
const fx = sum(x, y);

fx.eval()

toString

The library allows you to visualize a node in a very convinient way.

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

const x0 = number(12);
const x1 = number(12);
const x2 = number(12);
const y0 = sum(x0, x1);
const y1 = minus(x1, x2);
const z = divide(y0, y1);

z.toString();
// ☐ divide
// ├─ ☐ sum
// │  ├─ ☑ 2
// │  └─ ☑ ∅
// └─ ☐ minus
//    ├─ ☑ ∅
//    └─ ☑ ∅
//
// ☐ = the expression need to be evaluated
// ☑ = the expression has been evaluated
// ∅ = the expression value is undefined

x1.affect(4);
x2.affect(8);
z.eval();

z.toString();
// ☑ divide(6, -4) ➔ -1.5
// ├─ ☑ sum(2, 4) ➔ 6
// │  ├─ ☑ 2
// │  └─ ☑ 4
// └─ ☑ minus(4, 8) ➔ -4
//    ├─ ☑ 4
//    └─ ☑ 8
//
// ➔ = current value of the expression
// ☑ = the expression has been evaluated

alias

If you create an alias for a given expression.

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

const x0 = number(12);
const x1 = number(4);
const x2 = number(8);
const y0 = sum(x0, x1);
const y1 = minus(x1, x2).alias('y1');
const z = divide(y0, y1);

z.eval();

z.toString();
// ☑ divide ➔ -1.5
// ├─ ☑ sum ➔ 6
// │  ├─ ☑ 2
// │  └─ ☑ 4
// └─ ☑  -4     [y1]

describe

If you create a description for a given expression.

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

const x0 = number(12);
const x1 = number(4);
const x2 = number(8);
const x3 = number(4);
const y0 = sum(x0, x1);
const z = divide(y0, x3).alias('z').describe('The final result');

z.eval();

z.toString();
// ☑ divide ➔ -1.5      [z: The final result]
// ├─ ☑ sum ➔ 6
// │  ├─ ☑ 2
// │  └─ ☑ 4
// └─ ☑  -4

Example

Polynom computation

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

const x = number();
const a = number(3);
const b = number(5);
const c = number(7);
const fx = a.times(x2(x)).plus(b.times(x)).plus(c);

x.affect(1)
fx.eval(); // = 15

Polynom resolution

import {number, zero} from "@compute.ts/number";
import {x2, sqrt} from "@compute.ts/math";

const a = number();
const b = number();
const c = number();
const delta = x2(b).minus(times(4, a, c));
const hasSolution = delta.greaterOrEqualThan(zero);
const x1 = opposite(b).minus(sqrt(delta)).divideBy(times(2, a));
const x2 = opposite(b).sum(sqrt(delta)).divideBy(times(2, a));

a.affect(1);
b.affect(2);
c.affect(3);

hasSolution.eval() // = true
x1.eval(); // = 2/3
x2.eval(); // = 1

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/