benmarch / spel2js Goto Github PK
View Code? Open in Web Editor NEWParse Spring Expression Language in JavaScript
License: Other
Parse Spring Expression Language in JavaScript
License: Other
suppose employe.id = null and expression = "employe.id ? true : false"
if I am trying to evaluate the above expression using SpelExpressionEvaluator.compile(expression) function call. It returns NullPointer exception which was not happening in 0.2.5
Using angular 13 i get the following error:
Could not find a declaration file for module 'spel2js'
when trying to import as:
import { StandardContext, SpelExpressionEvaluator } from 'spel2js';
I was using const spel2js = require('spel2js');
with angular 12 but it does not work on 13 (and i don't know why).
It seems the solution is for you to provide something like @types/spel2js
Hi,
I have a custom class that is existed some variables. I wrote a method that takes a variable inside it and want to evaluate with spel2js. But, I take an error as shown below
"TypeError: Cannot read property 'activeContext' of undefined"
I also share symbolic codes below.
//Class
export class Clazz{
//variables
//method
public foo(variable:string) : string{
//business Logic
}
}
const spelContext = StandardContext.create();
const compiledExpression = SpelExpressionEvaluator.compile("#foo('123') == '123'");
let result = compiledExpression.eval(spelContext, this.clazz);
Hi there, very useful library, Thank you, all!
I got one problem when i use safe navigation.
when i use multi ?.
operators like:
"nested?.doesNotExist?.test"
will throw exception:
ContextDoesNotExistException: Attempting to look up property 'test' for an undefined context.
So is this a bug or i have some misunderstanding about safe navigation ?
Hi,
I'm using Angular 8 for frontend. I have an expression and object for evaluating. For example expression is "(getSubFoo()!=null && getSubFoo() == 'XYZ')" and object is
export class Foo{
field1: string;
field2:string;
public getSubFoo(): string{
// some implementations
}
}
When i want to run above evaluation, evaluation drops to catch and error is message: "Method getSubFoo does not exist."
name: "NullPointerException".
Does spel2js provide to evaluate methods?
Best Regards,
Burak Mert.
object.property throws null pointer exception when object is defined and there is no property.
Ideally it should not throw an exception instead return null or undefined.
example:
let obj = {a: 1, b: 2} is present in the context
and when I try to evaluate the expression like "obj.c == 3 ? true : false" it throws null pointer exception.
I can see nullSafeNavigation is false for me. is there a way I can make it true so that it returns null.
spel2js failed to compile expression with negative value
version: 0.2.6
test('test', () => {
let c = spel2js.SpelExpressionEvaluator.compile('1.0 > -5000.0') // fail to compile
console.log(c);
})
// test failed
// Cannot read property 'setParent' of undefined
When I am trying to evaluate the following expression:
{'PHONE','EMPLOYMENT_PHONE','WORK_PHONE'}.contains(classification)
It looks that the contains method is not supported
Here I leave all data needed to reproduce it:
import { SpelExpressionEvaluator } from 'spel2js';
const context = {
classification: 'PHONE',
};
const expr = `{'PHONE','EMPLOYMENT_PHONE','WORK_PHONE'}.contains(classification)`;
const compiledPrecondition = SpelExpressionEvaluator.compile(expr);
const result = compiledPrecondition.eval(context);
Hi - very useful library, thanks!
If you are ready to do so - are you able to push a new version (0.2.4
I guess) to NPM? There seems to be some packaging issue we have with the published 0.2.3
version that appears to be resolved on HEAD; possibly due to the switch to webpack; but that doesn't seem to be released yet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.