@maptalks/feature-filter
Advanced tools
+13
-3
@@ -40,3 +40,4 @@ /*! | ||
| op === '!has' ? compileNegation(compileHasOp(filter[1])) : | ||
| op === 'test' ? compileRegex(filter[1], filter[2]) : | ||
| // op === 'test' ? compileRegex(filter[1], filter[2]) : | ||
| op === 'contains' ? compileContains(filter[1], filter[2], filter[3]) : | ||
| 'true'; | ||
@@ -46,7 +47,16 @@ return `(${str})`; | ||
| function compileRegex(property, regex) { | ||
| function compileContains(property, str, index) { | ||
| const prop = compilePropertyReference(property); | ||
| return `new RegExp("${regex}").test(${prop})`; | ||
| if (index !== undefined) { | ||
| return `(${prop} + '').indexOf("${str}") === ${index}`; | ||
| } else { | ||
| return `(${prop} + '').indexOf("${str}") >= 0`; | ||
| } | ||
| } | ||
| // function compileRegex(property, regex) { | ||
| // const prop = compilePropertyReference(property); | ||
| // return `new RegExp("${regex}").test(${prop})`; | ||
| // } | ||
| function compilePropertyReference(property) { | ||
@@ -53,0 +63,0 @@ // const ref = |
+1
-1
| { | ||
| "name": "@maptalks/feature-filter", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "main": "./index.js", | ||
@@ -5,0 +5,0 @@ "module": "./index.js", |
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
90164
0.47%1671
0.54%1
-50%