Comments (5)
Thank you, this was very helpful. I'll definitely check v3 out.
from filtrex.
Update: I've finally published v3 as a stable release. Therefore you don't have to worry about release candidates and the like :)
from filtrex.
Hey Talat!
Sorry for the late reply! The problem with your code is that you use single quotes – by looking at the Readme, you can see that strings in Filtrex use double quotes while single quotes are reserved for symbols. In your case, all four of these are identical:
fuzzy(name, John)
fuzzy('name', John)
fuzzy(name, 'John')
fuzzy('name', 'John')
What you actually want is:
fuzzy(name, "John")
from filtrex.
You might also be interested in operator overloading which will be added in Filtrex v3. You can already use it, as v3 has a release candidate on NPM.
import { compileExpression } from "filtrex";
const options = {
operators: {
'~=': function fuzzy(a, b) { return a.toLowerCase().includes(b.toLowerCase()) }
}
};
const expr = `name ~= "john"`;
const f = compileExpression(expr, options);
f({ name: "John Doe"}) // true
f({ name: "Jane Smith"}) // false
from filtrex.
Also: v3 has better error discoverability. If you run your original code in v3, you'll get an UnknownPropertyError, as you should:
from filtrex.
Related Issues (20)
- Investigate rewriting in PEG
- Unary minus has precedence over exponentiation (ie. incorrect parsing of −x²)
- `not in` has weird precedence
- Exponentiation is left-associative
- Add option to use dot attribute access HOT 9
- Access nested object properties HOT 1
- Boolean values are handled as property names HOT 5
- Remove `random` from standard functions to promote reliability
- Change modulo from `%` to `mod`
- Make a changelog for v3
- Add support for asynchronous expressions HOT 1
- Add a Contributing section to README
- Update examples and make new ones
- Filtrex fails CSP HOT 9
- Translatable parser errors
- Get a list of used variables HOT 1
- "non-existent variable" and "!=" expression should return false HOT 1
- Support in async functions
- Single item arrays HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filtrex.