namirasoft-core
Advanced tools
Comparing version 1.3.25 to 1.3.26
@@ -7,4 +7,3 @@ import { FilterItemOperator } from "./FilterItemOperator"; | ||
values: string[]; | ||
static parseAll(item: string | null): FilterItem[]; | ||
static parse(item: string): FilterItem; | ||
static parse(item: string | null): FilterItem[]; | ||
constructor(column: string, not: boolean, operator: FilterItemOperator, ...values: string[]); | ||
@@ -11,0 +10,0 @@ getCommand(): string; |
@@ -6,18 +6,28 @@ "use strict"; | ||
class FilterItem { | ||
static parseAll(item) { | ||
if (item) | ||
return [FilterItem.parse(item)]; | ||
return []; | ||
} | ||
static parse(item) { | ||
let items = item.split(/(?<!\\);/); | ||
if (items.length < 3) | ||
throw new Error("Invalid value for FilterItem: " + item); | ||
let column = items[0]; | ||
let not = items[1] != "0"; | ||
if (items[1] != "0" && items[1] != "1") | ||
throw new Error("Invalid value for FilterItem.not: " + item[1]); | ||
let operator = FilterItemOperator_1.FilterItemOperator.getBySign(items[2]); | ||
let values = items.splice(0, 3).map(x => x.replace(/\\;/gm, ";")); | ||
return new FilterItem(column, not, operator, ...values); | ||
let ans = []; | ||
if (item) { | ||
let items = item.split(/(?<!\\);/); | ||
for (let i = 0; i < items.length;) { | ||
if (i + 3 >= items.length) | ||
throw new Error("Invalid value for FilterItem: " + item); | ||
let columnIndex = i; | ||
let notIndex = i + 1; | ||
let operatorIndex = i + 2; | ||
let valueIndex = i + 3; | ||
let column = items[columnIndex]; | ||
let not = items[notIndex] != "0"; | ||
if (items[notIndex] != "0" && items[notIndex] != "1") | ||
throw new Error("Invalid value for FilterItem.not: " + items[notIndex]); | ||
let operator = FilterItemOperator_1.FilterItemOperator.getBySign(items[operatorIndex]); | ||
let values = []; | ||
for (let j = 0; j < operator.count; j++) { | ||
let value = items[valueIndex + j].replace(/\\;/gm, ";"); | ||
values.push(value); | ||
} | ||
ans.push(new FilterItem(column, not, operator, ...values)); | ||
i += 3 + operator.count; | ||
} | ||
} | ||
return ans; | ||
} | ||
@@ -24,0 +34,0 @@ constructor(column, not, operator, ...values) { |
@@ -11,3 +11,3 @@ { | ||
"private": false, | ||
"version": "1.3.25", | ||
"version": "1.3.26", | ||
"author": "Amir Abolhasani", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@types/node": "^20.12.8", | ||
"@types/node": "^20.12.10", | ||
"axios": "^1.6.8", | ||
@@ -24,0 +24,0 @@ "moment": "^2.30.1", |
@@ -9,22 +9,33 @@ import { FilterItemOperator } from "./FilterItemOperator"; | ||
public values: string[]; | ||
public static parseAll(item: string | null): FilterItem[] | ||
public static parse(item: string | null): FilterItem[] | ||
{ | ||
// todo impolement | ||
let ans: FilterItem[] = []; | ||
if (item) | ||
return [FilterItem.parse(item)]; | ||
return []; | ||
{ | ||
let items = item.split(/(?<!\\);/); | ||
for (let i = 0; i < items.length;) | ||
{ | ||
if (i + 3 >= items.length) | ||
throw new Error("Invalid value for FilterItem: " + item); | ||
let columnIndex = i; | ||
let notIndex = i + 1; | ||
let operatorIndex = i + 2; | ||
let valueIndex = i + 3; | ||
let column = items[columnIndex]; | ||
let not = items[notIndex] != "0"; | ||
if (items[notIndex] != "0" && items[notIndex] != "1") | ||
throw new Error("Invalid value for FilterItem.not: " + items[notIndex]); | ||
let operator = FilterItemOperator.getBySign(items[operatorIndex]); | ||
let values: string[] = []; | ||
for (let j = 0; j < operator.count; j++) | ||
{ | ||
let value = items[valueIndex + j].replace(/\\;/gm, ";"); | ||
values.push(value); | ||
} | ||
ans.push(new FilterItem(column, not, operator, ...values)); | ||
i += 3 + operator.count; | ||
} | ||
} | ||
return ans; | ||
} | ||
public static parse(item: string): FilterItem | ||
{ | ||
let items = item.split(/(?<!\\);/); | ||
if (items.length < 3) | ||
throw new Error("Invalid value for FilterItem: " + item); | ||
let column = items[0]; | ||
let not = items[1] != "0"; | ||
if (items[1] != "0" && items[1] != "1") | ||
throw new Error("Invalid value for FilterItem.not: " + item[1]); | ||
let operator = FilterItemOperator.getBySign(items[2]); | ||
let values = items.splice(0, 3).map(x => x.replace(/\\;/gm, ";")); | ||
return new FilterItem(column, not, operator, ...values); | ||
} | ||
constructor(column: string, not: boolean, operator: FilterItemOperator, ...values: string[]) | ||
@@ -31,0 +42,0 @@ { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
341743
4232
Updated@types/node@^20.12.10