Skip to content

Commit 2b3a3bf

Browse files
Sander-ToonenSander Toonen
andauthored
Prepare release version 6 (#8)
Co-authored-by: Sander Toonen <s.toonen@pro-fa.com>
1 parent 3ee7f5b commit 2b3a3bf

19 files changed

Lines changed: 1937 additions & 5233 deletions

BREAKING_CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This document lists breaking changes in the library to help users migrate between versions.
44

5+
## Version 6.0.0
6+
7+
`null` is no longer silently casted to `0`. This means that from version 6 onwards, `null == 0` will no longer be true and `null == someVariable` with `someVariable` having a null value will become true. (This was not the case before.)
8+
59
## Version 5.0.0
610

711
### Security: Functions Must Be Registered Explicitly

docs/language-service.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ A complete working example of Monaco Editor integration is included in the repos
4747

4848
```bash
4949
# Build the UMD bundle and start the sample server
50-
npm run monaco-sample:serve
50+
npm run playground
5151
```
5252

5353
Then open http://localhost:8080 in your browser. The sample demonstrates:

index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export {
3939
} from './src/types/errors.js';
4040

4141
export type {
42-
LanguageServiceApi,
43-
HoverV2,
44-
GetCompletionsParams,
45-
GetHoverParams,
46-
HighlightToken,
47-
LanguageServiceOptions
48-
} from "./src/language-service/index.js";
42+
LanguageServiceApi,
43+
HoverV2,
44+
GetCompletionsParams,
45+
GetHoverParams,
46+
HighlightToken,
47+
LanguageServiceOptions
48+
} from './src/language-service/index.js';
4949

5050
export { createLanguageService, Expression, Parser };

package-lock.json

