Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: null,
globalSetup: '<rootDir>/test/_setupFiles/globalSetup.ts',

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,
Expand Down Expand Up @@ -120,6 +120,11 @@ module.exports = {
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// The paths to modules that run some code to configure or set up the testing environment after each test
setupFilesAfterEnv: [
'<rootDir>/test/_setupFiles/bootstrap.ts'
],

// The path to a module that runs some code to configure or set up the testing framework before each test
// setupTestFrameworkScriptFile: null,

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"compile": "tsc",
"coverage": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --coverage",
"test": "cross-env NODE_ICU_DATA=node_modules/full-icu jest",
"test.watch": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch",
"test:ci": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --maxWorkers=2",
"typedoc:build": "typedoc --options .typedoc.js",
"typedoc:serve": "npm run typedoc:build && serve doc -p 5005",
Expand Down
70 changes: 49 additions & 21 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {TrigonometryPlugin} from './interpreter/plugin/TrigonometryPlugin'
import {VlookupPlugin} from './interpreter/plugin/VlookupPlugin'
import {Maybe} from './Maybe'
import {ParserConfig} from './parser/ParserConfig'
import {LicenseKeyValidityState, checkLicenseKeyValidity} from './helpers/licenseKey'

type GPUMode = 'gpu' | 'cpu' | 'dev'

Expand All @@ -57,7 +58,7 @@ export interface ConfigParams {
* Applies to comparison operators only.
*
* @default false
*
*
* @category String
*/
accentSensitive: boolean,
Expand All @@ -66,7 +67,7 @@ export interface ConfigParams {
* Applies to comparison operators only.
*
* @default false
*
*
* @category String
*/
caseSensitive: boolean,
Expand All @@ -75,7 +76,7 @@ export interface ConfigParams {
* When set to `false` uses the locale's default.
*
* @default 'lower'
*
*
* @category String
*/
caseFirst: 'upper' | 'lower' | 'false',
Expand All @@ -96,7 +97,7 @@ export interface ConfigParams {
* Any order of YY, MM, DD is accepted as a date, and YY can be replaced with YYYY.
*
* @default ['MM/DD/YYYY', 'MM/DD/YY']
*
*
* @category DateTime
*/
dateFormats: string[],
Expand All @@ -114,7 +115,7 @@ export interface ConfigParams {
* A separator character used to separate arguments of procedures in formulas. Must be different from [[decimalSeparator]] and [[thousandSeparator]].
*
* @default ','
*
*
* @category Syntax
*/
functionArgSeparator: string,
Expand All @@ -123,7 +124,7 @@ export interface ConfigParams {
* Can be either '.' or ',' and must be different from [[thousandSeparator]] and [[functionArgSeparator]].
*
* @default '.'
*
*
* @category Number
*/
decimalSeparator: '.' | ',',
Expand All @@ -133,20 +134,26 @@ export interface ConfigParams {
* @default 'enGB'
*/
language: string,
/**
* License key for commercial version of HyperFormula.
*
* @default ''
*/
licenseKey: string,
/**
* A thousand separator used for parsing numeric literals.
* Can be either empty, ',' or ' ' and must be different from [[decimalSeparator]] and [[functionArgSeparator]].
*
* @default ''
*
*
* @category Number
*/
thousandSeparator: '' | ',' | ' ' | '.',
/**
* A list of additional function plugins to use by formula interpreter.
*
* @default []
*
*
* @category Syntax
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -157,7 +164,7 @@ export interface ConfigParams {
* Other values should be used for debugging purposes only. More info can be found in GPU.js documentation.
*
* @default 'gpu'
*
*
* @category Engine
*/
gpuMode: GPUMode,
Expand All @@ -175,7 +182,7 @@ export interface ConfigParams {
* Set to `true` for compatibility with Lotus 1-2-3 and Excel. See [[nullDate]] for complete solution.
*
* @default false
*
*
* @category DateTime
*/
leapYear1900: boolean,
Expand All @@ -193,24 +200,24 @@ export interface ConfigParams {
* Some CRUD operations may break numeric matrices into individual vertices if needed.
*
* @default true
*
*
* @category Engine
*/
matrixDetection: boolean,
/**
* Specifies how many cells an area must have in order to be treated as a matrix. Relevant only if [[matrixDetection]] is set to `true`.
*
* @default 100
*
* @category Engine
*
* @category Engine
*/
matrixDetectionThreshold: number,
/**
* Two-digit values when interpreted as a year can be either 19xx or 20xx.
* If `xx <= nullYear` its latter, otherwise its former.
*
* @default 30
*
*
* @category DateTime
*/
nullYear: number,
Expand All @@ -232,16 +239,16 @@ export interface ConfigParams {
* for `c=a+b` or `c=a-b`, if `abs(c) <= precisionEpsilon * abs(a)`, then `c` is set to `0`
*
* @default 1e-13
*
* @category Number
*
* @category Number
*/
precisionEpsilon: number,
/**
* Sets how precise the calculation should be.
* Numerical outputs are rounded to `precisionRounding` many digits after the decimal.
*
* @default 14
*
*
* @category Number
*/
precisionRounding: number,
Expand All @@ -258,7 +265,7 @@ export interface ConfigParams {
* If `false`, no rounding happens, and numbers are equal if and only if they are truly identical value (see: [[precisionEpsilon]]).
*
* @default true
*
*
* @category Number
*/
smartRounding: boolean,
Expand All @@ -269,7 +276,7 @@ export interface ConfigParams {
* In some scenarios column index may fall back to binary search despite this flag.
*
* @default false
*
*
* @category Engine
*/
useColumnIndex: boolean,
Expand All @@ -287,7 +294,7 @@ export interface ConfigParams {
* Used by VLOOKUP and MATCH functions.
*
* @default 20
*
*
* @category Engine
*/
vlookupThreshold: number,
Expand Down Expand Up @@ -326,6 +333,7 @@ export class Config implements ConfigParams, ParserConfig {
decimalSeparator: '.',
thousandSeparator: '',
language: 'enGB',
licenseKey: '',
functionPlugins: [],
gpuMode: 'gpu',
leapYear1900: false,
Expand Down Expand Up @@ -402,6 +410,8 @@ export class Config implements ConfigParams, ParserConfig {
/** @inheritDoc */
public readonly language: string
/** @inheritDoc */
public readonly licenseKey: string
/** @inheritDoc */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public readonly functionPlugins: any[]
/** @inheritDoc */
Expand Down Expand Up @@ -440,7 +450,7 @@ export class Config implements ConfigParams, ParserConfig {
public readonly undoLimit: number
/**
* Built automatically based on translation package.
*
*
* @internal
*/
public readonly errorMapping: Record<string, ErrorType>
Expand All @@ -450,6 +460,21 @@ export class Config implements ConfigParams, ParserConfig {
* @internal
*/
public readonly translationPackage: TranslationPackage
/**
* Set automatically based on licenseKey checking result.
*
* @internal
*/
#licenseKeyValidityState: LicenseKeyValidityState
/**
* Proxied property to its private counterpart. This makes the property
* as accessible as the other Config options but without ability to change the value.
*
* @internal
*/
public get licenseKeyValidityState() {
return this.#licenseKeyValidityState
}

constructor(
{
Expand All @@ -463,6 +488,7 @@ export class Config implements ConfigParams, ParserConfig {
decimalSeparator,
thousandSeparator,
language,
licenseKey,
functionPlugins,
gpuMode,
ignorePunctuation,
Expand Down Expand Up @@ -493,6 +519,8 @@ export class Config implements ConfigParams, ParserConfig {
this.functionArgSeparator = this.valueFromParam(functionArgSeparator, 'string', 'functionArgSeparator')
this.decimalSeparator = this.valueFromParam(decimalSeparator, ['.', ','], 'decimalSeparator')
this.language = this.valueFromParam(language, 'string', 'language')
this.licenseKey = this.valueFromParam(licenseKey, 'string', 'licenseKey')
this.#licenseKeyValidityState = checkLicenseKeyValidity(this.licenseKey)
this.thousandSeparator = this.valueFromParam(thousandSeparator, ['', ',', ' ', '.'], 'thousandSeparator')
this.localeLang = this.valueFromParam(localeLang, 'string', 'localeLang')
this.functionPlugins = functionPlugins ?? Config.defaultConfig.functionPlugins
Expand Down
Loading