Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mathigon/hilbert

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mathigon/hilbert - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

128

dist/hilbert.js

@@ -49,9 +49,2 @@ 'use strict';

// =============================================================================
// Core.ts | Utility Functions
// (c) Mathigon
// =============================================================================
/** Creates a random UID string of a given length. */
function uid(n = 10) {
return Math.random().toString(36).substr(2, n);
}
/** Checks if x is strictly equal to any one of the following arguments. */

@@ -83,2 +76,51 @@ function isOneOf(x, ...values) {

// =============================================================================
/** Returns the last item in an array, or the ith item from the end. */
function last(array, i = 0) {
return array[array.length - 1 - i];
}
/** Filters all duplicate elements from an array. */
function unique(array) {
return array.filter((a, i) => array.indexOf(a) === i);
}
/** Flattens a nested array into a single list. */
function flatten(array) {
return array.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
}
/** Join multiple Arrays */
function join(...arrays) {
return arrays.reduce((a, x) => a.concat(x), []);
}
// =============================================================================
/** Splits a string into space separated words. */
function words(str, divider = /\s+/) {
if (!str)
return [];
return str.trim().split(divider);
}
// ============================================================================
// Fermat.js | Utility Functions
// (c) Mathigon
// ============================================================================
const PRECISION = 0.000001;
// -----------------------------------------------------------------------------
// Checks and Comparisons
/** Checks if two numbers are nearly equals. */
function nearlyEquals(x, y, t = PRECISION) {
if (isNaN(x) || isNaN(y))
return false;
return Math.abs(x - y) < t;
}
// =============================================================================
// Core.ts | Utility Functions
// (c) Mathigon
// =============================================================================
/** Creates a random UID string of a given length. */
function uid(n = 10) {
return Math.random().toString(36).substr(2, n);
}
// =============================================================================
// Core.ts | Array Functions

@@ -135,6 +177,2 @@ // (c) Mathigon

}
/** Returns the last item in an array, or the ith item from the end. */
function last(array, i = 0) {
return array[array.length - 1 - i];
}
/** Finds the sum of all elements in an numeric array. */

@@ -144,38 +182,4 @@ function total(array) {

}
/** Filters all duplicate elements from an array. */
function unique(array) {
return array.filter((a, i) => array.indexOf(a) === i);
}
/** Flattens a nested array into a single list. */
function flatten(array) {
return array.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
}
/** Join multiple Arrays */
function join(...arrays) {
return arrays.reduce((a, x) => a.concat(x), []);
}
// =============================================================================
/** Splits a string into space separated words. */
function words(str, divider = /\s+/) {
if (!str)
return [];
return str.trim().split(divider);
}
// ============================================================================
// Fermat.js | Utility Functions
// (c) Mathigon
// ============================================================================
const PRECISION = 0.000001;
// -----------------------------------------------------------------------------
// Checks and Comparisons
/** Checks if two numbers are nearly equals. */
function nearlyEquals(x, y, t = PRECISION) {
if (isNaN(x) || isNaN(y))
return false;
return Math.abs(x - y) < t;
}
// =============================================================================
var Matrix;

@@ -865,18 +869,2 @@ (function (Matrix) {

}
class ExprTerm extends ExprElement {
constructor(items) {
super();
this.items = items;
}
evaluate(vars = {}) { return this.collapse().evaluate(vars); }
substitute(vars = {}) { return this.collapse().substitute(vars); }
get simplified() { return this.collapse().simplified; }
get variables() { return unique(join(...this.items.map(i => i.variables))); }
get functions() { return this.collapse().functions; }
toString() { return this.items.map(i => i.toString()).join(' '); }
toMathML(custom = {}) {
return this.items.map(i => i.toMathML(custom)).join('');
}
collapse() { return collapseTerm(this.items).collapse(); }
}

@@ -1040,2 +1028,19 @@ // =============================================================================

}
// -----------------------------------------------------------------------------
class ExprTerm extends ExprElement {
constructor(items) {
super();
this.items = items;
}
evaluate(vars = {}) { return this.collapse().evaluate(vars); }
substitute(vars = {}) { return this.collapse().substitute(vars); }
get simplified() { return this.collapse().simplified; }
get variables() { return unique(join(...this.items.map(i => i.variables))); }
get functions() { return this.collapse().functions; }
toString() { return this.items.map(i => i.toString()).join(' '); }
toMathML(custom = {}) {
return this.items.map(i => i.toMathML(custom)).join('');
}
collapse() { return collapseTerm(this.items).collapse(); }
}