Lines changed: 1312 additions & 1187 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pro-fa/expr-eval",
3-
"version": "5.0.0",
3+
"version": "6.0.0",
44
"description": "Mathematical expression evaluator",
55
"keywords": [
66
"expression",
@@ -43,7 +43,6 @@
4343
],
4444
"scripts": {
4545
"test": "npm run build && vitest run",
46-
"test:ts": "vitest run test/expression/expression-core-partial.ts test/expression/expression-advanced-partial.ts test/expression/expression-fork-partial.ts test/expression/expression-methods-partial.ts test/functions/functions-binary-ops-partial.ts test/functions/functions-unary-ops-partial.ts test/functions/functions-advanced-partial.ts test/functions/functions-array-string-partial.ts test/functions/functions-logical-partial.ts test/functions/functions-higher-order-partial.ts test/parser/parser-core-partial.ts test/parser/parser-numbers-partial.ts test/parser/parser-options-partial.ts test/operators/operators-comparison-partial.ts test/operators/operators-logical-partial.ts test/operators/operators-math-trig-partial.ts test/operators/operators-math-basic-partial.ts test/operators/operators-misc-partial.ts",
4746
"test:ts:watch": "vitest --testNamePattern=partial",
4847
"test:watch": "vitest",
4948
"test:ui": "vitest --ui",
@@ -57,7 +56,6 @@
5756
"bench:ci": "npm run build && tsx benchmarks/index.bench.ts",
5857
"lint": "eslint **/*.ts --ignore-pattern parser.d.ts",
5958
"tsgo": "tsgo",
60-
"check-types": "tsgo --noEmit",
6159
"type-check": "tsgo --noEmit",
6260
"build:types": "tsgo -p tsconfig.build.json --emitDeclarationOnly",
6361
"build:esm": "cross-env BUILD_TARGET=esm vite build",
@@ -68,7 +66,7 @@
6866
"watch": "cross-env BUILD_TARGET=esm vite build --watch",
6967
"clean": "rimraf dist",
7068
"prepublish": "npm run build",
71-
"monaco-sample:serve": "npm run build:umd && node samples/language-service-sample/serve-sample.cjs"
69+
"playground": "npm run build:umd && node samples/language-service-sample/serve-sample.cjs"
7270
},
7371
"devDependencies": {
7472
"@eslint/js": "^9.15.0",
@@ -83,6 +81,7 @@
8381
"eslint-plugin-n": "^17.0.0",
8482
"eslint-plugin-promise": "^7.0.0",
8583
"rimraf": "^6.0.1",
84+
"terser": "^5.44.1",
8685
"tinybench": "^5.0.1",
8786
"ts-node": "^10.9.2",
8887
"tslib": "^2.8.1",

src/core/evaluate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { ISCALAR, IOP1, IOP2, IOP3, IVAR, IVARNAME, IFUNCALL, IFUNDEF, IEXPR, IEXPREVAL, IMEMBER, IENDSTATEMENT, IARRAY, IUNDEFINED, ICASEMATCH, IWHENMATCH, ICASEELSE, ICASECOND, IWHENCOND, IOBJECT, IPROPERTY, IOBJECTEND } from '../parsing/instruction.js';
99
import type { Instruction } from '../parsing/instruction.js';
1010
import type { Expression } from './expression.js';
11-
import type { Value, Values, VariableResolveResult, VariableAlias, VariableValue } from '../types/values.js';
11+
import type { Value, Values, VariableResolveResult } from '../types/values.js';
1212
import { VariableError } from '../types/errors.js';
1313
import { ExpressionValidator } from '../validation/expression-validator.js';
1414

src/functions/string/operations.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function searchCount(text: string | undefined, substring: string | undefi
9393
if (substring.length === 0) {
9494
return 0;
9595
}
96-
96+
9797
let count = 0;
9898
let position = 0;
9999
while ((position = text.indexOf(substring, position)) !== -1) {
@@ -310,12 +310,12 @@ export function naturalSort(arr: string[] | undefined): string[] | undefined {
310310
if (!Array.isArray(arr)) {
311311
throw new Error('Argument to naturalSort must be an array');
312312
}
313-
313+
314314
const collator = new Intl.Collator(undefined, {
315315
numeric: true,
316316
sensitivity: 'base'
317317
});
318-
318+
319319
return [...arr].sort(collator.compare);
320320
}
321321

@@ -348,16 +348,16 @@ export function toBoolean(str: string | undefined): boolean | undefined {
348348
if (typeof str !== 'string') {
349349
throw new Error('Argument to toBoolean must be a string');
350350
}
351-
351+
352352
const lower = str.toLowerCase().trim();
353-
353+
354354
if (lower === 'true' || lower === '1' || lower === 'yes' || lower === 'on') {
355355
return true;
356356
}
357357
if (lower === 'false' || lower === '0' || lower === 'no' || lower === 'off' || lower === '') {
358358
return false;
359359
}
360-
360+
361361
throw new Error(`Cannot convert "${str}" to a boolean`);
362362
}
363363

src/language-service/language-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export function createLanguageService(options: LanguageServiceOptions | undefine
247247
const range: Range = {
248248
start: textDocument.positionAt(span.start),
249249
end: textDocument.positionAt(span.end)
250-
}
250+
};
251251
return {
252252
contents: {
253253
kind: MarkupKind.PlainText,

src/parsing/parser-state.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// cSpell:words IOBJECT IOBJECTEND
55

66
import {
7-
TOP, TNUMBER, TSTRING, TPAREN, TBRACKET, TCOMMA, TNAME, TSEMICOLON, TEOF, TKEYWORD, TBRACE, Token, TokenType,
8-
TCONST
7+
TOP, TNUMBER, TSTRING, TPAREN, TBRACKET, TCOMMA, TNAME, TSEMICOLON, TEOF, TKEYWORD, TBRACE, Token, TokenType,
8+
TCONST
99
} from './token.js';
1010
import { Instruction, ISCALAR, IVAR, IFUNCALL, IMEMBER, IARRAY, IUNDEFINED, binaryInstruction, unaryInstruction, IWHENMATCH, ICASEMATCH, ICASEELSE, ICASECOND, IWHENCOND, IPROPERTY, IOBJECT, IOBJECTEND, InstructionType } from './instruction.js';
1111
import contains from '../core/contains.js';
@@ -121,7 +121,7 @@ export class ParserState {
121121
} else {
122122
instr.push(new Instruction(IVAR, this.current!.value));
123123
}
124-
} else if (this.accept(TNUMBER) ||this.accept(TSTRING) || this.accept(TCONST)) {
124+
} else if (this.accept(TNUMBER) || this.accept(TSTRING) || this.accept(TCONST)) {
125125
instr.push(new Instruction(ISCALAR, this.current!.value));
126126
} else if (this.accept(TPAREN, '(')) {
127127
this.parseExpression(instr);

src/parsing/parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Expression } from '../core/expression.js';
66
import type { Value, VariableResolveResult, Values } from '../types/values.js';
77
import type { Instruction } from './instruction.js';
88
import type { OperatorFunction } from '../types/parser.js';
9-
import { atan2, condition, fac, filter, fold, gamma, hypot, indexOf, join, map, max, min, random, roundTo, sum, json, stringLength, isEmpty, stringContains, startsWith, endsWith, searchCount, trim, toUpper, toLower, toTitle, stringJoin, split, repeat, reverse, left, right, replace, replaceFirst, naturalSort, toNumber, toBoolean, padLeft, padRight } from '../functions/index.js';
9+
import { atan2, condition, fac, filter, fold, gamma, hypot, indexOf, join, map, max, min, random, roundTo, sum, json, stringLength, isEmpty, stringContains, startsWith, endsWith, searchCount, trim, toUpper, toLower, toTitle, split, repeat, reverse, left, right, replace, replaceFirst, naturalSort, toNumber, toBoolean, padLeft, padRight } from '../functions/index.js';
1010
import {
1111
add,
1212
sub,
@@ -223,13 +223,13 @@ export class Parser {
223223

224224
this.numericConstants = {
225225
E: Math.E,
226-
PI: Math.PI,
226+
PI: Math.PI
227227
};
228228

229229
this.buildInLiterals = {
230230
true: true,
231231
false: false,
232-
null: null,
232+
null: null
233233
};
234234

235235
// A callback that evaluate will call if it doesn't recognize a variable. The default

0 commit comments

Comments
 (0)