New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@univerjs/engine-formula

Package Overview
Dependencies
Maintainers
5
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@univerjs/engine-formula - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

7

lib/types/controller/formula.controller.d.ts
import { Disposable, ICommandService } from '@univerjs/core';
import { Ctor, Injector } from '@wendellhu/redi';
import { Ctor } from '@wendellhu/redi';
import { DataSyncPrimaryController } from '@univerjs/rpc';
import { IFunctionNames } from '../basics/function';

@@ -10,5 +11,5 @@ import { BaseFunction } from '../functions/base-function';

private readonly _commandService;
private readonly _injector;
private readonly _functionService;
constructor(_function: Array<[Ctor<BaseFunction>, IFunctionNames]>, _commandService: ICommandService, _injector: Injector, _functionService: IFunctionService);
private readonly _dataSyncPrimaryController?;
constructor(_function: Array<[Ctor<BaseFunction>, IFunctionNames]>, _commandService: ICommandService, _functionService: IFunctionService, _dataSyncPrimaryController?: DataSyncPrimaryController | undefined);
private _initialize;

@@ -15,0 +16,0 @@ private _registerCommands;

@@ -17,22 +17,118 @@ /**

/**
* Packaging basic mathematical calculation methods, adding precision parameters and solving native JavaScript precision problems
* Since Excel follows the IEEE 754 specification, it only handles precision issues when displaying cells. For example, =0.1+0.2, the stored value in XML is 0.30000000000000004, and the displayed value is 0.3. The accuracy of the calculation process does not need to be considered. We only focus on the accuracy of the calculation results. Any result is processed within 15 digits.
Reference https://en.wikipedia.org/wiki/Numeric_precision_in_Microsoft_Excel
*/
export declare function plus(a: number, b: number): number;
export declare function minus(a: number, b: number): number;
export declare function multiply(a: number, b: number): number;
export declare function divide(a: number, b: number): number;
/**
* Native JavaScript: 0.6789 * 10000 = 6788.999999999999
*
* @param a
* @param b
* @returns
* Rounds a number to a specified number of decimal places.
* @param base The number to round.
* @param precision The number of decimal places to round to.
* @returns The rounded number.
*/
export declare function multiply(a: number, b: number): number;
export declare function round(base: number, precision: number): number;
/**
* Rounds down a number to a specified number of decimal places.
* @param base The number to round down.
* @param precision The number of decimal places to round down to.
* @returns The floored number.
*/
export declare function floor(base: number, precision: number): number;
/**
* Rounds up a number to a specified number of decimal places.
* @param base The number to round up.
* @param precision The number of decimal places to round up to.
* @returns The ceiled number.
*/
export declare function ceil(base: number, precision: number): number;
export declare function baseEpsilon(base: number, factor: number): number;
/**
* Returns the remainder of division of two numbers.
* @param base The dividend.
* @param divisor The divisor.
* @returns The remainder.
*/
export declare function mod(base: number, divisor: number): number;
/**
* Raises a base number to the power of the exponent.
*
* @param base The base number.
* @param exponent The exponent.
* @returns The result of base raised to the power of exponent.
*/
export declare function pow(base: number, exponent: number): number;
/**
* Excel can display numbers with up to about 15 digits of precision. This includes the sum of the integer part and the decimal part
* @param input
* Calculates the square root of a number.
* @param base The number to take the square root of.
* @returns The square root of base.
*/
export declare function sqrt(base: number): number;
/**
* Compares two numbers for equality.
* @param a The first number.
* @param b The second number.
* @returns True if numbers are equal, false otherwise.
*/
export declare function equals(a: number, b: number): boolean;
/**
* Checks if the first number is greater than the second number.
* @param a The first number.
* @param b The second number.
* @returns True if a is greater than b, false otherwise.
*/
export declare function greaterThan(a: number, b: number): boolean;
/**
* Checks if the first number is greater than or equal to the second number.
* @param a The first number.
* @param b The second number.
* @returns True if a is greater than or equal to b, false otherwise.
*/
export declare function greaterThanOrEquals(a: number, b: number): boolean;
/**
* Checks if the first number is less than the second number.
* @param a The first number.
* @param b The second number.
* @returns True if a is less than b, false otherwise.
*/
export declare function lessThan(a: number, b: number): boolean;
/**
* Checks if the first number is less than or equal to the second number.
* @param a The first number.
* @param b The second number.
* @returns True if a is less than or equal to b, false otherwise.
*/
export declare function lessThanOrEquals(a: number, b: number): boolean;
/**
* Complete the number to the specified accuracy and solve the accuracy error,
*
* e.g. strip(0.30000000000000004,15) => 0.3
*
* Why precision is 15?
*
* Excel only saves 15 digits
*
reference: https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript
* @param num
* @param precision
* @returns
*/
export declare function truncateNumber(input: number | string): number;
export declare function strip(num: number, precision?: number): number;
/**
* Set an error range for floating-point calculations. If the error is less than Number.EPSILON, we can consider the result reliable.
* @param left
* @param right
* @returns
*/
export declare function withinErrorMargin(left: number, right: number): boolean;
/**
* Tolerance for the results of accuracy issues to tolerate certain errors
*
* Why 12?
This is an empirical choice. Generally, choosing 12 can solve most of the 0001 and 0009 problems. e.g. floor(5,1.23) = 0.0800000000000001
* @param num
* @returns
*/
export declare function stripErrorMargin(num: number, precision?: number): number;

@@ -22,1 +22,2 @@ import { IWorkbookData, Workbook, Univer } from '@univerjs/core';

export declare function getObjectValue(result: FunctionVariantType): string | number | boolean | (string | number | boolean | null)[][];
export declare function stripArrayValue(array: (string | number | boolean | null)[][]): (string | number | boolean | null)[][];

@@ -99,1 +99,3 @@ /**

export { AsyncArrayObject } from './engine/reference-object/base-reference-object';
export { strip, stripErrorMargin } from './engine/utils/math-kit';
export { AsyncObject } from './engine/reference-object/base-reference-object';
{
"name": "@univerjs/engine-formula",
"version": "0.1.13",
"version": "0.1.14",
"private": false,

@@ -48,10 +48,7 @@ "description": "UniverSheet normal base-formula-engine",

],
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"peerDependencies": {
"@wendellhu/redi": "0.15.2",
"rxjs": ">=7.0.0",
"@univerjs/core": "0.1.13"
"@univerjs/core": "0.1.14",
"@univerjs/rpc": "0.1.14"
},

@@ -69,5 +66,19 @@ "dependencies": {

"vitest": "^1.6.0",
"@univerjs/core": "0.1.13",
"@univerjs/shared": "0.1.13"
"@univerjs/core": "0.1.14",
"@univerjs/shared": "0.1.14",
"@univerjs/rpc": "0.1.14"
},
"univerSpace": {
".": {
"import": "./lib/es/index.js",
"require": "./lib/cjs/index.js",
"types": "./lib/types/index.d.ts"
},
"./*": {
"import": "./lib/es/*",
"require": "./lib/cjs/*",
"types": "./lib/types/index.d.ts"
},
"./lib/*": "./lib/*"
},
"scripts": {

@@ -74,0 +85,0 @@ "test": "vitest run",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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