@@ -1332,3 +1337,4 @@ // =============================================================================

exports.ExprElement = ExprElement;
exports.ExprError = ExprError;
exports.Expression = Expression;

@@ -9,1 +9,2 @@ // =============================================================================

export {Expression} from './src/expression';
export {ExprElement} from './src/elements';
{
"name": "@mathigon/hilbert",
"version": "0.3.2",
"version": "0.3.3",
"description": "JavaScript expression parsing, MathML rendering and CAS.",

@@ -27,4 +27,4 @@ "keywords": [

"dependencies": {
"@mathigon/fermat": "^0.3.2",
"@mathigon/core": "^0.3.2"
"@mathigon/fermat": "^0.3.3",
"@mathigon/core": "^0.3.3"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -7,5 +7,4 @@ // =============================================================================

import {join, Obj, unique} from '@mathigon/core';
import {Obj} from '@mathigon/core';
import {CONSTANTS, escape, isSpecialFunction} from './symbols';
import {collapseTerm} from './parser';
import {ExprError} from './errors';

@@ -132,26 +131,1 @@

}
export class ExprTerm extends ExprElement {
constructor(readonly items: ExprElement[]) {
super();
}
evaluate(vars: VarMap = {}) { return this.collapse().evaluate(vars); }
substitute(vars: ExprMap = {}) { return this.collapse().substitute(vars); }
get simplified() { return this.collapse().simplified; }
get variables() { return unique(join(...this.items.map(i => i.variables))); }
get functions() { return this.collapse().functions; }
toString() { return this.items.map(i => i.toString()).join(' '); }
toMathML(custom: MathMLMap = {}) {
return this.items.map(i => i.toMathML(custom)).join('');
}
collapse() { return collapseTerm(this.items).collapse(); }
}

@@ -7,5 +7,6 @@ // =============================================================================

import {unique, flatten, words, isOneOf} from '@mathigon/core';
import {unique, flatten, words, isOneOf, join} from '@mathigon/core';
import {collapseTerm} from './parser';
import {BRACKETS, escape, isSpecialFunction} from './symbols';
import {ExprElement, ExprTerm, ExprNumber, CustomFunction, MathMLMap, VarMap, ExprMap} from './elements';
import {ExprElement, ExprNumber, CustomFunction, MathMLMap, VarMap, ExprMap} from './elements';
import {ExprError} from './errors';

@@ -195,1 +196,28 @@

}
// -----------------------------------------------------------------------------
export class ExprTerm extends ExprElement {
constructor(readonly items: ExprElement[]) {
super();
}
evaluate(vars: VarMap = {}) { return this.collapse().evaluate(vars); }
substitute(vars: ExprMap = {}) { return this.collapse().substitute(vars); }
get simplified() { return this.collapse().simplified; }
get variables() { return unique(join(...this.items.map(i => i.variables))); }
get functions() { return this.collapse().functions; }
toString() { return this.items.map(i => i.toString()).join(' '); }
toMathML(custom: MathMLMap = {}) {
return this.items.map(i => i.toMathML(custom)).join('');
}
collapse() { return collapseTerm(this.items).collapse(); }
}

@@ -9,4 +9,4 @@ // =============================================================================

import {SPECIAL_OPERATORS, SPECIAL_IDENTIFIERS, IDENTIFIER_SYMBOLS, OPERATOR_SYMBOLS, BRACKETS} from './symbols';
import {ExprNumber, ExprIdentifier, ExprOperator, ExprSpace, ExprString, ExprTerm, ExprElement} from './elements';
import {ExprFunction} from './functions';
import {ExprNumber, ExprIdentifier, ExprOperator, ExprSpace, ExprString, ExprElement} from './elements';
import {ExprFunction, ExprTerm} from './functions';
import {ExprError} from './errors';

@@ -13,0 +13,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc