@devmm/puredocs-excel-formula 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +15 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -282,7 +282,7 @@ var _FormulaValue = class _FormulaValue {
|
|
|
282
282
|
if (value2 === null || value2 === void 0) return _FormulaValue.blank;
|
|
283
283
|
if (typeof value2 === "number") return isNaN(value2) ? _FormulaValue.errorValue : _FormulaValue.number(value2);
|
|
284
284
|
if (typeof value2 === "boolean") return _FormulaValue.boolean(value2);
|
|
285
|
-
if (typeof value2 === "string") return
|
|
285
|
+
if (typeof value2 === "string") return _FormulaValue.text(value2);
|
|
286
286
|
if (value2 instanceof Date) {
|
|
287
287
|
return _FormulaValue.number(puredocsExcel.toOADate(value2));
|
|
288
288
|
}
|
|
@@ -1820,11 +1820,14 @@ function count(a, c) {
|
|
|
1820
1820
|
function countA(a, c) {
|
|
1821
1821
|
return FormulaValue.number(exports.FormulaHelper.flattenArgs(a, c).filter((v) => !v.isBlank).length);
|
|
1822
1822
|
}
|
|
1823
|
+
function isCountBlank(v) {
|
|
1824
|
+
return v.isBlank || v.isText && v.textValue === "";
|
|
1825
|
+
}
|
|
1823
1826
|
function countBlank(a, c) {
|
|
1824
1827
|
const v = a[0].evaluate(c);
|
|
1825
|
-
if (!v.isArray) return FormulaValue.number(v
|
|
1828
|
+
if (!v.isArray) return FormulaValue.number(isCountBlank(v) ? 1 : 0);
|
|
1826
1829
|
let n = 0;
|
|
1827
|
-
for (const item of v.arrayVal.values()) if (item
|
|
1830
|
+
for (const item of v.arrayVal.values()) if (isCountBlank(item)) n++;
|
|
1828
1831
|
return FormulaValue.number(n);
|
|
1829
1832
|
}
|
|
1830
1833
|
function countIf(a, c) {
|
|
@@ -1832,11 +1835,12 @@ function countIf(a, c) {
|
|
|
1832
1835
|
if (range.isError) return range;
|
|
1833
1836
|
const crit = a[1].evaluate(c);
|
|
1834
1837
|
if (crit.isError) return crit;
|
|
1835
|
-
const
|
|
1836
|
-
if (!range.isArray) return FormulaValue.number(
|
|
1838
|
+
const compiled = exports.FormulaHelper.compileCriteria(crit.asText());
|
|
1839
|
+
if (!range.isArray) return FormulaValue.number(compiled.test(range) ? 1 : 0);
|
|
1840
|
+
const countBlanks = compiled.kind === "blankness";
|
|
1837
1841
|
let n = 0;
|
|
1838
1842
|
for (const item of range.arrayVal.values()) {
|
|
1839
|
-
if (!item.isBlank &&
|
|
1843
|
+
if ((countBlanks || !item.isBlank) && compiled.test(item)) n++;
|
|
1840
1844
|
}
|
|
1841
1845
|
return FormulaValue.number(n);
|
|
1842
1846
|
}
|
|
@@ -4728,6 +4732,8 @@ exports.FormulaHelper = void 0;
|
|
|
4728
4732
|
const rhsVal = parseFloat(rhs);
|
|
4729
4733
|
const rhsNum = isNaN(rhsVal) ? null : rhsVal;
|
|
4730
4734
|
const rhsValue = rhsNum !== null ? FormulaValue.number(rhsNum) : FormulaValue.text(rhs);
|
|
4735
|
+
if (rhs === "" && op === "=") return { kind: "blankness", test: (v) => v.isBlank };
|
|
4736
|
+
if (rhs === "" && op === "<>") return { kind: "other", test: (v) => !v.isBlank };
|
|
4731
4737
|
if (op === "=") {
|
|
4732
4738
|
return rhsNum !== null ? numberEquality(rhsNum) : textEquality(rhs);
|
|
4733
4739
|
}
|
|
@@ -4743,6 +4749,9 @@ exports.FormulaHelper = void 0;
|
|
|
4743
4749
|
const pattern = wildcardToRegex(trimmed);
|
|
4744
4750
|
return { kind: "other", test: (v) => pattern.test(v.asText()) };
|
|
4745
4751
|
}
|
|
4752
|
+
if (trimmed === "") {
|
|
4753
|
+
return { kind: "blankness", test: (v) => v.isBlank || v.isText && v.textValue === "" };
|
|
4754
|
+
}
|
|
4746
4755
|
const num5 = parseFloat(trimmed);
|
|
4747
4756
|
return isNaN(num5) ? textEquality(trimmed) : numberEquality(num5);
|
|
4748
4757
|
}
|