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

@zushah/chalkboard

v2.1.0

Published

The Chalkboard library provides a plethora of mathematical functionalities for its user.

Downloads

11

Readme

Contents

About

The Chalkboard library is a JavaScript namespace that provides a plethora of both practical and abstract mathematical functionalities for its user. It was developed by Zushah during 2022 and 2023 and then released on November 6, 2023. As per the latest release of v2.1.0 Seki, Chalkboard has 455 different commands. The library is available for regular JavaScript on both the client-side and the server-side as well as Proccesing.js (fully compatible with Khan Academy). Chalkboard's website can be visited here.

Installation

If your JavaScript project is being run on the client-side within a webpage, you can install Chalkboard with this HTML tag:

<script src="https://cdn.jsdelivr.net/gh/Zushah/[email protected]/dist/Chalkboard.min.js"></script>

If your JavaScript project is being run on the server-side within the Node.js environment, you can install Chalkboard with this console command:

npm install @zushah/chalkboard

Alternatively, you can simply download the latest release and put the relevant files in your project's directory.

Chalkboard can also be downloaded on Khan Academy from the code in the corresponding release.

Documentation

Chalkboard has twelve categories of commands:

  • calc - Single/multi-variable real/complex-valued calculus operations
  • comp - Complex number and complex function operations
  • geom - Geometric operations
  • matr - Multidimensional matrix operations
  • numb - Number-theory-related operations
  • plot - Plotting real and complex functions, complex numbers, vectors, matrices, and statistical graphs
  • quat - Quaternion operations
  • real - Real number and real function operations
  • stat - Statistical array operations
  • tens - Tensor (multidimensional multidimensional matrix) operations
  • trig - Trigonometric function operations
  • vect - Two-, three-, and four-dimensional vector and vector field operations

There are also eight "global" commands and constants, which are:

  • APPLY - Applies a callback function in an element-wise manner on a Chalkboard object
  • CONTEXT - The JavaScript canvas rendering context to use for plotting
  • E() - Computes the number e
  • LOGO() - Draws the Chalkboard logo
  • PARSEPREFIX - Used for adding custom functions to the Chalkboard parser
  • PI() - Computes the number π
  • README() - Prints basic information about Chalkboard in the console
  • VERSION - The installed version of Chalkboard
  • VERSIONALIAS - The alias of the installed version of Chalkboard

Lastly, Chalkboard has seven data types (also known as Chalkboard objects):

  • ChalkboardComplex - Complex numbers
  • ChalkboardFunction - Mathematical functions
  • ChalkboardMatrix - Matrices
  • ChalkboardQuaternion - Quaternions
  • ChalkboardTensor - Tensors
  • ChalkboardVector - Vectors
  • ChalkboardVectorField - Vector fields

The comprehensive Chalkboard documentation can be visited here.

Getting Started

After installing Chalkboard into your program, you can immediately get started with using it. Every Chalkboard command begins with typing "Chalkboard" followed by a period, then the name of the category of the command (all categories are listed above in the documentation section) with another period, and lastly the desired command itself.

Chalkboard.category.command(parameters);

Here is some code that shows off only a few features of Chalkboard:

const cb = Chalkboard; // Initialize in a browser
// or
const cb = require("@zushah/chalkboard"); // Initialize in Node with CommonJS
// or
import cb from "@zushah/chalkboard"; // Initiialize in Node with ES Modules

let f = cb.real.define("Math.cos(2 * x)"); // f(x) = cos(2x)
let dfdx = cb.calc.dfdx(f, 2); // Derivative of f at x = 0
let fxdx = cb.calc.fxdx(f, 0, 2); // Antiderivative of f from x = 0 to x = 2
let fourier = cb.calc.Fourier(f, 2); // Fourier transform of f at x = 2

let f = cb.vect.field("x", "y", "z"); // f(x, y, z) = (x, y, z)
let r = cb.real.define(["Math.cos(s) * Math.cos(t)", "Math.sin(s) * Math.cos(t)", "Math.sin(t)"], "surf"); // r(s, t) = (cos(s)cos(t), sin(s)cos(t), sin(t))
let fnds = cb.calc.fnds(f, r, cb.PI(-1/2), cb.PI(1/2), 0, cb.PI(2)); // Flux of the radial vector field through the unit sphere

let primes = cb.numb.primeArr(0, 100); // Array of prime numbers between 0 and 100
let midPrime = cb.stat.median(primes); // Median number in the primes array
cb.plot.barplot(primes, cb.stat.array(0, 100, 11), {size: 5, strokeStyle: "black", fillStyle: "blue"}); // Barplot of the primes array with a bin size of 10, a scale of 2, a stroke color of black, and a fill color of blue

let z = cb.comp.init(1, 1); // z = 1 + i
let zsqsqrt = cb.comp.sqrt(cb.comp.sq(z)); // The square root of z squared equals z
let f = cb.comp.define("a*a - b*b + 1", "2*a*b"); // f(z) = z^2 + 1
cb.plot.definition(f); // Plots the domain coloring of f

let r = cb.real.define(["Math.cos(t)", "Math.sin(t)"], "curv"); // r(t) = (cos(t), sin(t))
cb.plot.xyplane({size: 2}); // Draws the Cartesian coordinate plane scaled by 2
cb.plot.definition(r, {size: 2, strokeStyle: "rgb(255, 100, 100)", domain: [0, cb.PI(2)]}); // Plots r(t) scaled by 2 colored light red from t = 0 to t = π/2

let a = cb.vect.init(1, 2, 3); // Vector a = (1, 2, 3)
let b = cb.vect.init(4, 5, 6); // Vector b = (4, 5, 6)
let c = cb.vect.init(7, 8, 9); // Vector c = (7, 8, 9)
let axbxc = cb.vect.vectorTriple(a, b, c); // Triple cross product between a, b, and c
cb.vect.print(axbxc); // Prints axbxc in the console

let m = cb.matr.init( // m is a 5x5 matrix
    [0, 1, 1, 1, 1],
    [1, 0, 1, 1, 1],
    [1, 1, 0, 1, 1],
    [1, 1, 1, 0, 1],
    [1, 1, 1, 1, 0]
);
let mi = cb.matr.invert(m); // mi is the inverse of m
let mmi = cb.matr.mul(m, mi); // mmi is the product of m and mi
cb.matr.print(mmi); // Prints mmi in the console

let t = cb.tens.init( // t is a 2x2x2 rank-3 tensor
    [
        [1, 2],
        [3, 4]
    ],
    [
        [5, 6],
        [7, 8]
    ]
);
let tt = cb.tens.mul(t, t); // tt is a 2x2x2x2x2x2 rank-6 tensor
let ttm = cb.tens.resize(tt, 8, 8); // ttm is an 8x8 matrix (or rank-2 tensor)
cb.tens.print(tt); // Prints tt in the console just to see what it looks like for fun

// Calculates the factorial of each element of t
let factorialt = cb.APPLY(t, (x) => {
    return cb.numb.factorial(x);
});

More examples that are more interesting can be seen here with their source code here.

Contributing

NOTE: If you want to change the documentation, you will also have to clone the zushah.github.io repository because that's where the files are generated.

The changelog can be read here.

The Chalkboard library is available under the MIT License.

Acknowledgments

Thanks to @bhavjitChauhan for his contribution to v1.3.0 Heaviside.
Thanks to @gyang0 for his contribution to the documentation.
Thanks to @JentGent for his implementation for calculating QR decomposition which was adapted into v1.7.0 Descartes.

Contact

GitHub
Khan Academy